Back to index

extremetuxracer  0.5beta
splash_screen.cpp
Go to the documentation of this file.
00001 /* 
00002  * ETRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * Copyright (C) 1999-2001 Jasmin F. Patry
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 #include "splash_screen.h"
00023 
00024 #include "gl_util.h"
00025 #include "textures.h"
00026 
00027 #include "ppgltk/audio/audio.h"
00028 #include "ppgltk/alg/glhelper.h"
00029  
00030 SplashScreen::SplashScreen()
00031 {             
00032        pp::Vec2d pos(getparam_x_resolution()/2, 100); //Coordinates are from bottom-left corner of the screen
00033        
00034        mp_anykeyLbl = new pp::Label(pos,"event_and_cup_label",_("PRESS ANY KEY TO START"));
00035 
00036        mp_anykeyLbl->alignment.center();  //use the horizontal center of the text as the placement point
00037        mp_anykeyLbl->alignment.top(); //use the top of the text as the placement point
00038        
00039   play_music( "splash_screen" );
00040 }
00041 
00042 SplashScreen::~SplashScreen()
00043 {
00044        // there is no need to keep the logo in memory
00045        if(getparam_y_resolution()>800) {
00046               unbind_texture( "splash_screen" );
00047        } else {
00048               unbind_texture( "splash_screen" );
00049        }
00050        flush_textures();
00051        
00052        delete mp_anykeyLbl;
00053 }
00054 
00055 void
00056 SplashScreen::loop(float timeStep)
00057 {
00058        update_audio();
00059 
00060   clear_rendering_context();
00061   set_gl_options( GUI );
00062   UIMgr.setupDisplay();
00063 
00064        drawSnow(timeStep);
00065 
00066        {//should this be created in the splash screen constructor?
00067               
00068               if(getparam_y_resolution()>760) {
00069                      pp::Vec2d pos(getparam_x_resolution()/2 - 256, getparam_y_resolution()/2 - 256); //centered
00070                      pp::Vec2d size(512, 512);
00071                      ppGL::draw::rect("splash_screen", pos, size);
00072               } else {
00073                      pp::Vec2d pos(getparam_x_resolution()/2 - 256, getparam_y_resolution()/2 - 256/2); //centered
00074                      pp::Vec2d size(512, 256);
00075                      ppGL::draw::rect("splash_screen_small", pos, size);
00076               }
00077        }      
00078 
00079   UIMgr.draw();
00080 
00081   reshape( getparam_x_resolution(), getparam_y_resolution() );
00082   winsys_swap_buffers();    
00083 }
00084 
00085 
00086 bool
00087 SplashScreen::mouseButtonReleaseEvent(int button, int x, int y)
00088 {
00089        set_game_mode( GAME_TYPE_SELECT );
00090        winsys_post_redisplay();
00091        return true;
00092 }
00093 
00094 bool
00095 SplashScreen::keyReleaseEvent(SDLKey key)
00096 {
00097        set_game_mode( GAME_TYPE_SELECT );
00098        winsys_post_redisplay();
00099        return true;
00100 }