- [NEW] Consola in-game

This commit is contained in:
2024-07-03 11:38:39 +02:00
parent 06d58b090d
commit c7186119c2
7 changed files with 371 additions and 99 deletions

View File

@@ -7,6 +7,7 @@ namespace game
{
static int param_count = 0;
static char **params = nullptr;
static bool should_exit = false;
static unsigned int ticks_per_frame = 1000/60;
@@ -15,6 +16,11 @@ namespace game
ticks_per_frame = ticks;
}
void exit()
{
should_exit = true;
}
const char* getParams(const int index)
{
if (index<param_count) return params[index];
@@ -32,13 +38,12 @@ int main(int argc, char *argv[])
static unsigned int current_ticks = SDL_GetTicks();
bool should_exit=false;
SDL_Event e;
while (!should_exit)
while (!game::should_exit)
{
while(SDL_PollEvent(&e))
{
if (e.type==SDL_QUIT) { should_exit = true; break; }
if (e.type==SDL_QUIT) { game::should_exit = true; break; }
if (e.type==SDL_KEYDOWN)
{
input::updateKey(e.key.keysym.scancode);
@@ -59,7 +64,7 @@ int main(int argc, char *argv[])
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)
{
if (!game::loop()) should_exit = true;
if (!game::loop()) game::should_exit = true;
input::updateKey(SDL_SCANCODE_UNKNOWN);
input::updateKeypressed(SDL_SCANCODE_UNKNOWN);
input::updateClk(0);