starting game planning
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "Application.h"
|
||||
#include "Game.h"
|
||||
#include "backend/RaylibInput.h"
|
||||
|
||||
#include <raylib.h>
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Debugger.h>
|
||||
|
||||
Game game;
|
||||
|
||||
bool Application::Init(int width, int height, const char* title, const char* documentPath) {
|
||||
InitWindow(width, height, title);
|
||||
SetTargetFPS(60);
|
||||
@@ -24,6 +27,8 @@ bool Application::Init(int width, int height, const char* title, const char* doc
|
||||
TraceLog(LOG_WARNING, "Failed to load %s", documentPath);
|
||||
}
|
||||
|
||||
game.Init(context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,10 +41,12 @@ void Application::Frame() {
|
||||
ForwardInputToRml(context);
|
||||
context->Update();
|
||||
|
||||
game.Update();
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(DARKGRAY);
|
||||
|
||||
// --- game world rendering goes here, before the UI ---
|
||||
game.Draw2D();
|
||||
|
||||
context->Render();
|
||||
EndDrawing();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <RmlUi/Core/Context.h>
|
||||
#include "backend/RaylibSystemInterface.h"
|
||||
#include "backend/RaylibRenderInterface.h"
|
||||
#include "Game.h"
|
||||
|
||||
class Application {
|
||||
public:
|
||||
|
||||
20
src/Game.cpp
Normal file
20
src/Game.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "Game.h"
|
||||
#include <RmlUi/Core/Context.h>
|
||||
#include <iostream>
|
||||
#include <raylib.h>
|
||||
#include <RmlUi/Core.h>
|
||||
|
||||
void Game::Draw2D() {return;}
|
||||
|
||||
void Game::Update() {
|
||||
// TODO: Remove this debug
|
||||
std::cout << "Game update" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
bool Game::Init(Rml::Context *context) {
|
||||
if (!ctx) return false;
|
||||
|
||||
ctx = context;
|
||||
return true;
|
||||
}
|
||||
32
src/Game.h
Normal file
32
src/Game.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <RmlUi/Core/Context.h>
|
||||
#include <RmlUi/Core/DataModelHandle.h>
|
||||
enum GameState {
|
||||
START_MENU,
|
||||
PAUSE_MENU,
|
||||
STATS_MENU,
|
||||
OPTIONS_MENU,
|
||||
IN_GAME
|
||||
};
|
||||
|
||||
struct GameData {
|
||||
GameState game_state = START_MENU;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Game {
|
||||
public:
|
||||
GameData game_data;
|
||||
|
||||
bool Init(Rml::Context *context);
|
||||
|
||||
bool setup_rml_data_binding(Rml::Context *ctx, Rml::DataModelHandle &model_handle, GameData &game_data);
|
||||
|
||||
void Update();
|
||||
void Draw2D();
|
||||
|
||||
private:
|
||||
Rml::Context *ctx = nullptr;
|
||||
};
|
||||
Reference in New Issue
Block a user