Robot Devastation
GameScreen.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_GAME_SCREEN_HPP__
6 #define __RD_GAME_SCREEN_HPP__
7 
8 #include <string>
9 #include <vector>
10 
11 #include <SDL.h>
12 #include <SDL_ttf.h>
13 
14 #include "Target.hpp"
15 #include "Player.hpp"
16 #include "Weapon.hpp"
17 #include "Screen.hpp"
18 #include "ImageManager.hpp"
19 
20 namespace rd{
21 
28 class GameScreen : public Screen
29 {
30  public:
31  GameScreen();
32  virtual bool init();
33  virtual bool cleanup();
34  virtual bool drawScreen(void *screen);
35  virtual ~GameScreen();
36  virtual bool update(const std::string & parameter, const std::string & value);
37  virtual bool update(const std::string & parameter, const Player & value);
38  virtual bool update(const std::string & parameter, const std::vector<Player> & value);
39  virtual bool update(const std::string & parameter, const std::vector<Target> & value);
40  virtual bool update(const std::string & parameter, const Weapon & value);
41  virtual bool update(const std::string & parameter, const Image & value);
42 
43  //-- Screen interface parameters
44  static const std::string PARAM_CAMERA_FRAME;
45  static const std::string PARAM_MYSELF;
46  static const std::string PARAM_PLAYERS;
47  static const std::string PARAM_TARGETS;
48  static const std::string PARAM_WEAPON;
49 
50  private:
51  bool drawUserUI(SDL_Surface * screen, const Player & user, const Weapon & weapon);
52  bool drawPlayerUI( SDL_Surface * screen, const Player & player, int x, int y);
53  bool drawTargetUI( SDL_Surface * screen, const Target & target, const Player & player_data);
54  bool drawScope( SDL_Surface * screen );
55 
56  //-- Screen constants (that should not be constant)
58  static const int SCREEN_WIDTH = 640;
59  static const int SCREEN_HEIGHT = 480;
60 
61  //-- Player info constants
62  static const int PLAYER_NAME_H = 15;
63  static const int PLAYER_NAME_W = 65;
64  static const int HEALTH_BAR_H = 10;
65  static const int HEALTH_BAR_W = 80;
66 
67  //-- Target constants
68  static const int TARGET_THICKNESS = 2;
69  static const int TARGET_TEXT_BOX_HEIGHT = 15;
70  static const int TARGET_HEALTH_BAR_H = 5;
71 
72  //-- Scope constants
73  static const int SCOPE_VERT_W = 4;
74  static const int SCOPE_VERT_H = 50;
75  static const int SCOPE_VERT_H_SPACE = 20;
76 
77  static const int SCOPE_HORIZ_W = 50;
78  static const int SCOPE_HORIZ_H = 4;
79  static const int SCOPE_HORIZ_W_SPACE = 20;
80 
81  //-- User info display constants
82  static const int USER_HEALTH_MARGIN_X = 10;
83  static const int USER_HEALTH_MARGIN_Y = 20;
84  static const int USER_HEALTH_W = 20;
85  static const int USER_HEALTH_BOTTOM_Y = 50;
86 
87  static const int AMMO_BAR_MARGIN_X =20;
88  static const int AMMO_BAR_MARGIN_Y = 20;
89  static const int AMMO_BAR_W = 200;
90  static const int AMMO_BAR_H = 15;
91 
92  static const int WEAPON_NAME_WIDTH = 100;
93  static const int WEAPON_NAME_HEIGHT = 10;
94 
95  static const int AMMO_TEXT_WIDTH = 50;
96  static const int AMMO_TEXT_HEIGHT = 10;
97 
98  //-- Refresh control
99  bool update_required;
100 
101  //-- SDL stuff
102  SDL_Surface * camera_frame_surface;
103  TTF_Font *player_font, *target_font, *weapon_font;
104 
105  static const SDL_Color greencolor;
106  static const SDL_Color redcolor;
107  static const SDL_Color bluecolor;
108 
109  Player myself;
110  std::vector<Player> players;
111  std::vector<Target> targets;
112  Weapon current_weapon;
113  Image camera_frame;
114 
115 };
116 
117 }
118 
119 #endif //-- __RD_GAME_SCREEN_HPP__
rd::Player
Class that represents a player of this game, with a 'unique' id, name, health, team id and score.
Definition: Player.hpp:21
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::Screen
A User Interface.
Definition: Screen.hpp:24
rd::Weapon
Class that represents a weapon.
Definition: Weapon.hpp:22
rd::GameScreen
A User Interface.
Definition: GameScreen.hpp:28
rd::GameScreen::SCREEN_WIDTH
static const int SCREEN_WIDTH
Definition: GameScreen.hpp:58
rd::Target
Class that represents a target detected. This target is (or should be) associated to a player.
Definition: Target.hpp:18