menu
This commit is contained in:
@@ -12,6 +12,7 @@ GAME_ENTITY(Player)
|
||||
void setGroundTexture(std::shared_ptr<Game::Renderer::Texture> tex);
|
||||
void respawnRandomSea(float landBoundaryX);
|
||||
bool isShipMode() const { return mIsShipMode; }
|
||||
void setShipMode(bool isShip) { mIsShipMode = isShip; } // Set form state for replay
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
private:
|
||||
Object::Sound mSound;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
#include <object/ui/uitextbox.hpp>
|
||||
|
||||
namespace Game::AGame {
|
||||
class SampleTextBox : public Object::UITextBox {
|
||||
using Object::UITextBox::UITextBox; // Inherit constructors
|
||||
|
||||
public:
|
||||
~SampleTextBox() override = default;
|
||||
|
||||
void start() override {
|
||||
// Call the base class start to initialize the text box
|
||||
mZIndex = 1000; // Ensure it renders on top of most other entities
|
||||
Object::UITextBox::start();
|
||||
setText("Hello, World!");
|
||||
|
||||
mIsActive = false;
|
||||
mIsVisible = false;
|
||||
}
|
||||
void update(float deltaTime) override {
|
||||
// Call the base class update to handle input and text refreshing
|
||||
Object::UITextBox::update(deltaTime);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -19,7 +19,8 @@ namespace Game {
|
||||
enum class GameStateEnum {
|
||||
RUNNING,
|
||||
PAUSED,
|
||||
STOPPED
|
||||
STOPPED,
|
||||
REPLAY
|
||||
};
|
||||
|
||||
enum class SharedDataType {
|
||||
@@ -59,7 +60,14 @@ namespace Game {
|
||||
static void processPendingEntityRemovals();
|
||||
|
||||
static void pushPlayerPosition(Object::Transform transform) { mPlayerTransformHistory.push_back(transform); }
|
||||
static void pushPlayerFormState(bool isShipMode) { mPlayerFormHistory.push_back(isShipMode); }
|
||||
static void getPlayerPositionHistory(std::vector<Object::Transform>& outHistory) { outHistory = mPlayerTransformHistory; }
|
||||
static void getPlayerFormHistory(std::vector<bool>& outHistory) { outHistory = mPlayerFormHistory; }
|
||||
|
||||
// Replay mode API
|
||||
static bool initReplayMode();
|
||||
static bool playReplayFrame();
|
||||
static void stopReplayMode();
|
||||
|
||||
private:
|
||||
int mTargetUpdatesPerSecond = TARGET_UPDATE_RATE;
|
||||
@@ -69,8 +77,17 @@ namespace Game {
|
||||
static std::unordered_map<std::string, float> mSharedFloats;
|
||||
static std::unordered_map<std::string, bool> mSharedBools;
|
||||
static std::vector<Object::Transform> mPlayerTransformHistory;
|
||||
static std::vector<bool> mPlayerFormHistory;
|
||||
static GameStateEnum mCurrentGameState;
|
||||
float mLastDelta = 0.f;
|
||||
|
||||
// Replay data
|
||||
struct ReplayFrame {
|
||||
float x, y, rotation, scaleX, scaleY;
|
||||
bool isShipMode;
|
||||
};
|
||||
static std::vector<ReplayFrame> mReplayFrames;
|
||||
static size_t mCurrentReplayFrame;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace Game {
|
||||
class Input {
|
||||
@@ -16,13 +20,23 @@ namespace Game {
|
||||
static bool isMouseButtonJustReleased(Uint8 button);
|
||||
static float getMouseX();
|
||||
static float getMouseY();
|
||||
|
||||
// Text input from SDL text-input events (pushed by window thread, consumed by game thread)
|
||||
static void pushText(const std::string& utf8);
|
||||
static void consumeText(std::vector<std::string>& out);
|
||||
|
||||
private:
|
||||
static const bool* mCurrentKeyStates;
|
||||
static const bool* mPreviousKeyStates;
|
||||
static std::vector<Uint8> mPreviousKeyStates;
|
||||
static int mNumKeys;
|
||||
static int mPrevNumKeys;
|
||||
static SDL_MouseButtonFlags mCurrentMouseButtonStates;
|
||||
static SDL_MouseButtonFlags mPreviousMouseButtonStates;
|
||||
static float mMouseX;
|
||||
static float mMouseY;
|
||||
|
||||
// Text input queue and mutex (window thread writes via pushText, game thread reads via consumeText)
|
||||
static std::mutex mTextMutex;
|
||||
static std::vector<std::string> mPendingText;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user