summaryrefslogtreecommitdiff
path: root/src/spaceship.c
blob: e92c4bb66c126d90d3c9a8b37186555915c81d80 (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
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <stdio.h>

#include <rb.h>
#include <spaceship.h>

void
rb_ship_init(struct spaceship *sp)
{
	sp->x		 = RB_X_CENTER;
	sp->y		 = RB_Y_CENTER;
	sp->heading	 = 24;
	sp->speed	 = 0;
	sp->rot_velocity = 0;
	sp->scale	 = 0;
	sp->alive	 = 1;
	sp->color	 = al_map_rgb(255, 255, 255);
	printf("ship initialized\n");
}

#if 0
void
rb_ship_accelerate(struct spaceship *sp,
	       float x, float, y)
{
}
#endif

void
rb_draw_ship(struct spaceship *sp)
{
	ALLEGRO_TRANSFORM transform;
	al_identity_transform(&transform);
	al_rotate_transform(&transform, (ALLEGRO_PI / 180) * sp->heading);
	al_translate_transform(&transform, sp->x, sp->y);
	al_use_transform(&transform);

	al_draw_line(RB_X_CENTER - 8, RB_Y_CENTER + 9,
		     RB_X_CENTER, RB_Y_CENTER - 11,
		     sp->color, 3.0f);

	al_draw_line(RB_X_CENTER, RB_Y_CENTER - 11,
		     RB_X_CENTER + 8, RB_Y_CENTER + 9,
		     sp->color, 3.0f);
	al_draw_line(RB_X_CENTER - 6, RB_Y_CENTER + 4,
		     RB_X_CENTER - 1, RB_Y_CENTER + 4,
		     sp->color, 3.0f);
	al_draw_line(RB_X_CENTER + 6, RB_Y_CENTER + 4,
		     RB_X_CENTER + 1, RB_Y_CENTER + 4,
		     sp->color, 3.0f);

}