summaryrefslogtreecommitdiff
path: root/entity.ha
blob: 07b8b693f4ac5e5e767137653ff7875e4e4aa2b1 (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
use vt;
use math::random;
use time;
use fmt;
use os;

type entity = struct {
	x: uint,
	y: uint,
	letter: rune,
	color: u8,
};

fn entity_draw(ent: *entity, term: *vt::term) void = {
	vt::move(term, ent.y+1, ent.x+1)!;
	fmt::fprintf(os::stdout_file,"\x1b[3{}m{}",ent.color,ent.letter)!;
};

fn entity_tick(ent: *entity, room: *room) void = {
	ent.x += 1;
	if (ent.x >= 13) ent.x = 1;
	ent.y += 1;
	if (ent.y >= 11) ent.y = 1;
};

fn entity_new(r: rune, col: u8) entity = entity {
	x = 1,
	y = 1,
	letter = r,
	color = col,
};