/Users/craigcornelius/Projects/SPRING Mac Release 0.2/gameBase.h

Go to the documentation of this file.
00001 // $Id: gameBase.h,v 1.6 2006/05/24 16:52:41 sean Exp $ 
00002 // $Copyright: (c)2001 National Biocomputation Center, Stanford University $
00003 
00004 #ifndef GAMEBASE_H
00005 #define GAMEBASE_H
00006 
00007 // Abstract definition of a game in Spring. Used to guide
00008 // users and collect data during testing. Extend Game to
00009 // define your own experiments.
00010 //
00011 // Based on game.h, created by Chris (caschwan@gmx.net)
00012 //
00013 // Author: Craig Cornelius (cwcornelius@stanford.edu)
00014 // 
00015 // History:
00016 //      09-aug-2005     cwc             Created this file
00017 //      30-aug-2005     cwc             Updated based on Chris's suggestions.
00018 //
00019 // A game is implemented by having its functions called from the appropriate
00020 // portions of SPRING:
00021 //              instantiate object
00022 //              Set up GUI
00023 //              Initialization
00024 //              
00025 
00026 // Note that non-object based individual functions may be included in a games file
00027 // where the interfaces won't accept a C++ member function, e.g. callbacks for some
00028 // GUI toolkits such as GLUT, GLOW, etc.
00029 
00030 
00031 // Refers to these classes below, but shouldn't include the .h files.
00032 class springCore;
00033 
00034 class gameBase {
00035 protected:
00036         springCore* myappObject;
00037 
00038 public: 
00039     int debug;    static const char* rcsid;
00040 
00041 public:
00042         // The game can be created with knowledge of the application object.    
00043         // NULL is allowed, but doesn't make much sense.
00044     gameBase(springCore* main_app, char* params = 0);
00045     virtual ~gameBase();        
00046 
00047         // Returns pointer to the name assigned to this game.
00048         // This function must be provided by any derived class.
00049         virtual char* getName() = 0;
00050 
00051         // Set up all the local variables.  This may, for instance, read a file of      
00052         // data object descriptions.
00053         virtual void Initialize();      
00054         // Initialize graphical interfaces elements needed, e.g. popups, menu items, etc.       
00055         virtual void setupGUI();
00056 
00057         // Called, when keyboard events occur. If 0 is returned, the main SPRING 
00058         // application will handle the key event. If 1 is returned, SPRING itself will
00059         // NOT handle the key event. x and y donate the current mouse coordinates when
00060         // the key was pressed.
00061         virtual bool handleKeyboard(unsigned char key, int x, int y);
00062 
00063         // Update implements the logic and rules of the game by observing 
00064         // changes in the universe, then checks if the state of the game
00065         // has been changed.
00066         // This is called after the sensors and universe have been updated
00067         //  Inherited from Game class
00068         virtual void Update();
00069 
00070         // Draws 2D information over the displayed image.
00071         // Normally used for user feedback and metrics, time information, etc.
00072         // This is called in the springCore's Draw2D function.
00073         virtual void Draw2D();          
00074         // called when in Draw2D
00075         
00076         // Draws 3D information over the image, if desired.
00077         // 3-D graphical enhancements may be desirable in some game scenarios.
00078         // This is called in DisplayOnce, *after* all the other items have been drawn.
00079         // This allows it to appear in stereo.
00080         virtual void Draw3D();
00081 };
00082 
00083 #endif   // GAMEBASE_H

Generated on Thu Aug 30 11:03:13 2007 for SPRING Mac by  doxygen 1.5.3