primer commit

This commit is contained in:
2025-04-07 11:01:28 +02:00
parent 9f0fa99694
commit 149a8216bc
26 changed files with 18311 additions and 1 deletions

75
source/main.cpp Normal file
View File

@@ -0,0 +1,75 @@
#include <SDL3/SDL.h>
#include <memory>
#include "screen.h"
#include "mouse.h"
#include "surface.h"
#include "s_sprite.h"
bool running = true;
Uint64 ticks = 0;
std::shared_ptr<Surface> logo_surface = nullptr;
std::unique_ptr<SSprite> logo_sprite = nullptr;
void init()
{
Screen::get()->init();
logo_surface = std::make_shared<Surface>("jailgames.gif");
logo_sprite = std::make_unique<SSprite>(logo_surface);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Logo start");
}
void close()
{
Screen::get()->destroy();
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nBye!");
SDL_Quit();
}
void checkEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_EVENT_QUIT:
running = false;
return;
}
Mouse::handleEvent(event);
}
}
void update()
{
if (SDL_GetTicks() - ticks > options.game.speed)
{
ticks = SDL_GetTicks();
}
}
void render()
{
Screen::get()->start();
logo_sprite->render();
Screen::get()->render();
}
int main()
{
init();
while (running)
{
update();
checkEvents();
render();
}
close();
}