Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

common.h

00001 #ifndef DEF_COMMON_H 00002 #define DEF_COMMON_H 1 00003 00008 #include <iostream> 00009 #include <fstream> 00010 #include <sstream> 00011 #include <vector> 00012 #include <set> 00013 #include <map> 00014 #include <math.h> 00015 #include <string> 00016 #include <dlfcn.h> 00017 #include <SDL.h> 00018 #include <SDL_mixer.h> 00019 #ifdef SDL_IMAGE 00020 #include <SDL_image.h> 00021 #endif 00022 #include <boost/shared_ptr.hpp> 00023 00024 using namespace std; 00025 00026 class Object; 00027 class Character; 00028 class Player; 00029 class Monster; 00030 class ImageCache; 00031 class SoundCache; 00032 class GraphicsEngine; 00033 class SoundsEngine; 00034 class ObjectsPool; 00035 class Background; 00036 class Scenario; 00037 class InputHandler; 00038 class PhysicHandler; 00039 class Font; 00040 class Event; 00041 class Weapon; 00042 class EmptyAnimation; 00043 class Animation; 00044 class Menu; 00045 class Box; 00046 class Editor; 00047 00048 typedef std::set<Object *>::iterator object_iterator; 00049 typedef std::set<Character *>::iterator character_iterator; 00050 typedef std::set<Player *>::iterator player_iterator; 00051 typedef std::set<Monster *>::iterator monster_iterator; 00052 typedef std::set<Object *>::reverse_iterator object_riterator; 00053 typedef std::set<Character *>::reverse_iterator character_riterator; 00054 typedef boost::shared_ptr<EmptyAnimation> EmptyAnimationPtr; 00055 typedef std::map<string,string> ParameterMap; 00056 00057 //Data 00058 #define DATA_LVLFPS 6 00059 #define DATA_LVLDUR 1000 00060 #define DATA_LVLPLAYER_W 25 00061 #define DATA_LVLPLAYER_H 30 00062 00063 //General definitions 00064 #define NOTHING 0x00000000 00065 #define ALL 0xFFFFFFFF 00066 #define DIR_RIGHT 0x00000001 00067 #define DIR_LEFT 0x00000002 00068 #define DIR_UP 0x00000004 00069 #define DIR_DOWN 0x00000008 00070 #define DIR_ALL 0x0000000F 00071 #define DIR_UPR 0x00000005 00072 #define DIR_UPL 0x00000006 00073 #define DIR_DWR 0x00000009 00074 #define DIR_DWL 0x0000000A 00075 #define DIR_LR 0x00000003 00076 00077 //Game states 00078 #define GAME_PAUSED 0x00000001 00079 #define GAME_PLAY 0x00000002 00080 #define GAME_MENU 0x00000004 00081 #define GAME_EDIT 0x00000008 00082 #define GAME_EDIT_NOANIM 0x00000010 00083 #define GAME_TEXT_INPUT 0x00000020 00084 00085 //Animation types 00086 #define ATYPE_ONCE 0x00000001 00087 #define ATYPE_LOOP 0x00000002 00088 #define ATYPE_SWING 0x00000004 00089 #define ATYPE_STEP 0x00000008 00090 #define ATYPE_ONCE_REV 0x00000010 00091 #define ATYPE_LOOP_REV 0x00000020 00092 #define ATYPE_SWING_REV 0x00000040 00093 #define ATYPE_STEP_REV 0x00000080 00094 #define ATYPE_ALL_ONCE 0x00000011 00095 #define ATYPE_ALL_LOOP 0x00000022 00096 #define ATYPE_ALL_SWING 0x00000044 00097 #define ATYPE_ALL_NORMAL 0x0000000F 00098 #define ATYPE_ALL_REV 0x000000F0 00099 #define ATYPE_ST_SWITCH 0x00000100 00100 #define ATYPE_ONCE_S 0x00000101 00101 #define ATYPE_ONCE_S_REV 0x00000110 00102 00103 //Description formats 00104 #define DESC_NONE 0x00000000 00105 #define DESC_LVLANIM 0x00000001 00106 #define DESC_ANIM_LVLANIM 0x00000002 00107 00108 enum ConfigKey { 00109 KEY_START, 00110 KEY_LEFT, 00111 KEY_RIGHT, 00112 KEY_UP, 00113 KEY_DOWN, 00114 KEY_SP1, 00115 KEY_SP2, 00116 KEY_ACT, 00117 KEY_USE, 00118 KEY_DROP, 00119 KEY_SWITCH, 00120 KEY_PAUSE, 00121 KEY_MENU, 00122 KEY_FPS, 00123 KEY_BAR, 00124 KEY_FULL, 00125 KEY_QUIT, 00126 KEY_NOANIM, 00127 KEY_DEBUG, 00128 KEY_ADD_SEL, 00129 KEY_RM_SEL, 00130 KEY_DEL 00131 }; 00132 00133 enum BasePointType { 00134 BP_LU, 00135 BP_LM, 00136 BP_LD, 00137 BP_MU, 00138 BP_MM, 00139 BP_MD, 00140 BP_RU, 00141 BP_RM, 00142 BP_RD 00143 }; 00144 00145 enum AllignType { 00146 AT_LU, 00147 AT_LM, 00148 AT_LD, 00149 AT_MU, 00150 AT_MM, 00151 AT_MD, 00152 AT_RU, 00153 AT_RM, 00154 AT_RD 00155 }; 00156 00160 struct Hit { 00161 Uint16 enter; 00162 Uint16 touch; 00163 }; 00164 00168 struct Config { 00169 Uint16 width; 00170 Uint16 height; 00171 bool full; 00172 Uint16 audio_format; 00173 int audio_rate; 00174 int audio_channels; 00175 string datadir; 00176 string map; 00177 string scenario; 00178 string anim_file; 00179 SDLKey keybind[30]; 00180 double lvlscale; 00181 bool onlymap; 00182 }; 00183 00187 struct Frame { 00188 Frame(SDL_Surface*,SDL_Rect); 00189 Frame(); 00190 SDL_Surface* image; 00191 //Frame position (Source Rectangle) 00192 SDL_Rect pos; 00193 }; 00194 00198 struct Image { 00199 SDL_Surface* surface; 00200 std::vector<SDL_Rect> description; 00201 }; 00202 00203 //global functions 00205 00206 void startScreen(); 00209 int quitGame(int); 00210 00217 int readConfig(const string& filename); 00219 ParameterMap getFileParameters(const string& filelist); 00221 ParameterMap getParameters(const string& parameterlist, char delim=',', char delimsub='='); 00223 string putParameters(const ParameterMap& parameters, char delim=',', char delimsub='='); 00225 bool hasParam(const ParameterMap& parameters, const string& str); 00228 Uint16 getDirFromString(const string& str); 00229 00231 void parseInput(int argc,char* argv[]); 00233 void usage(); 00235 string itos(int); 00237 int addAbsolute(int,int); 00239 double calcFPS(Uint16 frames, Uint32 duration); 00240 00242 void setGameMode(Uint8); 00244 void addGameMode(Uint8); 00246 void removeGameMode(Uint8); 00248 Menu* setMenu(Menu* newmenu); 00250 Menu* closeMenu(); 00252 void closeMenus(); 00253 00255 00256 //global variables 00258 00259 extern Config config; 00261 extern ImageCache* imgcache; 00263 extern SoundCache* sndcache; 00265 extern GraphicsEngine* gfxeng; 00267 extern SoundsEngine* sfxeng; 00269 extern Scenario* scenario; 00271 extern InputHandler* input; 00273 extern Font* font; 00275 extern Font* font2; 00277 extern Uint8 game_mode; 00279 extern Menu* menu; 00281 extern Editor* editor; 00283 00284 #endif

Generated on Sun Feb 5 13:02:35 2006 for Lost Penguins by doxygen 1.3.8