GameState.h

Go to the documentation of this file.
00001 /* -*- Mode: CC; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * GameState.h
00009  * MetalWarriors
00010  * $Revision: 1.32 $
00011  *
00012  * Created by Daniel Aarno on Fri Oct 17 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029  
00030 #include "State.h"
00031 
00032 #include <string>
00034 
00035 #define INIT_URI_MAX 1000000l
00036 
00037 typedef struct
00038 {
00039      unsigned short esc;
00040      unsigned short toggleCamera;  
00041      unsigned short accelerate;
00042      unsigned short slowDown;
00043      unsigned short turnLeft;
00044      unsigned short turnRight;
00045      unsigned short powerInc;
00046      unsigned short powerDec;
00047      unsigned short fiInc;
00048      unsigned short fiDec;
00049      unsigned short thetaInc;
00050      unsigned short thetaDec;
00051      unsigned short fire;
00052      unsigned short endTurn;
00053      unsigned short cycleMap;
00054      unsigned short zoomInMap;
00055      unsigned short zoomOutMap;
00056      unsigned short fsToggle;
00057      
00058      //Group controls
00059      unsigned short grp_x1;
00060      unsigned short grp_x2;
00061      unsigned short grp_x3;
00062      unsigned short grp_x4;
00063      unsigned short grp_x5;
00064      unsigned short grp_x6;
00065      unsigned short grp_x7;
00066      unsigned short grp_x8;
00067      unsigned short grp_x9;
00068      unsigned short grp_x0;
00069      unsigned short leaveGrp;
00070      
00071      //View controls
00072      unsigned short panRight;
00073      unsigned short panLeft;
00074      unsigned short aimMode;     
00075 } KeyBindings;
00076 
00080 class GameState : public State
00081 {
00083   friend class State;
00084 
00085 public:
00087      static GameState* currentGame;
00089      static KeyBindings kb;
00090      
00091 protected:
00092      typedef void (GameState::*DoKeyFunc_t) (int, int, int, bool, bool, unsigned int);
00093 
00095      static int initState;
00096      static long lastUpdate;
00097      int buttonsDown;
00098      float lastMouseX, lastMouseY;
00099      bool cameraLock;
00100      float turnStart;
00101      float turnTime_ms;
00102      bool turnActive;
00103      std::string mission;
00104      DoKeyFunc_t doKeyFunc;
00105      
00106 public:
00107      GameState(StateID state, std::string m);
00108      ~GameState();
00109 
00110      virtual void paint();
00111      virtual void doKey(int key, int x, int y, bool special, 
00112                         bool down, unsigned int modifiers);     
00113      virtual void keyRelease(int key, int x, int y, bool special, unsigned int modifiers);
00114      virtual void doMouseDown(Interface::MouseButtonType button, int x, int y);
00115      virtual void doMouseUp(Interface::MouseButtonType button, int x, int y);
00116      virtual void doMouseDragged(int x, int y);
00117      virtual bool isActive();
00118      
00119      void setupKeyBindings();
00120 
00121      void doKey_InGame(int key, int x, int y, bool special, 
00122                        bool down, unsigned int modifiers);
00123      void doKey_GameOver(int key, int x, int y, bool special, 
00124                          bool down, unsigned int modifiers);
00125  protected:
00131      static void LoadMissionIncremental();
00132      static void Update(int value);
00133      static void GenerateTrees(short nmemb, float minRadius, float maxRadius);
00134      static void GenerateStones(short nmemb, float radius);
00135      static void Start();
00136      static void StartGameOver();
00137      static void GameOverPaint();
00138 
00139      void setupProjectionMatrix();
00140      void setupOrthoMatrix();
00141      void endTurn();
00142      
00143 };

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7