summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.hpp3
-rw-r--r--src/game.cpp44
-rw-r--r--src/main.cpp4
3 files changed, 33 insertions, 18 deletions
diff --git a/src/common.hpp b/src/common.hpp
index 44493eb..f89ae08 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -176,12 +176,15 @@ namespace game {
class state_t {
double now;
+
+ std::unordered_set<unit_t*> units;
std::unordered_set<unit_t*> selected_units;
public:
world::world_t world;
void start(void);
+ void stop(void);
void tick(double now_);
// These are called by the interface.
diff --git a/src/game.cpp b/src/game.cpp
index 5dc9af8..bfc698d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -117,7 +117,7 @@ public:
if (move.attempts_left) {
move.blocked = true;
move.attempts_left--;
- move.next_attempt = now + 0.5f;
+ move.next_attempt = now + 0.2f;
} else {
if ((x - move.dst).len() > 1.5f)
say(text::unit_blocked, now);
@@ -160,7 +160,13 @@ public:
class human_t : public unit_t {
public:
- double last_follow = -INFINITY;
+ human_t()
+ {
+ size[0] = v2f_t(-0.4f, -0.4f);
+ 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);
+ }
void render_to(render::state_t *render)
{
@@ -192,21 +198,24 @@ public:
}
};
-static human_t human, human2;
-
void state_t::start(void)
{
- human.size[0] = v2f_t(-0.4f, -0.4f);
- human.size[1] = v2f_t(+0.4f, +0.4f);
- human.render_size[0] = v2f_t(-0.5f, -1.0f);
- human.render_size[1] = v2f_t(+0.5f, +0.5f);
- human.place(&world, v2f_t(2.5f, -3.5f));
-
- human2.size[0] = v2f_t(-0.4f, -0.4f);
- human2.size[1] = v2f_t(+0.4f, +0.4f);
- human2.render_size[0] = v2f_t(-0.5f, -1.0f);
- human2.render_size[1] = v2f_t(+0.5f, +0.5f);
- human2.place(&world, v2f_t(3.5f, 0.5f));
+ for (size_t i = 0; i < 10; i++) {
+ human_t *human;
+
+ human = new human_t;
+ human->place(&world, v2f_t(0.5, 0.5) + i * v2f_t(0.2, -1.2f));
+ units.insert(human);
+ }
+}
+
+void state_t::stop(void)
+{
+ // FIXME
+ /*
+ for (unit_t *unit : units)
+ delete unit;
+ */
}
void state_t::select(rectf_t x)
@@ -235,8 +244,9 @@ void state_t::command(v2f_t x)
void state_t::tick(double now_)
{
now = now_;
- human.keep_moving(now_);
- human2.keep_moving(now_);
+
+ for (unit_t *unit : units)
+ unit->keep_moving(now);
}
} //namespace game
diff --git a/src/main.cpp b/src/main.cpp
index 57c923d..1059cb6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,7 +21,7 @@ int main()
game::state_t game;
interface::state_t interface(&window, &game);
- window.setVerticalSyncEnabled(true);
+ window.setVerticalSyncEnabled(false);
text::load_strings("pl");
assets::load();
@@ -43,5 +43,7 @@ int main()
render.end_frame();
}
+ game.stop();
+
return 0;
}