Initial shot logic to remove tiles
This commit is contained in:
1 parent
0a34f6044f
commit
fd04772828
10 files changed
+129
-8
No files matched your search
@@ -11,6 +11,7 @@ HexTile::HexTile(float x, float y, float size)
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_size = size;
|
||||
m_damage_state = UNDAMAGED;
|
||||
}
|
||||
|
||||
bool HexTile::point_within(float x, float y)
|
||||
@@ -39,3 +40,12 @@ bool HexTile::point_within(float x, float y)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HexTile::shot()
|
||||
{
|
||||
if(m_damage_state < DESTROYED)
|
||||
{
|
||||
// Note: This only works because these are in order in the ENUM.
|
||||
m_damage_state = (Tile_Damage_States_t)((int)(m_damage_state) + 1);
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,25 @@
|
||||
class HexTile
|
||||
{
|
||||
public:
|
||||
typedef enum{
|
||||
UNDAMAGED,
|
||||
DAMAGED,
|
||||
DESTROYED
|
||||
}Tile_Damage_States_t;
|
||||
|
||||
HexTile(float x, float y, float size);
|
||||
bool point_within(float x, float y);
|
||||
float get_x() { return m_x; }
|
||||
float get_y() { return m_y; }
|
||||
float get_size() { return m_size; }
|
||||
Tile_Damage_States_t get_damage_state() { return m_damage_state; }
|
||||
void shot();
|
||||
protected:
|
||||
float m_x;
|
||||
float m_y;
|
||||
float m_size;
|
||||
Tile_Damage_States_t m_damage_state;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -40,7 +40,7 @@ Map::Map(int width, int height, float tile_size)
|
||||
|| (outer_out.point_within(y, x)
|
||||
&& !outer_in.point_within(y, x)))
|
||||
{
|
||||
refptr<HexTile> get_tile_at(float x, float y);
|
||||
refptr<HexTile> get_tile_at(float x, float y);
|
||||
ht = new HexTile(x, y, tile_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,13 @@ Player::Player()
|
||||
a_pressed = KEY_NOT_PRESSED;
|
||||
s_pressed = KEY_NOT_PRESSED;
|
||||
d_pressed = KEY_NOT_PRESSED;
|
||||
rel_mouse_movement = 0;
|
||||
rel_mouse_movement = 0.0;
|
||||
updated = false;
|
||||
m_client = NULL;
|
||||
m_shot_distance = 0.0;
|
||||
m_shot_start_time = 0.0;
|
||||
m_shot_start_x = 0.0;
|
||||
m_shot_start_y = 0.0;
|
||||
m_shot_direction = 0.0;
|
||||
|
||||
}
|
||||
@@ -21,6 +21,12 @@ class Player
|
||||
sf::Int32 rel_mouse_movement;
|
||||
bool updated;
|
||||
Client_t* m_client;
|
||||
float m_shot_distance;
|
||||
double m_shot_start_x;
|
||||
double m_shot_start_y;
|
||||
double m_shot_direction;
|
||||
double m_shot_start_time;
|
||||
|
||||
|
||||
Player();
|
||||
};
|
||||
|
||||
@@ -8,5 +8,12 @@
|
||||
#define PLAYER_DISCONNECT 0x2Bu
|
||||
#define PLAYER_DEATH 0x3Cu
|
||||
#define PLAYER_UPDATE 0x4Du
|
||||
#define PLAYER_SHOT 0x5Eu
|
||||
|
||||
#define TILE_DAMAGED 0xA1u
|
||||
|
||||
// The speed of the projectile
|
||||
#define PROJECTILE_VELOCITY 100.0
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user