summaryrefslogtreecommitdiff
path: root/src/game/game.hpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-13 19:50:42 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-13 19:50:42 +0100
commit868c3ce7659b1042f27b15774976dd20a0be3f77 (patch)
tree582823b2ab1f8f684a61c2e7a92aa501e33978a2 /src/game/game.hpp
parentb3b30521e50f1ed0046091b316b19daec646b4ac (diff)
Introduce health and damage; better alien AI.
Diffstat (limited to 'src/game/game.hpp')
-rw-r--r--src/game/game.hpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/game/game.hpp b/src/game/game.hpp
index f141e85..0ad0614 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -11,6 +11,12 @@ namespace game {
TILE_WALL
};
+ enum {
+ CF_NONE = 0,
+ CF_SOLID = 1,
+ CF_HUMAN = 2
+ };
+
extern size_t selection_cookie;
void worldgen(world::tile_t *tile, world::tile_index_t x,
@@ -20,6 +26,7 @@ namespace game {
typedef struct {
render::oriented_sprite_4M_t head_idle, body_idle;
render::oriented_sprite_4M2_t legs_idle, legs_walking;
+ render::animated_texture_t dead;
} human_assets_t;
typedef struct {
@@ -54,6 +61,8 @@ namespace game {
unit_t(type_t type_);
+ virtual void think(double now, double dt) = 0;
+
struct {
bool moving = false;
v2f_t dst;
@@ -66,21 +75,27 @@ namespace game {
float next_attempt;
} move;
- const wchar_t *say_text;
- double say_time = -INFINITY;
-
- bool awake = false;
- double wake_time = -INFINITY;
-
- void render_to(render::state_t *render);
- void say(const wchar_t *wstr, double now);
void place(world::world_t *world_, v2f_t x_);
bool keep_moving(double now, double dt, double speed);
bool start_moving(v2f_t dst_, double now);
+ bool awake = false;
+ double wake_time = -INFINITY;
virtual void wake(double now, unit_t *by_whom) = 0;
virtual void sleep(double now) = 0;
- virtual void think(double now, double dt) = 0;
+
+ bool dead = false;
+ double death_time = -INFINITY;
+ int health = 1;
+ void damage(double now, int points);
+ virtual void die(double now) = 0;
+
+ const wchar_t *say_text;
+ double say_time = -INFINITY;
+ void say(const wchar_t *wstr, double now);
+
+ void render_to(render::state_t *render);
+
};
class human_t : public unit_t {
@@ -91,11 +106,14 @@ namespace game {
void wake(double now, unit_t *by_whom);
void sleep(double now);
void think(double now, double dt);
+ void die(double now);
};
class alien_t : public unit_t {
- unit_t *target;
+ double next_targetting = -INFINITY;
+ double next_attack = -INFINITY;
+ void attack(double now, unit_t *target, float range);
public:
alien_t();
void render_to(render::state_t *render);
@@ -103,5 +121,6 @@ namespace game {
void wake(double now, unit_t *by_whom);
void sleep(double now);
void think(double now, double dt);
+ void die(double now);
};
};