1 /***************************************************************************
2   alienBlaster
3   Copyright (C) 2004
4   Paul Grathwohl, Arne Hormann, Daniel Kuehn, Soenke Schwardt
5 
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10 
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15 
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ***************************************************************************/
20 #ifndef RACER_H
21 #define RACER_H
22 
23 #include <vector>
24 #include "SDL.h"
25 #include "settings.h"
26 
27 class Racer;
28 class Shots;
29 class Items;
30 class Enemys;
31 class Explosions;
32 
33 /* A class, that manages the individual racers.
34    It is used for everything, that the racers are capable of doing.
35  */
36 class Racers {
37   vector<Racer *> racers;
38 
39   // points reached by racer 0 in arcade mode
40   int pointsInArcadeMode;
41 
42   void collideWithEnemys();
43 
44   PlayerKeys playerKeys0;
45   PlayerKeys playerKeys1;
46 
47   public:
48 
49   Racers();
50   ~Racers();
51 
52   bool isShipTypeActive( int shipType );
53 
54   void addRacer( Racer *racer );
55   void deleteRacers();
56   Racer *getRacer(unsigned int i);
getNrRacers()57   unsigned int getNrRacers() { return racers.size(); }
58 
59   // Moves the racers. Calculates collisions between the racers and
60   // collisions between a racer and enemies.
61   void moveAndCollide( int dT );
62 
63   // Checks if a racer has picked up an item by flying over it.
64   void pickUpItems();
65   // Checks if a racer was at his pitstop and is being repaired.
66   //  void repair( PitStops *pitStops );
67   // Lets the racers shoot, if they want to.
68   void shoot();
69   // recharge the shields
70   void rechargeShield( int dT );
71   // draws the racers.
72   void drawRacers( SDL_Surface *screen );
73   void drawShadows( SDL_Surface *screen );
74   void drawStats( SDL_Surface *screen );
75 
76   // returns, which racer has shot more enemys
77   //int getWinner();
78 
79   void expireRacers();
80 
81   bool bothPlayersLost();
82 
83   void receivePointsArcade( float amount );
84   int getPointsArcadeMode();
85 
86   void getKeyActionMaps();
87   void handleEvent( const SDLKey key, const bool pressed );
88   private:
89   void handlePlayerEvent( PlayerEvent pEvent, int playerNr, bool keyDown );
90 };
91 
92 #endif
93