forked from kdx/jtmm2-old
More comments in player.c
This commit is contained in:
parent
833a1711c4
commit
190368b666
21
src/player.c
21
src/player.c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue