Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development 4 map #16

Open
wants to merge 65 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ff53af4
Created Map.h
MicheleMichetti Feb 16, 2024
58e9e9f
Created Map.cpp
MicheleMichetti Feb 16, 2024
6a0ad5f
Created test for Map
MicheleMichetti Feb 16, 2024
8ce95b8
Added Map.h and Map.cpp
MicheleMichetti Feb 16, 2024
f238951
Added destructor and included Tile.h
MicheleMichetti Feb 17, 2024
8d2e6f1
populated destructor, doesItCollide, doesItInteract
MicheleMichetti Feb 17, 2024
09b2ef2
Imported prototype test map definition.
MicheleMichetti Feb 17, 2024
10ca6b4
doc: Update README.md
MicheleMichetti Feb 16, 2024
07ccf18
Update README.md
marc-gav Feb 17, 2024
3f9de8a
doc: Update README.md
marc-gav Feb 17, 2024
1e3bc7e
doc: Update README.md
marc-gav Feb 17, 2024
8e97c0a
feat: Pull request template
marc-gav Feb 17, 2024
71175ed
feat: Update PULL_REQUEST_TEMPLATE.md
marc-gav Feb 17, 2024
9386af1
switched tiles_ from std::map to boost::multi_array.
MicheleMichetti Feb 17, 2024
6a477ca
feat: Tile class basic structure
marc-gav Feb 16, 2024
06f8d35
feat: Update gitignore
marc-gav Feb 16, 2024
79b3916
feat: Tile class logic
marc-gav Feb 16, 2024
783473f
feat: Include coordinate into Tile class
marc-gav Feb 16, 2024
1023daa
refactor: Coordinate not needed for tile
marc-gav Feb 17, 2024
9735180
fix: Direction enum utils.hpp
marc-gav Feb 17, 2024
72fc2ec
feat: Skeleton of testing capabilities
marc-gav Feb 17, 2024
be446c3
feat: Testing skeleton
marc-gav Feb 17, 2024
f933a28
fix: Add execution permissions for build_docker_image.sh
marc-gav Feb 17, 2024
1a3f584
feat: Update gitignore
marc-gav Feb 17, 2024
11f5d0b
feat: Add google test library
marc-gav Feb 17, 2024
3f9603f
feat: Add Json reader
marc-gav Feb 17, 2024
58e2801
feat: CMakeLists.txt new hierarchy
marc-gav Feb 17, 2024
230fc77
refactor: Re-organize code structure
marc-gav Feb 17, 2024
6088184
feat: Dummy unit test
marc-gav Feb 17, 2024
ec0bdd9
feat: Interactive docker image scripts
marc-gav Feb 17, 2024
2822060
feat: Automated tests using github actions
marc-gav Feb 17, 2024
0e49c1c
doc: New simplified Docker instructions
marc-gav Feb 17, 2024
a7a3ace
breaking: Test failed testing pipeline behaviour
marc-gav Feb 17, 2024
cdb2030
fix: Fix breaking change
marc-gav Feb 17, 2024
74310c5
fix: Update CMakeLists.txt
marc-gav Feb 17, 2024
b2de58e
doc: Update README.md
marc-gav Feb 17, 2024
2659a5c
doc: Update README.md
marc-gav Feb 17, 2024
76565c9
fix: Incorporate PR comments
marc-gav Feb 17, 2024
6b2c26b
feat: Auto-formatter
marc-gav Feb 17, 2024
686f113
feat: Update clang formatter with current code structure
marc-gav Feb 17, 2024
884638a
fix: Clang formatter list of files
marc-gav Feb 17, 2024
9755ed2
feat: Nice clang-format workflow
marc-gav Feb 17, 2024
5306a8b
feat: Improve clang-format.yml
marc-gav Feb 17, 2024
02d002d
Refactor .h -> .hpp and correct typos
MicheleMichetti Feb 18, 2024
f5ba44b
Correction in Map.cpp->swapTiles()
MicheleMichetti Feb 18, 2024
e89a375
Merge branch 'develop' into development-4-Map
MicheleMichetti Feb 18, 2024
9a3ae73
Fixed includes
MicheleMichetti Feb 18, 2024
0d0a406
Merge branch 'develop' into development-4-Map
marc-gav Feb 18, 2024
da9e23c
Autoformat code
marc-gav Feb 18, 2024
970bc66
Moved hpp and cpp in the new structure. Updated dependencies.
MicheleMichetti Feb 18, 2024
983abbd
Install boost lib in docker and include in CMakeLists. Not in a worki…
MicheleMichetti Feb 18, 2024
2826648
Autoformat code
MicheleMichetti Feb 18, 2024
bb09edc
Use consistent variable format "my_variable"
MicheleMichetti Feb 18, 2024
5aa42de
Using consistent member name format "my_member"
MicheleMichetti Feb 18, 2024
23904ce
Autoformat code
MicheleMichetti Feb 18, 2024
0aed526
fix: Find Boost library CMakeLists.txt
marc-gav Feb 18, 2024
fd45343
feat: install spdlog to Docker container and include it in CMake.
MicheleMichetti Feb 18, 2024
3d0d8c2
feat: Added tile matrix of dimension 0 error. Made some variables for…
MicheleMichetti Feb 18, 2024
a06f53d
fix: changed the argument type of the functions Tile::isCollision and…
MicheleMichetti Feb 18, 2024
140381e
fix: changed the argument type of the functions Map::doesItCollide an…
MicheleMichetti Feb 18, 2024
cb7268c
fix: fixed passage of coordinates to collision and interaction functions
MicheleMichetti Feb 18, 2024
6e7fbfa
fix: swapTiles() in Map class coherence between cpp and hpp
MicheleMichetti Feb 18, 2024
026a9d5
Added map type enum. Throw invalid_argument. Use std::swap
MicheleMichetti Mar 9, 2024
38b83be
Autoformat code
MicheleMichetti Mar 9, 2024
f94d728
Merge branch 'develop' into development-4-Map
MicheleMichetti Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions game/include/Map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>

using tileArray = boost::multi_array<Tile, 2>;
using entityMap = std::map<uint32_t, entity::Entity>;
using entityMap = std::map<uint32_t, Entity>;

class Map {
private:
Expand All @@ -20,15 +20,15 @@ class Map {

public:
Map();
Map(const uint16_t& id, const uint8_t& current_type, const std::string& map_name, const std::string& bitmap_name, const tileArray& tiles, const uint16_t& dimensionX, const uint16_t& dimensionY,
Map(const uint16_t& id, const uint8_t& current_type, const std::string& map_name, const std::string& bitmap_name, const tileArray& tiles, const uint16_t& length_x, const uint16_t& length_y,
const entityMap& entities);
~Map();

void setId(const uint16_t& id);
void setCurrentType(const uint8_t& current_type);
void setMapName(const std::string& map_name);
void setBitmapName(const std::string& bitmap_name);
void setTiles(const tileArray tiles, const uint16_t& dimensionX, const uint16_t& dimensionY);
void setTiles(const tileArray tiles, const uint16_t& length_x, const uint16_t& length_y);
void setEntities(const entityMap& entities);
void setTile(const utils::Coordinate& coordinate, const Tile& tile);

Expand All @@ -39,7 +39,7 @@ class Map {
const tileArray getTiles();
const entityMap getEntities();

void swapTiles(Tile tile1, Tile Tile2);
void swapTiles(Tile tile_1, Tile tile_2);

bool doesItCollide(const tils::Coordinate& coordinate, const uint8_t& direction);
bool doesItInteract(const utils::Coordinate& coordinate, const uint8_t& direction);
Expand Down
22 changes: 13 additions & 9 deletions game/src/Map.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#include <Map.hpp>

Map::Map(const uint16_t& id, const uint8_t& current_type, const std::string& map_name, const std::string& bitmap_name, const tileArray& tiles, const uint16_t& dimensionX, const uint16_t& dimensionY,
#include "spdlog/spdlog.h"

Map::Map(const uint16_t& id, const uint8_t& current_type, const std::string& map_name, const std::string& bitmap_name, const tileArray& tiles, const uint16_t& length_x, const uint16_t& length_y,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create an enum of possible map types

const entityMap& entities) {
setId(id);
setCurrentType(current_type);
setMapName(map_name);
setBitmapName(bitmap_name);
setTiles(tiles, dimensionX, dimensionY);
setTiles(tiles, length_x, length_y);
setEntities(entities);
}

Expand All @@ -16,11 +18,13 @@ 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::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& dimensionX, const uint16_t& dimensionY) {
if (dimensionX == 0 || dimensionY == 0) {
void Map::setTiles(const tileArray& tiles, const uint16_t& length_x, const uint16_t& length_y) {
if (length_x == 0 || length_y == 0) {
SPDLOG_ERROR("The tile matrix that is being set has a dimension of value 0. Exiting. ");
throw;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
}
tiles_.resize(boost::extents[dimensionX][dimensionY]);
tiles_.resize(boost::extents[length_x][length_y]);
this->tiles_ = tiles;
}
void Map::setEntities(const entityMap& entities) { this->entities_ = entities; }
Expand All @@ -33,10 +37,10 @@ const std::string Map::getBitmapName() { return bitmap_name_; }
const tileArray Map::getTiles() { return tiles_; }
const entityMap Map::getEntities() { return entities_; }

void Map::swapTiles(Tile& tile1, Tile& tile2) {
Tile tiletmp = tile1;
tile1 = tile2;
tile2 = tiletmp;
void Map::swapTiles(Tile& tile_1, Tile& tile_2) {
Tile tiletmp = tile_1;
tile_1 = tile_2;
tile_2 = tiletmp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Tile tiletmp = tile_1;
tile_1 = tile_2;
tile_2 = tiletmp;
std::swap(tile_1, tile_2);

}

bool Map::doesItCollide(const utils::Coordinate& coordinate, const uint8_t& direction) {
Expand Down
Loading