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 13 commits
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
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Doneness checkbox:
- [ ] Testing
- [ ] Documentation
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ add_library(
target_include_directories(pokemon-lib PUBLIC include)
target_include_directories(pokemon-lib PUBLIC ${JSONCPP_INCLUDE_DIRS})

add_library(
include/Map.h
src/Map.cpp
)

add_executable(pokemon src/main.cpp)

target_link_libraries(pokemon PRIVATE ${JSONCPP_LIBRARIES})
Expand Down
19 changes: 12 additions & 7 deletions Docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Docker

Our development philosophy with Docker is the following.
In this project we will use docker to compile, test and run our game. It would be quite helpful to quickly check a [guide like on Docker](https://phoenixnap.com/kb/docker-image-vs-container). In this `Readme`, we explain the different steps we take to run our code inside a Docker container.

### Quick overview
1. Building Docker image with the project dependencies
2. Development mode: Opening a shell inside the container.
3. Test mode

### Details

1. We build an image that contains all the necessary dependencies to compile the application. This image only needs to be created once as long as the dependencies do not change (very rarely). **This step does not compile the game**.
- Linux and MacOS:
Expand All @@ -10,11 +17,9 @@ Our development philosophy with Docker is the following.
- Windows:

```$ .\Docker\windows\build_docker_image.bat```
The image that contains the `Ubuntu-latest` environment for our application is created at this point. You can double check by running the command `$ docker images`.

2. docker run -it "pokemon-container"

At this point we have created an Docker image based on `Ubuntu-latest`. You can double check by executing `$ docker images` and hopefully find that a container called `pokemon-image`.

3. Next question you should be asking yourself is: What about the source code and the compilation? The folder `Re-Pokemon-Red/Testing` will contain a script for each test that will do `docker run ...`
2. From the root directory of our project run `$ docker run -it -v .:/pokemon_game "pokemon-image"`. This will run the docker image `"pokemon-image"` with the source code included as a [mounted volume](https://docs.docker.com/storage/volumes/). Inside this docker image you can manually compile the project as usual with: `mkdir build; cd build; cmake ..; make;`. Note: While you are developing, you can keep this shell open. Since your local machine files are synched with the docker's image thanks to `-v .:/pokemon_game`. The most comfortable workflow should be: `Write changes locally, run make in the docker image, run the program, repeat`

Step two will be much more frequent during the development process since it will be called each time we want to test our new code.
3.
3. Test mode: TBD
30 changes: 30 additions & 0 deletions include/Map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "Tile.h"

#include <iostream>
#include <string>
#include <vector>

using tileStdMap = std::map<std::pair,tile::Tile>;
using entityStdMap = std::map<uint32_t,entity::Entity>;

class Map {
private:
uint16_t id_;
uint8_t currentType_;
std::string mapName_;
std::string bitmapName_;
tileStdMap tiles_; //<Coordinates,tile>
entityStdMap entities_;// Map<entityId, Entity>

public:

Map();
~Map();
Map(uint16_t id, uint8_t currentType, std::string mapName, std::string bitmapName, tileStdMap tiles, entityStdMap entities);

bool doesItCollide(uint16_t desiredX, uint16_t desiredY, uint8_t direction);
bool doesItInteract(uint16_t desiredX, uint16_t desiredY, uint8_t direction);

}
29 changes: 29 additions & 0 deletions src/Map.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "Map.h"

Map::Map(uint16_t id, uint8_t currentType, std::string mapName, std::string bitmapName, tileStdMap tiles, entityStdMap entities) {
id_ = id;
currentType_ = currentType;
mapName_ = mapName;
bitmapName_ = bitmapName;
tiles_ = tiles;
entities_ = entities;

}

Map::~Map() {
tiles_.clear();
entities_.clear();

}

bool Map::doesItCollide(uint16_t desiredX, uint16_t desiredY, uint8_t direction) {
tile::Tile tile = tiles_.at( std::pair<uint16_t,uint16_t> (desiredX, desiredY) );
return tile.isCollision(direction);

}

bool Map::doesItInteract(uint16_t desiredX, uint16_t desiredY, uint8_t direction) {
tile::Tile tile = tiles_.at( std::pair<uint16_t,uint16_t> (desiredX, desiredY) );
return tile.isInteraction(direction);

}
38 changes: 38 additions & 0 deletions test/MapTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "Map.h"

int main() {
std::cout<<"hello Map"<<std::endl;

std::vector<short int> testVectorMap1 = { 9, 9, 9, 9, 9, 9, 9, 9, 9};
std::vector<short int> testVectorMap2 = { 9, 0, 0, 0, 0, 0, 0, 0, 100};
std::vector<short int> testVectorMap3 = { 9, 0, 0, 0, 0, 0, 0, 0, 9};
std::vector<short int> testVectorMap4 = { 9, 0, 0, 0, 0, 0, 9, -1, 9};
std::vector<short int> testVectorMap5 = { 9, 0, 0, 0, 0, 0, 9, 9, 9};
std::vector<short int> testVectorMap6 = { 9, 0, 0, 0, 0, 0, 0, 0, 9};
std::vector<short int> testVectorMap7 = { 9, 0, 0, 0, 100, 9, 0, 0, 9};
std::vector<short int> testVectorMap8 = { 9, 0, 0, 0, 0, 0, 0, 100, 9};
std::vector<short int> testVectorMap9 = { 9, 0, 0, 0, 0, 0, 0, 100, 9};
std::vector<short int> testVectorMap10 = { 9, 0, 0, 0, 0, 0, 0, 9, 9};
std::vector<short int> testVectorMap11 = { 9, 0, 0, 100, 100, 0, 0, 9, 9};
std::vector<short int> testVectorMap12 = { 9, 0, 0, 0, 0, 0, 0, 100, 9};
std::vector<short int> testVectorMap13 = { 9, 9, 9, 9, 9, 9, 9, 9, 9};

std::vector<std::vector<short int>> testVectorMap;

testVectorMap.push_back(testVectorMap1);
testVectorMap.push_back(testVectorMap2);
testVectorMap.push_back(testVectorMap3);
testVectorMap.push_back(testVectorMap4);
testVectorMap.push_back(testVectorMap5);
testVectorMap.push_back(testVectorMap6);
testVectorMap.push_back(testVectorMap7);
testVectorMap.push_back(testVectorMap8);
testVectorMap.push_back(testVectorMap9);
testVectorMap.push_back(testVectorMap10);
testVectorMap.push_back(testVectorMap11);
testVectorMap.push_back(testVectorMap12);
testVectorMap.push_back(testVectorMap13);

Map testMap(testVectorMap, "testMap");

}