inital commit

This commit is contained in:
2026-07-09 00:27:26 +01:00
commit 06bcac9bf7
22 changed files with 793 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#include <player.hpp>
#include <movement.hpp>
#include <scene.hpp>
#include <render.hpp>
#include <asset/raylib_asset.hpp>
GamePlayScene::GamePlayScene() {
registry = entt::registry();
asset_loader.load_asset("assets/bird.png");
create_player(registry,asset_loader.get_texture("assets/bird.png"));
}
void GamePlayScene::update(float dt) {
update_movement_system(registry, dt);
update_player_system(registry, dt);
}
void GamePlayScene::render() {
update_render_system(registry);
}
void GamePlayScene::ui() {
}
GamePlayScene::~GamePlayScene(){
asset_loader.unload_asset("assets/bird.png");
}
+56
View File
@@ -0,0 +1,56 @@
#include <player.hpp>
#include <movement.hpp>
#include <scene.hpp>
#include <imgui.h>
// #include <format>
MenuScene::MenuScene() {
}
void MenuScene::update(float dt) {
}
void MenuScene::render() {}
void MenuScene::ui() {
// Get the current screen/viewport size
ImVec2 screen_size = ImGui::GetIO().DisplaySize;
// size of button container
ImVec2 vbox_size = ImVec2(200.0f, 250.0f);
// set next container to be center of the screen
ImVec2 screen_center = ImVec2(screen_size.x * 0.5f, screen_size.y * 0.5f);
ImGui::SetNextWindowPos(screen_center, ImGuiCond_Always,ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowSize(vbox_size);
// remove sub window decoration
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground;
ImGui::Begin("VBoxContainer", nullptr, flags);
// set button width to be size fill container
ImVec2 button_size = ImVec2(ImGui::GetContentRegionAvail().x, 50.0f);
// ImGui::SetCursorPos(centeredPos);
if (ImGui::Button("Play",button_size)){
g_Engine.request_switch(SceneType::GAMEPLAY);
}
ImGui::Dummy(ImVec2(0, 10)); // Gap
if (ImGui::Button("Quit",button_size)){
g_Engine.quit();
}
ImGui::End();
// ImGui::Begin("Debug");
// ImGui::Button("Hello",button_size);
// ImGui::TextUnformatted(std::format("window size: {} {} ", screen_size.x,screen_size.y).c_str());
// ImGui::End();
}
+39
View File
@@ -0,0 +1,39 @@
#include <scene.hpp>
SceneManager::SceneManager(){
current_scene = new MenuScene();
}
SceneManager::~SceneManager(){
delete current_scene;
}
void SceneManager::process_scene_switch(){
if (!g_Engine.pendingSwitch) return;
delete current_scene;
switch(g_Engine.nextScene){
case SceneType::MENU:
current_scene = new MenuScene();
break;
case SceneType::GAMEPLAY:
current_scene = new GamePlayScene();
break;
}
g_Engine.pendingSwitch = false;
}
void SceneManager::update(float dt){
if (current_scene){
current_scene->update(dt);
}
}
void SceneManager::render(){
current_scene->render();
}
void SceneManager::ui(){
current_scene->ui();
}