It is a simple 2d game demo with physics written in C++ using Unity3d-like gameobject/component system. I've tried to make it easy to extend and to upgrade
- Add new empty GameObject to game world.
auto& newGameObject = scene.createGameObject();
- Add Physics component to this object. All components require GameObject reference. And physComponent needs some physics info: mass, static or dynamic, is affected by gravity or not.
newGameObject.addComponent("Physics", new PhysComponent(newGameObject, 0.0f, false, false));
- We can get component from GO by name.
const auto currentPhysComponent = newGameObject.getComponent<PhysComponent>("Physics")
- Set the collider of physComponent.
currentPhysComponent -> setCollider(Collider::rectangleCollider(sf::Vector2f(1.0f,3.0f));
- Set GameObject's position.
newGameObject.getTransform().position = sf::Vector2f(3.0f,4.0f);
You will need SFML library to compile it.
sudo apt install libsfml-dev
git clone https://github.com/Cheburum/bubbly.git
cd ./bubbly/src
cmake .
make
GPLv3 (look LICENSE file in repository).