Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csrpg.h

00001 #ifndef _CSRPG_H_
00002 #define _CSRPG_H_
00003 
00004 /*
00005  *      CSRPG.h
00006  *      Main header file for the 2004 Computer Science AP project
00007  *      by Mike Stedman, Corey Baker, and Geoff Jackson.
00008  *
00009  *      This header file implements the basic "overlord" classes that
00010  *      will make up the game engine. Look in CSRPG.cpp for the particular
00011  *      implementation of such.
00012  */
00013 
00014 // Graphic Settings -- Perhaps an enterprising young soul
00015 //                      can make me a config file loader...
00016 #define RES_X 640
00017 #define RES_Y 480 // for "fight" backgrounds
00018 #define IS_FULLSCREEN 0
00019 #define CUTOFF_DISTANCE 8 // how far away from the player you draw tiles
00020 #define SLOW_PC 0 // turns off backgrounds and such for 386's
00021 #define INPUT_DELAY 0 // for performance testing, or if you have a 386, then set this to 0
00022 
00023 #define CHEATER_MODE 1 // use the 'g' and 'k' keys to trade gold for keys and keys for gold
00024                                            // (respectively)
00025 
00026 /*
00027         Current best performance with test first level, mp3 decoding in background, fullscreen,
00028         June 1st 2004:
00029                 - DEBUG MODE: 40.26 FPS
00030                 - RELEASE MODE: 42 FPS (Damn right!)
00031 
00032                 Looks like the memory leak I cleared up did more than just fix our nasty nasty memory
00033                 leaks :)
00034 */
00035 
00036 // Defines for sprite directions -- this is the number the
00037 //                                  game uses internally for each direction
00038 //                                  sprites can have
00039 #define FACING_UP 0
00040 #define FACING_LEFT 1
00041 #define FACING_DOWN 2
00042 #define FACING_RIGHT 3
00043 
00044 // Includes -- SDL (libsdl.org)
00045 #include "SDL.h"
00046 #include "SDL_image.h"
00047 #include "SDL_mixer.h"
00048 #include "SDL_ttf.h"
00049 
00050 // Includes -- STL and ANSI C
00051 #include <math.h>
00052 #include <cstdlib>
00053 #include <list>
00054 #include <cstdio>
00055 
00056 // Includes -- Our .h files
00057 #include "npc.h"                // implements the NPC class
00058 #include "HUDController.h"      // implements HUDController class
00059 #include "Player.h"             // implements Player class
00060 #include "Map.h"                // implements Map class
00061 #include "SpecialTiles.h"       // defines for special tiles
00062 #include "Shops.h"
00063 
00064 // More defines -- graphics-based
00065 #define MAX_TILES 8
00066 #define MAX_SPRITES 10
00067 #define MAX_ITEMS 9 // WHY DO YOU NOT WORK???#$?@
00068 
00069 // Gameplay
00070 #define MAX_FLOORS 5
00071 
00072 // Misc.
00073 #define IS_TRIPPY 0 // randomly shifts some colours
00074 
00075 using namespace std;
00076 
00078 
00086 class CGame {
00087         public:
00089                 void titleScreen(); 
00091                 void gameLoop(); 
00093                 CGame();
00095                 ~CGame();
00096         private:
00097                 // variables
00098                 SDL_Surface *screen; // this holds the window we'll render to
00099                 SDL_Event event; // this is used for input management
00100                 Map theMap;     // this holds our stuff. look in Map.h for more
00101                 //int currentfloor;
00102         
00103                 // Generic variables
00104                 bool bIsDone; // is the game over?
00105         
00106                 // Game mode variables and functions
00107                 bool bIsFighting; // are we in the fight engine?
00108                 bool bPlayerTurn; // is the player ready to pick a menu option?
00110                 void RoamLoop();  
00112                 void FightLoop(); 
00114                 void prepareFight(NPC *enemy); 
00116                 void solvedQuestScreen();
00118                 void ConsoleLoop();     
00119                 /* Generic functions */
00121                 void Roam_DrawEverything(); 
00123                         void paintTiles(); 
00125                         void drawSprite(int c, int r, SDL_Rect *temprect);
00127                         void Roam_CheckNPCConvo(int x, int y);
00129                 void Roam_GetInput();           
00130                 //void Fight_GetInput();                // get input on menus
00132                 void loadNPCs(char *filename); 
00134                 void spawnMrQuesty(); 
00136                 void clearNPCs();
00138                 /** if it is a door, and you have a key, it's opened and a key is taken away. if you don't have any keys, it does nothing */
00139                 void detectAndOpenDoors(int x, int y); 
00141                 void shopKeeping();
00142 
00143                 // HUD repair functions
00145                 void HUD_Player();
00147                 void HUD_Enemy(NPC* plyr);
00149                 void displayQuestCompletion();
00151                 void drawItemsPotionsKeys();
00153                 void Fight_magicMenu();
00155                 void characterMenu();
00156 
00157                 // Conversation repair functions
00159                 Quest* initiateConversation(NPC *plyr,int map);
00161                 void displayFightConsoleMessage(char *str, bool bIsBad);
00163                 void printItemInfo(string name, int cost);
00165                 void printYourMoney(int money); // for shops
00166 
00167         
00168                 // Scene graph, NPC lists.
00169                 list <NPC*> characters;         // holds all NPC's
00170                 Player you;                     // hooray, you're useful!
00171                 QuestMaster *qm; // holds all of our quests
00172                 NPC* targetNPC; // the NPC you are currently fighting with!!!!
00173                 int fightBackground; // the tile you are on will be saved and used in a fight
00174                 Shop NormalShop;
00175                 TTF_Font *font;
00176                 int menuchoice;
00177 
00178                 //int MaxItems;
00179                 
00180                 // Textures
00181                 SDL_Surface *tiles[MAX_TILES];
00182                 SDL_Surface *chargfx[MAX_SPRITES][4]; // the subscript is what direction they are facing
00183                 SDL_Surface *icons[5];
00184                 SDL_Surface *fightBackgrounds[2]; // for inside or outside
00185                 SDL_Surface *clouds; // background
00186                 SDL_Surface *portrait; // our player's portrait, 128x something
00187                 vector <SDL_Surface*> items;
00188         
00189                 // Utility/Miscellaneous functions
00191                 int tileCollision(int x, int y); 
00192                         // returns 1 if there is an impassable tile at that location
00194                 int spriteCollision(int x, int y); 
00195                         // returns 1 if there is a character on that tile
00196 
00197 
00199 
00200                 void loadSurfaces();
00202                 void initFonts();
00203 };
00204 
00205 #endif

Generated on Thu Jun 3 16:21:28 2004 by doxygen1.2.15