00001 // $Id: gameBase.cpp,v 1.6 2006/05/24 16:52:39 sean Exp $ 00002 // $Copyright: (c)2001 National Biocomputation Center, Stanford University $ 00003 00004 // 00005 // gameBase.cpp 00006 // 00007 // A base class for defining SPRING games, including common actions 00008 // and interfaces with SPRING to define, initialize, operate, and give 00009 // feedback from a game / scenario. 00010 00011 // The base class has general functions, but does not explicitly include 00012 // the concept of a game "state" 00013 // ?? Should I make basic states: {created, initialized, running, complete} 00014 00015 // History: 00016 // 24-Aug-05 cwc Started this base class. 00017 00018 00019 // Informational: 00020 // A game is implemented by having its functions called from the appropriate 00021 // portions of SPRING: 00022 // instantiate object 00023 // Set up GUI 00024 // Initialization 00025 // 00026 00027 // Note that non-object based individual functions may be included in a games file 00028 // where the interfaces won't accept a C++ member function, e.g. callbacks for some 00029 // GUI toolkits such as GLUT, GLOW, etc. 00030 00031 // The game can be created with knowledge of the global universe object 00032 00033 #include <stdlib.h> 00034 #include <string.h> 00035 00036 #include "gameBase.h" 00037 00038 gameBase::gameBase(springCore* main_app, char* param) 00039 { 00040 myappObject = main_app; 00041 00042 debug = 0; 00043 } 00044 00045 00046 // Desctructor - nothing local in the base class needs to be cleaned up. 00047 gameBase::~gameBase() 00048 { 00049 00050 } 00051 00052 00053 // Set up all the local variables. This may, for instance, read a file of 00054 // data object descriptions. 00055 void gameBase::Initialize() 00056 { 00057 } 00058 00059 // Initialize graphical interfaces elements needed, e.g. popups, menu items, etc. 00060 void gameBase::setupGUI() 00061 { 00062 } 00063 00064 // Called, when keyboard events occur. If 0 is returned, the main SPRING 00065 // application will handle the key event. If 1 is returned, SPRING itself will 00066 // NOT handle the key event. x and y donate the current mouse coordinates when 00067 // the key was pressed. 00068 bool gameBase::handleKeyboard(unsigned char key, int x, int y) 00069 { 00070 // indicates, that the key event was not processed and SPRING itself should handle 00071 // it. 00072 return 0; 00073 } 00074 00075 // Update implements the logic and rules of the game by observing 00076 // changes in the universe, then checks if the state of the game 00077 // has been changed. 00078 // This is called after the sensors and universe have been updated 00079 void gameBase::Update() 00080 { 00081 } 00082 00083 00084 // Draws 2D information over the displayed image. 00085 // Normally used for user feedback and metrics, time information, etc. 00086 // This is called in the springCore's Draw2D function. 00087 void gameBase::Draw2D() 00088 { 00089 } 00090 00091 00092 // Draws 3D information over the image, if desired. 00093 // 3-D graphical enhancements may be desirable in some game scenarios. 00094 // This is called in DisplayOnce, *after* all the other items have been drawn. 00095 // This allows it to appear in whatever views Display needs, including stereo. 00096 void gameBase::Draw3D() 00097 { 00098 }
1.5.3