summaryrefslogtreecommitdiff
path: root/src/game.cpp
blob: d805c83924754ea0dda5f4db6ace966bfc6b80f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "common.hpp"

namespace game {

class unit_t : public world::entity_t {
	world::world_t *world;

	void compute_bounds(v2f_t x)
	{
		bounds[0] = x + size[0];
		bounds[1] = x + size[1];
		render_bounds[0] = x + render_size[0];
		render_bounds[1] = x + render_size[1];
	}

public:
	rectf_t size, render_size;

	struct {
		world::tile_index_t pos;

		bool moving;
		std::list<world::tile_index_t*> path;
		world::tile_index_t dest;
	} move;

	void place(world::world_t *world, world::tile_index_t pos)
	{
		move.pos = pos;
		move.moving = false;
		unlink();
		compute_bounds((v2f_t)pos + v2f_t(0.5f, 0.5f));
		link(world);
	}

	void keep_moving(void)
	{
		if (!move.moving)
			return;
	}

	bool start_moving(world::tile_index_t dest)
	{
		return false;
	}
};

class human_t : public unit_t {
public:
	void render_to(render::state_t *render)
	{
		float angle = 0;
		render->render((move.moving ? &assets::human.legs_walking :
		               &assets::human.legs_idle), render_bounds, angle);
		render->render(&assets::human.body_idle, render_bounds, angle);
		render->render(&assets::human.head_idle, render_bounds, angle);
	}
};

static human_t human;

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, world::tile_index_t(0, 0));
}

void state_t::tick(void)
{
}

} //namespace game