X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftitle.c;h=0c66575a97a38f184a643e10d0b0925dc2d7249e;hb=2f395aba3974db45f45a8587ed423a3abeab4cd5;hp=831a2d95fed4adbd40bd3f94b7bdbe3ca8e36803;hpb=de11b13419f0f5ab58bbdbbfe7d4d1769696ab9a;p=supertux.git diff --git a/src/title.c b/src/title.c index 831a2d95f..0c66575a9 100644 --- a/src/title.c +++ b/src/title.c @@ -7,7 +7,7 @@ bill@newbreedsoftware.com http://www.newbreedsoftware.com/supertux/ - April 11, 2000 - April 12, 2000 + April 11, 2000 - December 29, 2003 */ #include @@ -18,10 +18,6 @@ #include #include -#ifndef NOSOUND -#include -#endif - #ifdef LINUX #include #include @@ -32,117 +28,151 @@ #include "globals.h" #include "title.h" #include "screen.h" +#include "high_scores.h" +#include "menu.h" +#include "type.h" /* --- TITLE SCREEN --- */ int title(void) { - SDL_Surface * title, * anim1, * anim2; + texture_type title, anim1, anim2; SDL_Event event; SDLKey key; - int done, quit, frame, pict; - - - /* Clear screen: */ - + int done, quit, frame, pict, last_highscore; + char str[80]; + + game_started = 0; + level_editor_started = 0; + + /* Init menu variables */ + initmenu(); + clearscreen(0, 0, 0); updatescreen(); - - + /* Load images: */ - - title = load_image(DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA); - anim1 = load_image(DATA_PREFIX "/images/title/title-anim2.png", - IGNORE_ALPHA); - anim2 = load_image(DATA_PREFIX "/images/title/title-anim1.png", - IGNORE_ALPHA); - - - /* Draw the title background: */ - - drawimage(title, 0, 0, UPDATE); - - + + texture_load(&title,DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA); + texture_load(&anim1,DATA_PREFIX "/images/title/title-anim2.png", IGNORE_ALPHA); + texture_load(&anim2,DATA_PREFIX "/images/title/title-anim1.png", IGNORE_ALPHA); + + /* --- Main title loop: --- */ - + done = 0; quit = 0; - + show_menu = 1; + frame = 0; - - do + + + /* Draw the title background: */ + texture_draw(&title, 0, 0, NO_UPDATE); + + + /* Draw the high score: */ + last_highscore = load_hs(); + sprintf(str, "High score: %d", last_highscore); + drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1); + + while (!done && !quit) { - frame++; - + frame++; + + /* Handle events: */ - + while (SDL_PollEvent(&event)) - { - if (event.type == SDL_QUIT) - { - /* Quit event - quit: */ - - quit = 1; - } - else if (event.type == SDL_KEYDOWN) - { - /* Keypress... */ - - key = event.key.keysym.sym; - - if (key == SDLK_ESCAPE) - { - /* Escape: Quit: */ - - quit = 1; - } - else if (key == SDLK_SPACE || key == SDLK_RETURN) - { - /* Space / Return: Continue: */ - - done = 1; - } - } + { + if (event.type == SDL_QUIT) + { + /* Quit event - quit: */ + quit = 1; + } + else if (event.type == SDL_KEYDOWN) + { + /* Keypress... */ + + key = event.key.keysym.sym; + + /* Check for menu events */ + menu_event(key); + + if (key == SDLK_ESCAPE) + { + /* Escape: Quit: */ + + quit = 1; + } + } #ifdef JOY_YES - else if (event.type == SDL_JOYBUTTONDOWN) - { - /* Joystick button: Continue: */ - - done = 1; - } + else if (event.type == SDL_JOYAXISMOTION) + { + if (event.jaxis.value > 256) + menuaction = MN_DOWN; + else + menuaction = MN_UP; + } + else if (event.type == SDL_JOYBUTTONDOWN) + { + /* Joystick button: Continue: */ + + menuaction = MN_HIT; + } + #endif - } - - + + } + + if(use_gl || menu_change) + { + /* Draw the title background: */ + + texture_draw_bg(&title, NO_UPDATE); + + /* Draw the high score: */ + sprintf(str, "High score: %d", last_highscore); + drawcenteredtext(str, 460, letters_red, NO_UPDATE, 1); + } + + /* Don't draw menu, if quit is true */ + if(show_menu && !quit) + quit = drawmenu(); + + if(game_started || level_editor_started) + done = 1; + /* Animate title screen: */ - + pict = (frame / 5) % 3; - + if (pict == 0) - drawpart(title, 560, 270, 80, 75, UPDATE); + texture_draw_part(&title, 560, 270, 80, 75, NO_UPDATE); else if (pict == 1) - drawimage(anim1, 560, 270, UPDATE); + texture_draw(&anim1, 560, 270, NO_UPDATE); else if (pict == 2) - drawimage(anim2, 560, 270, UPDATE); - - + texture_draw(&anim2, 560, 270, NO_UPDATE); + + flipscreen(); + /* Pause: */ - + SDL_Delay(50); + } - while (!done && !quit); - - + + /* Free surfaces: */ - - SDL_FreeSurface(title); - SDL_FreeSurface(anim1); - SDL_FreeSurface(anim2); - - + + texture_free(&title); + texture_free(&anim1); + texture_free(&anim2); + + /* Return to main! */ - + return(quit); }