46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
|
#include "IsoEngine.h"
|
||
|
#include "components/transform_component.h"
|
||
|
#include "components/input_component.h"
|
||
|
#include <raylib.h>
|
||
|
|
||
|
int main() {
|
||
|
IsoEngine engine(800, 600, nullptr);
|
||
|
engine.Initialize();
|
||
|
|
||
|
SceneManager& sceneManager = engine.GetSceneManager();
|
||
|
entt::entity gameScene = sceneManager.CreateScene();
|
||
|
sceneManager.SetActiveScene(gameScene);
|
||
|
|
||
|
entt::entity player = engine.GetRegistry().create();
|
||
|
engine.GetRegistry().emplace<TransformComponent>(player, 400.0f, 300.0f, 1.0f, 1.0f, 0.0f);
|
||
|
|
||
|
auto& inputComponent = engine.GetRegistry().emplace<InputComponent>(player);
|
||
|
|
||
|
inputComponent.BindKey(InputAction::MOVE_UP, KEY_W);
|
||
|
inputComponent.BindKey(InputAction::MOVE_DOWN, KEY_S);
|
||
|
inputComponent.BindKey(InputAction::MOVE_LEFT, KEY_A);
|
||
|
inputComponent.BindKey(InputAction::MOVE_RIGHT, KEY_D);
|
||
|
|
||
|
inputComponent.SetActionCallback(InputAction::MOVE_UP, [&]() {
|
||
|
auto& transform = engine.GetRegistry().get<TransformComponent>(player);
|
||
|
transform.y -= 5.0f;
|
||
|
});
|
||
|
inputComponent.SetActionCallback(InputAction::MOVE_DOWN, [&]() {
|
||
|
auto& transform = engine.GetRegistry().get<TransformComponent>(player);
|
||
|
transform.y += 5.0f;
|
||
|
});
|
||
|
inputComponent.SetActionCallback(InputAction::MOVE_LEFT, [&]() {
|
||
|
auto& transform = engine.GetRegistry().get<TransformComponent>(player);
|
||
|
transform.x -= 5.0f;
|
||
|
});
|
||
|
inputComponent.SetActionCallback(InputAction::MOVE_RIGHT, [&]() {
|
||
|
auto& transform = engine.GetRegistry().get<TransformComponent>(player);
|
||
|
transform.x += 5.0f;
|
||
|
});
|
||
|
|
||
|
engine.Run();
|
||
|
|
||
|
engine.Shutdown();
|
||
|
return 0;
|
||
|
}
|