ja pinta el logo en tamany 1:1
moguda la logica del main a la classe Logo
This commit is contained in:
@@ -1,75 +1,12 @@
|
||||
#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();
|
||||
}
|
||||
#include "logo.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
init();
|
||||
// Crea el objeto Logo
|
||||
auto logo = std::make_unique<Logo>();
|
||||
|
||||
while (running)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
}
|
||||
|
||||
close();
|
||||
// Bucle principal
|
||||
return logo->run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user