2024-09-09 02:50:07 -06:00
|
|
|
#include "IsoEngine.h"
|
2024-09-14 02:41:14 -06:00
|
|
|
#include "components.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#define ENABLE_LOGGING
|
|
|
|
|
|
|
|
enum class MenuState {
|
|
|
|
MAIN_MENU,
|
|
|
|
OPTIONS,
|
|
|
|
QUIT
|
|
|
|
};
|
2024-09-09 02:50:07 -06:00
|
|
|
|
|
|
|
int main() {
|
2024-09-14 02:41:14 -06:00
|
|
|
int screenWidth = 800;
|
|
|
|
int screenHeight = 600;
|
|
|
|
IsoEngine engine(screenWidth, screenHeight, nullptr);
|
2024-09-09 02:50:07 -06:00
|
|
|
engine.Initialize();
|
|
|
|
|
|
|
|
SceneManager& sceneManager = engine.GetSceneManager();
|
2024-09-14 02:41:14 -06:00
|
|
|
entt::entity mainMenuScene = sceneManager.CreateScene();
|
2024-09-09 02:50:07 -06:00
|
|
|
|
2024-09-14 02:41:14 -06:00
|
|
|
auto& registry = engine.GetRegistry();
|
2024-09-09 02:50:07 -06:00
|
|
|
|
2024-09-14 02:41:14 -06:00
|
|
|
// Button dimensions
|
|
|
|
float buttonWidth = 200.0f;
|
|
|
|
float buttonHeight = 50.0f;
|
|
|
|
float spacing = 20.0f; // Vertical spacing between buttons
|
2024-09-09 02:50:07 -06:00
|
|
|
|
2024-09-14 02:41:14 -06:00
|
|
|
// Center X position
|
|
|
|
float centerX = screenWidth / 2 - buttonWidth / 2;
|
2024-09-09 02:50:07 -06:00
|
|
|
|
2024-09-14 02:41:14 -06:00
|
|
|
// Y positions for each button
|
|
|
|
float singlePlayerY = screenHeight / 2 - (buttonHeight + spacing);
|
|
|
|
float quitButtonY = screenHeight / 2 + (buttonHeight + spacing);
|
|
|
|
|
|
|
|
// Create a UI button for "Single Player"
|
|
|
|
entt::entity singlePlayerButton = registry.create();
|
|
|
|
registry.emplace<TransformComponent>(singlePlayerButton, centerX, singlePlayerY, 1.0f, 1.0f, 0.0f); // Centered horizontally
|
|
|
|
registry.emplace<UIComponent>(singlePlayerButton, "Single Player", buttonWidth, buttonHeight, [&]() {
|
|
|
|
std::cout << "Single Player button clicked!" << std::endl;
|
2024-09-09 02:50:07 -06:00
|
|
|
});
|
2024-09-14 02:41:14 -06:00
|
|
|
registry.emplace<LayerComponent>(singlePlayerButton, 1); // Main menu on layer 1
|
|
|
|
|
|
|
|
// Create a "Quit" button
|
|
|
|
entt::entity quitButton = registry.create();
|
|
|
|
registry.emplace<TransformComponent>(quitButton, centerX, quitButtonY, 1.0f, 1.0f, 0.0f); // Centered horizontally
|
|
|
|
registry.emplace<UIComponent>(quitButton, "Quit", buttonWidth, buttonHeight, [&]() {
|
|
|
|
engine.Shutdown();
|
2024-09-09 02:50:07 -06:00
|
|
|
});
|
2024-09-14 02:41:14 -06:00
|
|
|
registry.emplace<LayerComponent>(quitButton, 1); // Also on layer 1
|
|
|
|
|
|
|
|
// Create an "F3" debug overlay on a higher layer
|
|
|
|
entt::entity debugOverlay = registry.create();
|
|
|
|
registry.emplace<TransformComponent>(debugOverlay, 10.0f, 10.0f, 1.0f, 1.0f, 0.0f); // Placed at top-left corner
|
|
|
|
registry.emplace<UIComponent>(debugOverlay, "FPS: 60\nPosition: (100, 200)", 300.0f, 100.0f, nullptr);
|
|
|
|
registry.emplace<LayerComponent>(debugOverlay, 2); // Debug overlay on layer 2
|
|
|
|
|
|
|
|
// Set active scene to the main menu
|
|
|
|
sceneManager.SetActiveScene(mainMenuScene);
|
2024-09-09 02:50:07 -06:00
|
|
|
|
2024-09-14 02:41:14 -06:00
|
|
|
// Run the engine loop
|
2024-09-09 02:50:07 -06:00
|
|
|
engine.Run();
|
|
|
|
|
|
|
|
engine.Shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
2024-09-14 02:41:14 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
// });
|