fixed windows build

This commit is contained in:
Sarah Faey 2025-05-07 17:59:50 +02:00
parent 794fa5bba0
commit 5aff6f6326
13 changed files with 33 additions and 27 deletions

View file

@ -17,14 +17,17 @@
Game::Game(SDL_Window *window, SDL_Renderer *renderer)
: m_Window(window, SDL_DestroyWindow),
m_Renderer(renderer, SDL_DestroyRenderer),
m_Gamepad1(nullptr, SDL_CloseGamepad)
m_Gamepad1(nullptr, SDL_CloseGamepad),
m_TickCount(0),
m_Player1DirectionInput({ 0,0 }),
m_Player2DirectionInput({ 0,0 })
{
SDL_FRect player1Hitbox;
player1Hitbox.x = 0;
player1Hitbox.y = 0;
player1Hitbox.w = 20;
player1Hitbox.h = 20;
m_Player1 = ActorFactory::CreateMovingActor(player1Hitbox);
m_Player1 = ActorFactory::CreateMovingActor(Vector2D(0,0), player1Hitbox, player1Hitbox);
//TODO: read keybinds from config if it exists. otherwise initialze standard and write file
m_KeyboardCommandMap.emplace(SDL_SCANCODE_ESCAPE, new EndGameCommand(this));
@ -46,7 +49,7 @@ void Game::Run()
float deltaTime = (SDL_GetTicks() - m_TickCount) / 1000.0f;
uint64_t ticks = SDL_GetTicks() - m_TickCount;
ticks = ticks > 0 ? ticks : 1;
int fps = 1000/(ticks);
long fps = 1000/(ticks);
m_TickCount = SDL_GetTicks();
HandleMovement();
m_Player1->Update(deltaTime);
@ -56,7 +59,7 @@ void Game::Run()
SDL_SetRenderDrawColor(m_Renderer.get(), 255, 255, 255, 255);
SDL_RenderDebugTextFormat(m_Renderer.get(), 10, 440, "%" SDL_PRIu64 " fps", fps);
SDL_RenderDebugTextFormat(m_Renderer.get(), 10, 440, "%" SDL_PRIu32 " fps", fps);
SDL_SetRenderDrawColor(m_Renderer.get(), 150, 0, 150, 255);
SDL_FRect player = m_Player1->GetMovementHitbox();
SDL_RenderFillRect(m_Renderer.get(), &player);