diff --git a/src/player.c b/src/player.c index 1932a00..e5094f1 100644 --- a/src/player.c +++ b/src/player.c @@ -3,6 +3,9 @@ #include /* (Mibi88) TODO: Upscale the player for the CG50. */ +/* The player should not be bigger than a tile because it may cause problems + * with the collisions. If it's a problem please ask me (Mibi88) to adapt that. + */ #define P_WIDTH 8 #define P_HEIGHT 8 @@ -56,9 +59,9 @@ bool player_collision(Map *map_level, Player *player, Direction direction) { const char dx = one_px_mov[direction*2]; const char dy = one_px_mov[direction*2+1]; int player_tile_x = player->x/T_WIDTH; - int player_tile_y = player->x/T_WIDTH; + int player_tile_y = player->y/T_HEIGHT; for(i=0;inblayers;i++){ - if(is_in(hard_tiles, HARD_TILES_AMOUNT, + if(is_in((short int*)hard_tiles, HARD_TILES_AMOUNT, get_tile(map_level, player_tile_x+dx, player_tile_y+dy, i))){ return true; } @@ -67,7 +70,7 @@ bool player_collision(Map *map_level, Player *player, Direction direction) { } void player_fix_position(Player *player, bool fix_x, bool fix_y) { - if(fix_x) player->x = player->x/T_WIDTH*T_WIDTH; - if(fix_y) player->y = player->y/T_HEIGHT*T_HEIGHT; + if(fix_x) player->x = player->x/T_WIDTH*T_WIDTH+P_WIDTH/2; + if(fix_y) player->y = player->y/T_HEIGHT*T_HEIGHT+P_HEIGHT/2; }