Skip to content

Commit

Permalink
fix: fixed passage of coordinates to collision and interaction functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleMichetti committed Feb 18, 2024
1 parent 140381e commit cb7268c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions game/include/Map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Map {
void setBitmapName(const std::string& bitmap_name);
void setTiles(const tileArray tiles, const uint16_t& length_x, const uint16_t& length_y);
void setEntities(const entityMap& entities);
void setTile(const uint8_t& coordinate, const Tile& tile);
void setTile(const utils::Coordinate& coordinate, const Tile& tile);

const uint16_t getId();
const uint8_t getCurrentType();
Expand All @@ -41,8 +41,8 @@ class Map {

void swapTiles(Tile tile_1, Tile tile_2);

bool doesItCollide(const uint8_t& coordinate, const uint8_t& direction);
bool doesItInteract(const uint8_t& coordinate, const uint8_t& direction);
bool doesItCollide(const utils::Coordinate& coordinate, const uint8_t& direction);
bool doesItInteract(const utils::Coordinate& coordinate, const uint8_t& direction);
bool isPokemonBattleTriggered();
bool isTrainerBattleTriggered();
}
4 changes: 2 additions & 2 deletions game/include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace utils {
struct Coordinate {
int x;
int y;
int16_t x;
int16_t y;
};

typedef enum Direction : uint8_t {
Expand Down
8 changes: 4 additions & 4 deletions game/src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Map::Map(const uint16_t& id, const uint8_t& current_type, const std::string& map
Map::~Map() {}

void Map::setId(const uint16_t& id) { this->id_ = id; }
void Map::setcurrentType(const uint8_t& current_type) { this->current_type_ = current_type; }
void Map::setCurrentType(const uint8_t& current_type) { this->current_type_ = current_type; }
void Map::setMapName(const std::string& map_name) { this->map_name_ = map_name; }
void Map::setBitmapName(const std::string& bitmap_name) { this->bitmap_name_ = bitmap_name; }
void Map::setTiles(const tileArray& tiles, const uint16_t& length_x, const uint16_t& length_y) {
Expand All @@ -28,7 +28,7 @@ void Map::setTiles(const tileArray& tiles, const uint16_t& length_x, const uint1
this->tiles_ = tiles;
}
void Map::setEntities(const entityMap& entities) { this->entities_ = entities; }
void Map::setTile(const uint8_t& coordinate, const Tile& tile) { tiles_[coordinate.x][coordinate.y] = tile; }
void Map::setTile(const utils::Coordinate& coordinate, const Tile& tile) { tiles_[coordinate.x][coordinate.y] = tile; }

const uint16_t Map::getId() { return id_; }
const uint8_t Map::getCurrentType() { return current_type_; }
Expand All @@ -43,12 +43,12 @@ void Map::swapTiles(Tile& tile_1, Tile& tile_2) {
tile_2 = tiletmp;
}

bool Map::doesItCollide(const uint8_t& coordinate, const uint8_t& direction) {
bool Map::doesItCollide(const utils::Coordinate& coordinate, const uint8_t& direction) {
Tile tile = tiles_[coordinate.x][coordinate.y];
return tile.isCollision(direction);
}

bool Map::doesItInteract(const uint8_t& coordinate, const uint8_t& direction) {
bool Map::doesItInteract(const utils::Coordinate& coordinate, const uint8_t& direction) {
Tile tile = tiles_[coordinate.x][coordinate.y];
return tile.isInteraction(direction);
}

0 comments on commit cb7268c

Please sign in to comment.