input, changes

This commit is contained in:
2026-03-16 08:21:04 +01:00
parent d522881358
commit f6a1e59ebb
12 changed files with 109 additions and 44 deletions

View File

@@ -19,8 +19,6 @@ namespace Game::AGame {
}
private:
float mSpeed = 200.f; // Pixels per second
int mScreenW, mScreenH;
int mEdgeTolerance = 200;
};
}

View File

@@ -8,6 +8,9 @@
#include <chrono>
#include <functional>
#include <object/camera.hpp>
#include <game/input.hpp>
#include <unordered_map>
#include <memory>
namespace Game {
using clock = std::chrono::steady_clock;
@@ -22,8 +25,14 @@ namespace Game {
void run(std::stop_token stopToken);
void setTargetUpdatesPerSecond(int target) { mTargetUpdatesPerSecond = target; }
int getTargetUpdatesPerSecond() { return mTargetUpdatesPerSecond; }
static void setSharedData(const std::string& key, std::string data);
static std::string getSharedData(const std::string& key);
static void removeSharedData(const std::string& key);
private:
int mTargetUpdatesPerSecond = TARGET_UPDATE_RATE;
clock::time_point mLastUpdate;
static std::unordered_map<std::string, std::string> mSharedStrings;
};
}

19
include/game/input.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <SDL3/SDL.h>
namespace Game {
class Input {
public:
Input() = delete;
static void update();
static bool isKeyPressed(SDL_Scancode key);
static bool isKeyJustPressed(SDL_Scancode key);
static bool isKeyJustReleased(SDL_Scancode key);
private:
static const bool* mCurrentKeyStates;
static bool* mPreviousKeyStates;
static int mNumKeys;
};
}