-
Notifications
You must be signed in to change notification settings - Fork 0
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
Maze Environment Loading From File #66
Conversation
…are stored in the `maps` directory)
…made the grid cell width a bit larger
… 2x2x2) and pulled new dev contents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great on my end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really love this idea and how it'll help use iterate quickly and try different maps out. The ASCII representation is very descriptive yet elegant and I'm looking forward to seeing what we can do with it.
include/server/game/constants.hpp
Outdated
#define MAX_NUM_BASE_OBJECTS 100 | ||
/* Maze Constants */ | ||
#define MAZE_DIRECTORY "maps" | ||
#define DEFAULT_MAZE_FILE "tyler_test.maze" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be nice to move into our config.json
at the root of the repo with the other server setup stuff so that we don't have to recompile the server when the map changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to reflect this - please let me know if it works well on your end and if the new code looks alright!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great on my end! Able to change maps without recompiling. Thanks for adding this feature!
src/client/client.cpp
Outdated
std::cout << "shared object " << i << ": position: " << glm::to_string(sharedObject->physics.position) << std::endl; | ||
|
||
if (sharedObject == nullptr) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: if we want to keep this position printout, maybe move to after checking if sharedObject == nullptr
just in case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
…can be changed without server recompilation
I have implemented an initial version of loading of a maze environment from a file.
Maze files are assumed to be in the
maps
directory.Maze files may only contain the characters
.
,@
, or#
(and new-lines and EOFs); each row must have the same number of columns.The
ServerGameState
constructors now call one of the constructors which callsloadMaze()
which opens the maze file for reading and intializes theServerGameState
'sGrid
instance which encapsulates a 2-D vector ofGridCell
s, each of which corresponds to a character in the input maze file.After the
Grid
is initialized inloadMaze()
,loadMaze()
iterates over all of theGridCell
s and placesSolidSurface
objects for each wall in the maze as well as a floor and ceilingSolidSurface
that cover the entire maze.