#include "logo.h" #include "screen.h" #include "mouse.h" #include "surface.h" #include "s_sprite.h" #include "global_inputs.h" Logo::Logo() { init(); } Logo::~Logo() { close(); } void Logo::init() { SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); SDL_SetLogPriority(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR); Screen::get()->init(); logo_surface = std::make_shared("jailgames.gif"); logo_surface->scale(5); logo_sprite = std::make_unique(logo_surface); logo_sprite->setPosition( (options.logo.width - logo_sprite->getWidth()) / 2, (options.logo.height - logo_sprite->getHeight()) / 2); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Logo start"); } void Logo::close() { Screen::get()->destroy(); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nBye!"); SDL_Quit(); } void Logo::checkEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_EVENT_QUIT: options.logo.running = false; return; } globalInputs::check(event); Mouse::handleEvent(event); } } void Logo::update() { if (SDL_GetTicks() - ticks > options.logo.speed) { ticks = SDL_GetTicks(); Screen::get()->update(); } } void Logo::render() { Screen::get()->start(); logo_sprite->render(); Screen::get()->render(); } int Logo::run() { while (options.logo.running) { update(); checkEvents(); render(); } return 0; }