summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/alien.h7
-rw-r--r--include/enemy_bullet.h7
-rw-r--r--include/game_entity.h13
-rw-r--r--include/game_state.h1
-rw-r--r--include/player_missile.h6
-rw-r--r--include/shield.h7
-rw-r--r--include/spaceship.h7
7 files changed, 33 insertions, 15 deletions
diff --git a/include/alien.h b/include/alien.h
index 2f7d596..5dda726 100644
--- a/include/alien.h
+++ b/include/alien.h
@@ -1,10 +1,11 @@
#pragma once
-class Alien {
+#include "game_entity.h"
+
+class Alien : public GameEntity
+{
public:
Alien(int x, int y);
const static char MAP_CHAR = 'x';
private:
- int x;
- int y;
};
diff --git a/include/enemy_bullet.h b/include/enemy_bullet.h
index db3fcf9..ff3b001 100644
--- a/include/enemy_bullet.h
+++ b/include/enemy_bullet.h
@@ -1,11 +1,12 @@
#pragma once
-class EnemyBullet {
+#include "game_entity.h"
+
+class EnemyBullet: public GameEntity
+{
public:
EnemyBullet(int x, int y);
const static char ALIEN_MAP_CHAR = '|';
const static char ENEMY_MISSILE_MAP_CHAR = 'i';
private:
- int x;
- int y;
};
diff --git a/include/game_entity.h b/include/game_entity.h
new file mode 100644
index 0000000..215333c
--- /dev/null
+++ b/include/game_entity.h
@@ -0,0 +1,13 @@
+#pragma once
+
+class GameEntity
+{
+public:
+ GameEntity(int x, int y);
+ int x() const {return _x;}
+ int y() const {return _y;}
+private:
+ int _x;
+ int _y;
+};
+
diff --git a/include/game_state.h b/include/game_state.h
index defe691..db20b84 100644
--- a/include/game_state.h
+++ b/include/game_state.h
@@ -12,6 +12,7 @@ class GameState
{
public:
GameState(std::string mapFilename);
+ void logState();
private:
std::vector<Alien> aliens;
std::vector<EnemyBullet> bullets;
diff --git a/include/player_missile.h b/include/player_missile.h
index 6f304df..c504a79 100644
--- a/include/player_missile.h
+++ b/include/player_missile.h
@@ -1,11 +1,11 @@
#pragma once
-class PlayerMissile
+#include "game_entity.h"
+
+class PlayerMissile: public GameEntity
{
public:
PlayerMissile(int x, int y);
const static char MAP_CHAR = '!';
private:
- int x;
- int y;
};
diff --git a/include/shield.h b/include/shield.h
index bd64e3e..be65be3 100644
--- a/include/shield.h
+++ b/include/shield.h
@@ -1,11 +1,12 @@
#pragma once
-class Shield {
+#include "game_entity.h"
+
+class Shield: public GameEntity
+{
public:
Shield(int x, int y);
const static char MAP_CHAR = '-';
private:
- int x;
- int y;
};
diff --git a/include/spaceship.h b/include/spaceship.h
index 5e6afd0..bd26b64 100644
--- a/include/spaceship.h
+++ b/include/spaceship.h
@@ -1,11 +1,12 @@
#pragma once
-class Spaceship {
+#include "game_entity.h"
+
+class Spaceship: public GameEntity
+{
public:
Spaceship(int x, int y);
const static char ENEMY_MAP_CHAR = 'V';
const static char PLAYER_MAP_CHAR = 'A';
private:
- int x;
- int y;
};