ja pinta el logo en tamany 1:1
moguda la logica del main a la classe Logo
This commit is contained in:
78
source/logo.cpp
Normal file
78
source/logo.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "logo.h"
|
||||
|
||||
#include "screen.h"
|
||||
#include "mouse.h"
|
||||
#include "surface.h"
|
||||
#include "s_sprite.h"
|
||||
|
||||
Logo::Logo()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Logo::~Logo()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void Logo::init()
|
||||
{
|
||||
Screen::get()->init();
|
||||
logo_surface = std::make_shared<Surface>("jailgames.gif");
|
||||
logo_sprite = std::make_unique<SSprite>(logo_surface);
|
||||
logo_sprite->setPosition(
|
||||
(options.game.width - logo_sprite->getWidth()) / 2,
|
||||
(options.game.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:
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Mouse::handleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Logo::update()
|
||||
{
|
||||
if (SDL_GetTicks() - ticks > options.game.speed)
|
||||
{
|
||||
ticks = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
void Logo::render()
|
||||
{
|
||||
Screen::get()->start();
|
||||
logo_sprite->render();
|
||||
Screen::get()->render();
|
||||
}
|
||||
|
||||
int Logo::run()
|
||||
{
|
||||
while (running)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user