diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-14 16:16:34 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-14 16:16:34 +0200 |
commit | 672180b2ee3ed9b9ff984538a85e6eaf2e1c91bc (patch) | |
tree | 9dc40562890b7dff088afc46fb4e2af0ea3552d8 /src/game.cpp | |
parent | e4ca910e7731e2a12815a4a8de2582157f519898 (diff) |
Move assets to assets.cpp.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/game.cpp b/src/game.cpp index 58b56c6..0b3e8d6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5,22 +5,6 @@ namespace game { class unit_t : public world::entity_t { }; -struct { - struct { - render::oriented_sprite_4M_t head_idle, body_idle; - render::oriented_sprite_4M2_t legs_idle, legs_walking; - } human; -} assets; - -bool load_assets(void) -{ - assets.human.head_idle.load("assets/units/human/head_idle", 1, 1, 1); - assets.human.body_idle.load("assets/units/human/body_idle", 2, 2, 2); - assets.human.legs_idle.load("assets/units/human/legs_idle", 2, 2); - assets.human.legs_walking.load("assets/units/human/legs_walking", 2, 2); - return true; -} - class human_t : public unit_t { public: @@ -30,10 +14,10 @@ public: void render_to(render::state_t *render) { - render->render((walking ? &assets.human.legs_walking : - &assets.human.legs_idle), bounds, angle); - render->render(&assets.human.body_idle, bounds, angle); - render->render(&assets.human.head_idle, bounds, angle); + render->render((walking ? &assets::human.legs_walking : + &assets::human.legs_idle), bounds, angle); + render->render(&assets::human.body_idle, bounds, angle); + render->render(&assets::human.head_idle, bounds, angle); } }; @@ -41,11 +25,7 @@ static std::list<human_t> humans; void state_t::start(void) { -} - -void state_t::tick(void) -{ - if (rand() % 5 == 0) { + for (size_t i = 0; i < 5; i++) { humans.emplace(humans.end()); human_t &human = *(--humans.end()); @@ -56,7 +36,10 @@ void state_t::tick(void) human.bounds.height = 1.0f; human.link(&world); } +} +void state_t::tick(void) +{ for (human_t &human : humans) { human.stalin -= ((float)rand() / RAND_MAX) * 0.1f; |