commit a3d1e3d3cced44cb6c4da4506123f0ef12e07400
parent 418056f4707eaf7857dc104e276cb89c5da26fbd
Author: amin <dev@aminmesbah.com>
Date: Wed, 25 Oct 2017 05:06:40 +0000
Accelerate player with thrust vector
FossilOrigin-Name: 284c9af6d2bf627f8963e9577ab29201bd23c6996fc86c556188f654e815d87c
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git 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);
}