diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-16 20:17:57 +0000 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-16 20:17:57 +0000 |
commit | 273c601a94464bef2161b9c3a29ea3cf901340e9 (patch) | |
tree | 9b3c4907c69dddf3b2dc421d89841081a735ac0d /src/game | |
parent | d96a70e50f7b3b19f3424aa9b97123db681269a8 (diff) |
Rename aliens to spiders and humans to soldiers.
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/assets.cpp | 26 | ||||
-rw-r--r-- | src/game/game.cpp | 30 | ||||
-rw-r--r-- | src/game/game.hpp | 27 | ||||
-rw-r--r-- | src/game/units.cpp | 50 |
4 files changed, 69 insertions, 64 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp index e5fee38..a4a03e5 100644 --- a/src/game/assets.cpp +++ b/src/game/assets.cpp @@ -2,24 +2,24 @@ namespace game::assets { -human_assets_t human; -alien_assets_t alien; +soldier_assets_t soldier; +spider_assets_t spider; fx_assets_t fx; deco_assets_t deco; void load(void) { - human.head_idle.load("assets/units/human/head_idle", 1, 1, 1); - human.body_idle.load("assets/units/human/body_idle", 2, 2, 2); - human.body_aiming.load("assets/units/human/body_aiming", 2, 2, 2); - human.body_firing.load("assets/units/human/body_firing", 2, 2, 2); - human.legs_idle.load("assets/units/human/legs_idle", 2, 2); - human.legs_walking.load("assets/units/human/legs_walking", 2, 2); - human.dead.load("assets/units/human/dead_", 1); - - alien.idle.load("assets/units/alien/idle", 2, 2, 2); - alien.walking.load("assets/units/alien/walking", 2, 2, 2); - alien.dead.load("assets/units/alien/dead_", 1); + soldier.head_idle.load("assets/units/soldier/head_idle", 1, 1, 1); + soldier.body_idle.load("assets/units/soldier/body_idle", 2, 2, 2); + soldier.body_aiming.load("assets/units/soldier/body_aiming", 2, 2, 2); + soldier.body_firing.load("assets/units/soldier/body_firing", 2, 2, 2); + soldier.legs_idle.load("assets/units/soldier/legs_idle", 2, 2); + soldier.legs_walking.load("assets/units/soldier/legs_walking", 2, 2); + soldier.dead.load("assets/units/soldier/dead_", 1); + + spider.idle.load("assets/units/spider/idle", 2, 2, 2); + spider.walking.load("assets/units/spider/walking", 2, 2, 2); + spider.dead.load("assets/units/spider/dead_", 1); fx.blood.load("assets/units/blood_", 4); diff --git a/src/game/game.cpp b/src/game/game.cpp index 35d66ec..51dca09 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -63,25 +63,25 @@ void entity_t::sleep(void) void state_t::start(void) { - human_t *human; - alien_t *alien; + unit_soldier_t *soldier; + unit_spider_t *spider; world.generator = worldgen; world.generator_data = (void*)this; - human = new human_t(this); - human->place(&world, v2f_t(0.5, 0.5)); - human = new human_t(this); - human->place(&world, v2f_t(1.5, 0.5)); - human = new human_t(this); - human->place(&world, v2f_t(2.5, 0.5)); + soldier = new unit_soldier_t(this); + soldier->place(&world, v2f_t(0.5, 0.5)); + soldier = new unit_soldier_t(this); + soldier->place(&world, v2f_t(1.5, 0.5)); + soldier = new unit_soldier_t(this); + soldier->place(&world, v2f_t(2.5, 0.5)); - alien = new alien_t(this); - alien->place(&world, v2f_t(15.5, -2.5)); - alien = new alien_t(this); - alien->place(&world, v2f_t(14.5, -2.5)); - alien = new alien_t(this); - alien->place(&world, v2f_t(13.5, -2.5)); + spider = new unit_spider_t(this); + spider->place(&world, v2f_t(15.5, -2.5)); + spider = new unit_spider_t(this); + spider->place(&world, v2f_t(14.5, -2.5)); + spider = new unit_spider_t(this); + spider->place(&world, v2f_t(13.5, -2.5)); } void state_t::stop(void) @@ -103,7 +103,7 @@ void state_t::select(rectf_t x) unit = (unit_t*)ent; - if (unit->type != unit_t::UNIT_HUMAN) + if (!unit->controllable) continue; if (!unit->dead && unit->selected != old_cookie) diff --git a/src/game/game.hpp b/src/game/game.hpp index c17de64..df027ce 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -32,12 +32,12 @@ namespace game { render::oriented_sprite_4M_t body_aiming, body_firing; render::oriented_sprite_4M2_t legs_idle, legs_walking; render::animated_texture_t dead; - } human_assets_t; + } soldier_assets_t; typedef struct { render::oriented_sprite_4M_t idle, walking; render::animated_texture_t dead; - } alien_assets_t; + } spider_assets_t; typedef struct { render::animated_texture_t blood; @@ -47,8 +47,8 @@ namespace game { render::animated_texture_t stone, eyething, nest; } deco_assets_t; - extern human_assets_t human; - extern alien_assets_t alien; + extern soldier_assets_t soldier; + extern spider_assets_t spider; extern fx_assets_t fx; extern deco_assets_t deco; @@ -88,8 +88,8 @@ namespace game { size_t selected = 0; typedef enum { - UNIT_HUMAN, - UNIT_ALIEN + UNIT_SOLDIER, + UNIT_SPIDER } type_t; type_t type; @@ -97,6 +97,9 @@ namespace game { unit_t(game::state_t *game_, type_t type_); + bool friendly = false; + bool controllable = false; + struct { bool moving = false; v2f_t dst; @@ -134,13 +137,13 @@ namespace game { }; - class human_t : public unit_t { + class unit_soldier_t : public unit_t { double last_target_time = -INFINITY; v2f_t last_target_x; public: - human_t(game::state_t *game_); - ~human_t(void) {}; + unit_soldier_t(game::state_t *game_); + ~unit_soldier_t(void) {}; void render_to(render::state_t *render); void on_think(void); @@ -149,10 +152,10 @@ namespace game { void on_death(void); }; - class alien_t : public unit_t { + class unit_spider_t : public unit_t { public: - alien_t(game::state_t *game_); - ~alien_t(void) {}; + unit_spider_t(game::state_t *game_); + ~unit_spider_t(void) {}; void render_to(render::state_t *render); void on_think(void); diff --git a/src/game/units.cpp b/src/game/units.cpp index 8eb11c7..ee6ee9f 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -153,7 +153,7 @@ void unit_t::damage(int points, unit_t *attacker) { fx_blood_t *blood; - blood = new fx_blood_t(game, x, type == UNIT_ALIEN); + blood = new fx_blood_t(game, x, type == UNIT_SPIDER); blood->place(&game->world); health -= points; @@ -237,9 +237,11 @@ static unit_t *find_target(world::world_t *world, v2f_t x, float r, return nearest; } -human_t::human_t(game::state_t *game) : unit_t(game, UNIT_HUMAN) +unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER) { always_awake = true; + friendly = true; + controllable = true; cmodel.cflags = CF_BODY; health = max_health = 20; @@ -247,14 +249,14 @@ human_t::human_t(game::state_t *game) : unit_t(game, UNIT_HUMAN) size[1] = v2f_t(+0.4f, +0.4f); render_size[0] = v2f_t(-0.5f, -1.0f); render_size[1] = v2f_t(+0.5f, +0.5f); - name = text::get(text::UNIT_HUMAN); + name = text::get(text::UNIT_NAME_SOLDIER); cs.armor_class = 10; cs.hit_roll = roll_params_t(20); cs.damage_roll = roll_params_t(4); } -void human_t::on_think(void) +void unit_soldier_t::on_think(void) { if (dead) return; @@ -264,7 +266,7 @@ void human_t::on_think(void) if (game->now > next_targetting) { unit_t *target; - target = find_target(world, x, 10.0f, UNIT_ALIEN); + target = find_target(world, x, 10.0f, UNIT_SPIDER); if (target) { last_target_time = game->now; last_target_x = target->x; @@ -293,7 +295,7 @@ void human_t::on_think(void) say(text::get(text::SAY_BLOCKED)); } -void human_t::on_death(void) +void unit_soldier_t::on_death(void) { render_size[0] = v2f_t(-0.75f, -0.5f); render_size[1] = v2f_t(+0.75f, +0.5f); @@ -302,40 +304,40 @@ void human_t::on_death(void) place(world, x); } -void human_t::render_to(render::state_t *render) +void unit_soldier_t::render_to(render::state_t *render) { if (!dead) { render::oriented_sprite_t *legs, *body; float body_angle; if (move.moving && !move.blocked) - legs = &assets::human.legs_walking; + legs = &assets::soldier.legs_walking; else - legs = &assets::human.legs_idle; + legs = &assets::soldier.legs_idle; if (last_target_time + 3 > game->now) { if (last_attack + 0.1 > game->now) - body = &assets::human.body_firing; + body = &assets::soldier.body_firing; else - body = &assets::human.body_aiming; + body = &assets::soldier.body_aiming; body_angle = (last_target_x - x).angle(); } else { - body = &assets::human.body_idle; + body = &assets::soldier.body_idle; body_angle = move.angle; } render->render(game->now * 10, legs, render_bounds, move.angle); render->render(game->now * 10, body, render_bounds, body_angle); - render->render(game->now * 10, &assets::human.head_idle, render_bounds, body_angle); + render->render(game->now * 10, &assets::soldier.head_idle, render_bounds, body_angle); } else - render->render(game->now * 10, &assets::human.dead, render_bounds); + render->render(game->now * 10, &assets::soldier.dead, render_bounds); unit_t::render_to(render); } -alien_t::alien_t(game::state_t *game) : unit_t(game, UNIT_ALIEN) +unit_spider_t::unit_spider_t(game::state_t *game) : unit_t(game, UNIT_SPIDER) { cmodel.cflags = CF_BODY_SMALL; health = max_health = 4; @@ -343,14 +345,14 @@ alien_t::alien_t(game::state_t *game) : unit_t(game, UNIT_ALIEN) size[1] = v2f_t(+0.2f, +0.3f); render_size[0] = v2f_t(-0.3f, -0.3f); render_size[1] = v2f_t(+0.3f, +0.3f); - name = text::get(text::UNIT_ALIEN); + name = text::get(text::UNIT_NAME_SPIDER); cs.armor_class = 5; cs.hit_roll = roll_params_t(20); cs.damage_roll = roll_params_t(3, 6, 1); } -void alien_t::on_think(void) +void unit_spider_t::on_think(void) { if (dead) return; @@ -358,7 +360,7 @@ void alien_t::on_think(void) if (game->now > next_targetting) { unit_t *target; - target = find_target(world, x, 10.0f, UNIT_HUMAN); + target = find_target(world, x, 10.0f, UNIT_SOLDIER); if (target) { if (last_attack + 0.5 < game->now) { world::trace_t trace; @@ -381,28 +383,28 @@ void alien_t::on_think(void) keep_moving(7.0); } -void alien_t::on_wake(void) +void unit_spider_t::on_wake(void) { next_targetting = game->now; } -void alien_t::on_death(void) +void unit_spider_t::on_death(void) { render_layer = -1; cmodel.cflags = CF_BACKGROUND; } -void alien_t::render_to(render::state_t *render) +void unit_spider_t::render_to(render::state_t *render) { bool moving; moving = move.moving && !move.blocked; if (!dead) - render->render(game->now * 20, (moving ? &assets::alien.walking : - &assets::alien.idle), render_bounds, move.angle); + render->render(game->now * 20, (moving ? &assets::spider.walking : + &assets::spider.idle), render_bounds, move.angle); else - render->render(game->now * 20, &assets::alien.dead, render_bounds); + render->render(game->now * 20, &assets::spider.dead, render_bounds); unit_t::render_to(render); } |