summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmin Mesbah <mesbahamin@gmail.com>2017-10-24 22:06:40 -0700
committerAmin Mesbah <mesbahamin@gmail.com>2017-10-24 22:06:40 -0700
commit90c8e671a8ffc1b4f3aff3c04b0b3c80f87f59b8 (patch)
tree73a57c3792f84f3efc7981c2469bf3a6c0a7952b
parentaf35e8eeca572f355ef423c0e20195f2cdc6fa53 (diff)
downloadohsp-90c8e671a8ffc1b4f3aff3c04b0b3c80f87f59b8.zip
ohsp-90c8e671a8ffc1b4f3aff3c04b0b3c80f87f59b8.tar.gz
Accelerate player with thrust vector
-rw-r--r--src/game.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
index b067fb4..946d53a 100644
--- a/src/game.c
+++ b/src/game.c
@@ -44,6 +44,11 @@ void game_update(struct GameState *game_state, struct GameControllerInput game_i
game_input.left_stick_y,
game_state->thrust_vector.angle,
game_state->thrust_vector.length);
+
+ struct Entity *player = &game_state->player;
+ entity_accelerate(player, game_state->thrust_vector.angle, game_state->thrust_vector.length * 0.001);
+ player->x += player->speed * cos(player->angle);
+ player->y += player->speed * sin(player->angle);
}
@@ -61,6 +66,11 @@ void game_render(struct OffscreenBuffer *buffer, float dt, struct GameState *gam
player.y + (game_state->thrust_vector.length * sin(game_state->thrust_vector.angle)),
10,
0x0000FF);
+ game_render_circle(buffer,
+ player.x + 100 * (player.speed * cos(player.angle)),
+ player.y + 100 * (player.speed * sin(player.angle)),
+ 10,
+ 0xFF00FF);
}