diff --git a/src/game.c b/src/game.c index 32de325..88686bf 100644 --- a/src/game.c +++ b/src/game.c @@ -29,10 +29,10 @@ void interaction_available(Game *game) { /* simple distance check along X and Y axis */ /* Be careful to use world coordinates, not local (i.e.map) ones */ - if((abs((int)game->player.wx - + if((abs((int)game->player.x - (int)(game->map_level->npcs[i].curx >> PRECISION) * PXSIZE) < MAX_INTERACTION_DISTANCE * PXSIZE) && - (abs((int)game->player.wy - + (abs((int)game->player.y - (int)(game->map_level->npcs[i].cury >> PRECISION) * PXSIZE) < MAX_INTERACTION_DISTANCE * PXSIZE)) { /* the player can do something */ @@ -48,10 +48,10 @@ void interaction_available(Game *game) { for(i = 0; i < game->map_level->nbSign; i++) { /* simple distance check along X and Y axis */ /* Be careful to use world coordinates, not local (i.e.map) ones */ - if((abs((int)game->player.wx - + if((abs((int)game->player.x - (int)game->map_level->signs[i].x * PXSIZE) < MAX_INTERACTION_DISTANCE * PXSIZE) && - (abs((int)game->player.wy - + (abs((int)game->player.y - (int)game->map_level->signs[i].y * PXSIZE) < MAX_INTERACTION_DISTANCE * PXSIZE)) { /* the player can do something */ diff --git a/src/game.h b/src/game.h index 0b5dbb1..992d0bd 100644 --- a/src/game.h +++ b/src/game.h @@ -19,9 +19,8 @@ typedef struct { /* Struct that define player parameters */ typedef struct { - int16_t x, y; /* The position of the player int the current map */ + int16_t x, y; /* The position of the player in the current map */ uint16_t px, py; /* The position of the player on screen */ - int16_t wx, wy; /* position of the player in the world */ int8_t life; /* How many lives the player still has between 0 and 100. */ int8_t speed; /* The speed of the movement of the player. */ diff --git a/src/main.c b/src/main.c index dd8f647..3db52cb 100644 --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,7 @@ extern Map *worldRPG[]; /* Game data (defined in "game.h")*/ Game game = {NULL, - {12 * PXSIZE, 36 * PXSIZE, 0, 0, 12 * PXSIZE, 36 * PXSIZE, 100, + {12 * PXSIZE, 36 * PXSIZE, 0, 0, 100, SPEED, false, 0, false, false, true}, {{}, {}, 0}, false, @@ -124,8 +124,10 @@ int main(void) { dgray(DGRAY_ON); #endif +#if DEBUGMODE dupdate(); getkey(); +#endif do { /* clear screen */ diff --git a/src/map.c b/src/map.c index 89cb3ca..0314811 100644 --- a/src/map.c +++ b/src/map.c @@ -231,7 +231,7 @@ Map *map_get_for_tile(Game *game, int x, int y) { do { int rx = x - map->x; int ry = y - map->y; - if(rx >= 0 && rx < map->w && ry >= 0 && ry < map->h) { + if(rx >= 0 && rx < (int)map->w && ry >= 0 && ry < (int)map->h) { return map; } i++; diff --git a/src/npc.c b/src/npc.c index 8286b76..5479ba0 100644 --- a/src/npc.c +++ b/src/npc.c @@ -267,8 +267,8 @@ void npc_draw(Game *game) { } #endif // DEBUGMODE - int16_t delX = ((Data->curx * PXSIZE) >> PRECISION) - (int16_t)pl->wx; - int16_t delY = ((Data->cury * PXSIZE) >> PRECISION) - (int16_t)pl->wy; + int16_t delX = ((Data->curx * PXSIZE) >> PRECISION) - (int16_t)pl->x; + int16_t delY = ((Data->cury * PXSIZE) >> PRECISION) - (int16_t)pl->y; bopti_image_t *face = npc_sprites[Data->face]; dimage(pl->px - P_WIDTH / 2 + delX, pl->py - P_HEIGHT / 2 + delY, face); } diff --git a/src/player.c b/src/player.c index 72eb595..6751d15 100644 --- a/src/player.c +++ b/src/player.c @@ -51,9 +51,6 @@ void player_draw(Game *game) { void player_move(Game *game, Direction direction) { Player *player = &game->player; - int old_x = player->x; - int old_y = player->y; - /* How this player movement will modify the player x and y. */ char dx, dy; @@ -90,9 +87,6 @@ void player_move(Game *game, Direction direction) { player->y += dy; } - player->wx = game->map_level->x * T_WIDTH * PXSIZE + player->x; - player->wy = game->map_level->y * T_HEIGHT * PXSIZE + player->y; - /* Check if we should change map */ Map *target = map_get_for_tile(game, game->map_level->x + player->x / T_WIDTH +