Tinman  1.0
race.h
Go to the documentation of this file.
1 // -*- coding:utf-8; tab-width:4; mode:cpp -*-
2 // Copyright (C) 2014 ISAAC LACOBA MOLINA
3 // Tinman author: Isaac Lacoba Molina
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef RACE_H
19 #define RACE_H
20 #include <memory>
21 #include <utility>
22 
23 #include "player.h"
24 #include "timer.h"
25 #include "powerup.h"
26 
27 class Game;
28 
29 class Race {
30  std::shared_ptr<Game> game_;
31 
34  std::vector<Player::shared> players_;
36  std::vector<std::string> player_nicks_;
37 
38  public:
39  typedef std::shared_ptr<Race> shared;
40 
41  std::vector<btVector3> starting_grid_;
42 
44 
45  Race(std::string data_file);
46  virtual ~Race();
47 
48  void update(float delta);
49 
50  void realize(std::shared_ptr<Game> game, std::vector<Player::shared> players);
51 
52  void add_collision_hooks();
53 
54  void config_race();
55  void start();
56  void pause();
57  void reset();
58 
59  void next(std::string data_file);
60 
61  void add(std::vector<Player::shared> players);
62  bool has_ended();
63 
64  Section get_section(int index);
65 
66  private:
67  void create_powerups(void);
68 
69  void configure_grid();
70  void update_players(float delta);
71  bool end(std::vector<Car::shared> cars);
72  Player::shared get_player(std::string nick);
74  void reset_powerups();
75  void reset_cars();
76  void add_stairs();
77  std::vector<std::pair<std::string, int>> get_players_positions();
78 
81 };
82 #endif
Race(std::string data_file)
Definition: race.cpp:20
virtual ~Race()
Definition: race.cpp:25
std::shared_ptr< Race > shared
Definition: race.h:39
void start()
Definition: race.cpp:69
std::vector< std::string > player_nicks_
Definition: race.h:36
Track::shared circuit_
Definition: race.h:35
std::shared_ptr< Game > game_
Definition: race.h:30
void update(float delta)
Definition: race.cpp:29
void add(std::vector< Player::shared > players)
void reset_powerups()
Definition: race.cpp:112
Timer timer_
Definition: race.h:43
PowerUp::shared nitro_
Definition: race.h:33
void configure_grid()
Definition: race.cpp:254
void realize(std::shared_ptr< Game > game, std::vector< Player::shared > players)
Definition: race.cpp:42
void add_collision_hooks()
Definition: race.cpp:136
int number_of_laps_
Definition: race.h:32
Definition: track.h:33
Section get_section(int index)
Definition: race.cpp:245
std::shared_ptr< Player > shared
Definition: player.h:14
void add_stairs()
Definition: race.cpp:197
void create_powerups(void)
Definition: race.cpp:57
void next(std::string data_file)
Definition: race.cpp:85
std::shared_ptr< PowerUp > shared
Definition: powerup.h:45
void add_collision_with_circuit(Car::shared car)
Definition: race.cpp:148
std::shared_ptr< Car > shared
Definition: car.h:44
void pause()
Definition: race.cpp:80
std::vector< btVector3 > starting_grid_
Definition: race.h:41
Definition: game.h:36
PowerUp::shared money_
Definition: race.h:33
void reset()
Definition: race.cpp:95
Player::shared get_player(std::string nick)
Definition: race.h:29
std::vector< std::pair< std::string, int > > get_players_positions()
Definition: race.cpp:234
std::shared_ptr< Track > shared
Definition: track.h:59
void update_players(float delta)
Definition: race.cpp:174
bool has_ended()
Definition: race.cpp:118
void config_cars_in_login_order()
Definition: race.cpp:180
Definition: timer.h:22
void reset_cars()
Definition: race.cpp:104
std::vector< Player::shared > players_
Definition: race.h:34
void add_collision_with_cars(Player::shared target)
Definition: race.cpp:159
void config_race()
Definition: race.cpp:74
bool end(std::vector< Car::shared > cars)
Definition: race.cpp:127