summaryrefslogtreecommitdiff
path: root/src/spaceship.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spaceship.c')
-rw-r--r--src/spaceship.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/spaceship.c b/src/spaceship.c
new file mode 100644
index 0000000..e92c4bb
--- /dev/null
+++ b/src/spaceship.c
@@ -0,0 +1,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);
+
+}