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

Maze Environment Loading From File #66

Merged
merged 8 commits into from
May 6, 2024
Merged

Maze Environment Loading From File #66

merged 8 commits into from
May 6, 2024

Conversation

gilkeidar
Copy link
Contributor

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 calls loadMaze() which opens the maze file for reading and intializes the ServerGameState's Grid instance which encapsulates a 2-D vector of GridCells, each of which corresponds to a character in the input maze file.

After the Grid is initialized in loadMaze(), loadMaze() iterates over all of the GridCells and places SolidSurface objects for each wall in the maze as well as a floor and ceiling SolidSurface that cover the entire maze.

@gilkeidar gilkeidar self-assigned this May 1, 2024
@gilkeidar gilkeidar added enhancement New feature or request Gameplay i love gameeing labels May 1, 2024
Copy link
Contributor

@jhparkt jhparkt left a 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.

Copy link
Contributor

@atar13 atar13 left a 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.

#define MAX_NUM_BASE_OBJECTS 100
/* Maze Constants */
#define MAZE_DIRECTORY "maps"
#define DEFAULT_MAZE_FILE "tyler_test.maze"
Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

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!

Comment on lines 224 to 227
std::cout << "shared object " << i << ": position: " << glm::to_string(sharedObject->physics.position) << std::endl;

if (sharedObject == nullptr)
continue;
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@gilkeidar gilkeidar merged commit 8de1426 into dev May 6, 2024
9 of 11 checks passed
@Tyler-Lentz Tyler-Lentz deleted the feat/environment branch May 10, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Gameplay i love gameeing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants