Back to index

extremetuxracer  0.5beta
loop.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
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 #ifndef _LOOP_H_
00023 #define _LOOP_H_
00024 
00025 #include "SDL.h"
00026 #include "translation.h"
00027 
00028 // we include this here because this headers
00029 // are used in nearly all modes
00030 #include "pp_types.h"
00031 #include "gl_util.h"
00032 #include "ppgltk/ui_mgr.h"
00033 #include "ppgltk/ui_theme.h"
00034 #include "render_util.h"
00035 #include "game_config.h"
00036 
00037 
00039 typedef enum {
00040     ALL_MODES = -2,
00041     NO_MODE = -1,
00042     SPLASH = 0,
00043     GAME_TYPE_SELECT,
00044     EVENT_SELECT,
00045        EVENT_RACE_SELECT,
00046     RACE_SELECT,
00047     LOADING,
00048     INTRO,
00049     RACING,
00050     GAME_OVER,
00051     PAUSED,
00052     RESET,
00053     CREDITS,
00054     CREDITS_TRANS,
00055        CONFIGURATION,
00056        CONFIG_GRAPHICS,
00057        CONFIG_VIDEO,
00058        CONFIG_AUDIO,
00059        CONFIG_KEYBOARD,
00060        CONFIG_JOYSTICK,
00061        QUIT,
00062        BENCHMARK,
00063     NUM_GAME_MODES,
00064     HIGHSCORE
00065 } game_mode_t;
00066 
00067 void set_game_mode( game_mode_t mode );
00068 void main_loop();
00069 bool is_mode_change_pending();
00070 
00071 void loop_mouse_func (int button, int state, int x, int y);
00072 void loop_mouse_motion_func( int x, int y );
00073 void loop_keyboard_func(SDLKey key, SDLMod mod, bool release, int x, int y);
00074 
00075 
00076 
00077 class GameMode
00078 {
00079 
00080 protected:
00082        void drawSnow( float timeStep, bool windy = false );
00083        
00084 public:
00085        GameMode();
00086        virtual ~GameMode(){}; 
00087        virtual void loop(float timeStep) = 0;
00088        
00089               
00090        virtual bool keyboardEvent(SDLKey key, bool release){return false;};
00091        virtual bool keyPressEvent(SDLKey key){return false;};
00092        virtual bool keyReleaseEvent(SDLKey key){return false;};
00093        
00094        virtual bool mouseButtonEvent(int button, int x, int y, bool pressed){return false;};
00095        virtual bool mouseButtonPressEvent(int button, int x, int y){return false;};
00096        virtual bool mouseButtonReleaseEvent(int button, int x, int y){return false;};
00097        
00098        static GameMode* currentMode;
00099        static game_mode_t mode;
00100        static game_mode_t prevmode;
00101 };
00102 
00103 #endif // _LOOP_H_