More comments in player.c

This commit is contained in:
KikooDX 2020-12-21 12:26:18 +01:00
parent 833a1711c4
commit 190368b666
1 changed files with 17 additions and 4 deletions

View File

@ -18,16 +18,25 @@ void player_step(Player *player, Input *input, const Level *level) {
Vec destination;
vec_cpy(&destination, player->pos);
vec_add(&destination, move);
/* The player can move if they're stuck in a block, to avoid
* softlock in some situations. If the destination is solid and
* they aren't in a block, then we use the costy player_move
* function to snap them and reset their speed accordingly.
*/
if (collide_full(player, player->pos, level, level->solid_layer) ||
!collide_full(player, destination, level, level->solid_layer))
{
!collide_full(player, destination, level, level->solid_layer)) {
vec_cpy(&player->pos, destination);
}
else {
}
}
void player_draw(Player *player, Camera *camera) {
Vec tl;
Vec br;
Vec tl; /* top left */
Vec br; /* bottom right */
/* The rest of this function calculates the player on screen
* position and draw it.
*/
vec_cpy(&tl, player->pos);
vec_sub(&tl, player->origin);
vec_cpy(&br, tl);
@ -39,10 +48,14 @@ void player_draw(Player *player, Camera *camera) {
vec_mul(&tl, SCALE);
vec_mul(&br, SCALE);
vec_add(&br, (Vec){SCALE - 1, SCALE - 1});
/* draw code here */
vec_drect(tl, br, C_BLACK);
}
void player_draw_debug(Player *player, uint step, const Level *level, uint layer_id) {
/* This debug function displays more or less usefull
* informations for debugging player movement.
*/
dprint(0, 0, C_BLACK, "x: %d", player->pos.x);
dprint(0, 10, C_BLACK, "y: %d", player->pos.y);
dprint(0, 20, C_BLACK, "vp: %d", VEC_PRECISION);