File: game.h

package info (click to toggle)
trackballs 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 39,908 kB
  • sloc: cpp: 17,058; lisp: 4,626; sh: 23; makefile: 11
file content (108 lines) | stat: -rw-r--r-- 2,709 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* game.h
   Collects information about the current game

   Copyright (C) 2000  Mathias Broxvall

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef GAME_H
#define GAME_H

#define SCORE_PLAYER 0
#define SCORE_BLACK 1
#define SCORE_BABY 2
#define SCORE_BIRD 3
#define SCORE_CACTUS 4
#define SCORE_FLAG 5
#define SCORE_MAX 6

#include <vector>
#include "gameHook.h"
#include "general.h"
#include "glHelp.h"

class AnimatedCollection;
class Map;
class Player;
class Weather;
class EditMode;
class Gamer;

class Game {
 public:
  Game(const char *, Gamer *gamer);
  Game(Map *editmap, const char *levelname);
  virtual ~Game();

  void tick(Real);
  void draw();                               /* Used for normal drawing mode */
  void drawReflection(const Coord3d &focus); /* Used when drawing environmentmaps */
  void doExpensiveComputations();

  void add(GameHook *);
  void queueCall(SCM fun);
  void queueCall(SCM fun, double val);
  void queueCall(SCM fun, GameHook *subject, SCM object);
  void loadLevel(const char *level);
  void clearLevel();

  GLfloat fogColor[4];
  int localPlayers, isNight, startTime, currentLevelSet, useGrid;
  double fogThickness, wantedFogThickness;
  double jumpFactor, oxygenFactor;
  int edit_mode;

  Player *player1;
  Map *map;
  Real gameTime;
  Gamer *gamer;
  Weather *weather;

  static Game *current;
  AnimatedCollection *balls;

  char levelName[256];
  char nextLevel[256];
  char returnLevel[256]; /* When returning from bonus levels */

  /** Records current default settings for score/time when killing
      units and triggering other events */
  static double defaultScores[SCORE_MAX][2];

 protected:
  friend class Ball;
  friend class EditMode;
  std::vector<GameHook *> hooks[Role_MaxTypes];

 private:
  typedef struct {
    SCM fun;
    union {
      double val;
      struct {
        GameHook *subject;
        SCM object;
      };
    };
    int type;
  } QueuedCall;
  std::vector<QueuedCall> queuedCalls;
  std::vector<GameHook *> newHooks;

  void setDefaults();
};

#endif