diff options
| author | Carlos Maiolino <[email protected]> | 2025-11-30 15:57:34 +0100 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-11-30 15:57:34 +0100 |
| commit | b44a1bf90f4336833f8ade39d053b9d917ede848 (patch) | |
| tree | 8ccd1c94ac6e395bbfc729c34bb679e7111bb7b1 | |
| parent | e6bb80a1aa60681992dba22823100900a4f22201 (diff) | |
Add spaceship drawing
Signed-off-by: Carlos Maiolino <[email protected]>
| -rw-r--r-- | src/spaceship.c | 53 |
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); + +} |
