76 lines
1.1 KiB
C++
76 lines
1.1 KiB
C++
#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();
|
|
}
|