Created
January 20, 2020 02:21
-
-
Save native-m/9ffd0c2199e0249f7883cb2be4b2c34c to your computer and use it in GitHub Desktop.
example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Hx.hpp> | |
#include <iostream> | |
using Hx::App::Application; | |
using Hx::App::Game; | |
using Hx::Entity::Entity; | |
using Hx::Entity::EntityManager; | |
using Hx::Entity::PlayerSystem; | |
using Hx::Math::Vec2; | |
class MyPlayerSystem : public PlayerSystem | |
{ | |
MyPlayerSystem() | |
: PlayerSystem() | |
{ | |
} | |
}; | |
class MyGame : public Game | |
{ | |
public: | |
MyGame() | |
: Game("MyGame") | |
{ | |
} | |
~MyGame() | |
{ | |
} | |
void Initialize() | |
{ | |
// Register builtin player system | |
this->EntityMgr.RegisterSystem<MyPlayerSystem>(); | |
// Create player and its component | |
this->PlayerEntity = this->EntityMgr.CreateEntity(); | |
this->PlayerEntity.AssignComponent<PlayerSystem::Position>(100.0f, 50.0f); | |
this->PlayerEntity.AssignComponent<PlayerSystem::Direction>(0.0f, 0.0f); | |
} | |
private: | |
MyPlayerComponent PlayerComp; | |
EntityManager EntityMgr; | |
Entity PlayerEntity; | |
}; | |
int main() | |
{ | |
MyGame game; | |
Application app(game); | |
if(!(game.Initialize() || game.Initialize())) | |
{ | |
std::cout << "Failed to initialize game engine" << std::endl; | |
return -1; | |
} | |
return app.Run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment