This library was created using the library template
This library is used to create simulations or simple games. It doesn't have all the advanced features that a modern game engine supports, but it is designed to be simple and easy. The idea behind this project is to have a tool that can be used to create simulation environments for AI-based or physics simulations.
- Easy integration into a QT widget
- GameObjects organized in a tree structure
- Multi-threaded GameObject updates for complex scenes (if enabled)
- GameObjects can be customized without creating an inherited class
- Components allow you to add special functionality to a GameObject.
- Collision detection for polygon shapes using Collider component.
- Multiple camera views can be used in one scene.
- Predefined Components ready to use.
- Disable specific parts of the update loop for all or individual objects to speed up the engine
- Dear Im Gui compatible
- Built in performance profiler
This Project is CMake based, you need to install CMake and QT5 with the MSVC compiler.
After that, download this repository and open the root CMakeLists.txt Project with Visual Studio.
CMake will automaticly download the dependencies for this library.
After CMake has configured the Project, press build->install.
This will build all targets and copies the nessesarry QT dll's to the build directory.
- easy_profiler to enable performace profiling
- Logger to create log messages to the console
- SFML as graphics library
- Qt Framework and Qt VisualStudio Tools
- ImGui as additional UI extention
- EA STL faster container tamplates
- FastNoiseLite a fast portable noise library
#include <QApplication>
#include "QSFML_EditorWidget.h"
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
// Create a QWidget to show the Scene in
QWidget screenWidget;
screenWidget.resize(500, 500);
// Create the scene that holds all GameObjects
QSFML::SceneSettings settings;
settings.timing.frameTime = 0.03; // ms -> ~60 FPS
QSFML::Scene scene(&screenWidget, settings);
// Create a editor GameObject, it creates a simple grid and manages
// camera movement.
QSFML::Objects::DefaultEditor* editor = new QSFML::Objects::DefaultEditor("Editor", sf::Vector2f(1000, 800));
scene.addObject(editor); // Add the object to the scene
// Create a empty GameObject
QSFML::Objects::GameObject* object = new QSFML::Objects::GameObject("MyObject");
// Add a custom update lambda function to that empty GameObject
object->addUpdateFunction([](QSFML::Objects::GameObject& obj)
{
// obj is a ref to it self, rotate it self a bit
obj.rotate(obj.getDeltaT() * 50.f);
});
// Add a custom draw lambda function to the GameObject
object->addDrawFunction([](const QSFML::Objects::GameObject& obj, sf::RenderTarget& target, sf::RenderStates states)
{
// Create a square to visualize the rotating object
sf::RectangleShape shape(sf::Vector2f(400, 400));
shape.setPosition(-200, -200);
shape.setFillColor(sf::Color::Red);
target.draw(shape, states);
});
// Add the GameObject to the scene
scene.addObject(object);
// Start the updat loop of the scene
scene.start();
screenWidget.show();
return a.exec();
}