migrat a SDL3 Callback API (SDL_AppInit/Iterate/Event/Quit) (milestone 3)
- main.cpp reescrit amb SDL_MAIN_USE_CALLBACKS - Director convertit a màquina d'estats amb iterate() i handleEvent() - Seccions (Logo, Intro, Title, Game) amb iterate() i handleEvent() - Events SDL enrutats via SDL_AppEvent → Director → secció activa - Eliminat SDL_PollEvent de iterate(), events via handleEvent() - Transicions entre seccions gestionades per handleSectionTransition() - Instructions i Game (demo) delegats frame a frame des de Title Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,15 +39,26 @@ Reescribiendo el código el 27/09/2022
|
||||
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
#include "director.h"
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// Crea el objeto Director
|
||||
auto director = std::make_unique<Director>(argc, const_cast<const char **>(argv));
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {
|
||||
auto *director = new Director(argc, const_cast<const char **>(argv));
|
||||
*appstate = director;
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
return director->run();
|
||||
}
|
||||
SDL_AppResult SDL_AppIterate(void *appstate) {
|
||||
return static_cast<Director *>(appstate)->iterate();
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
||||
return static_cast<Director *>(appstate)->handleEvent(event);
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void *appstate, SDL_AppResult result) {
|
||||
delete static_cast<Director *>(appstate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user