Travelling Across The Map
Hey there, fellow indie game developers! In this devlog, I'll go over moving on the map using the method from my previous text adventures and the challenges that arose from trying to apply an abstract movement method to a concrete map and how I solved them.
In my Epic Prose games, I handled movement differently than other text adventures I've seen. Instead of having a 2D grid for a map, I wanted moving across the map to be more abstract. I didn't have a game map so locations were just arbitrary points stored in a Location class along with a description. Typing in your destination would cause the player to move from their current location towards the new location, moving in increments based on the player's speed. I use a loop to continuously move the player towards their destination in increments. The amount of each increment is determined by the player's speed. The loop checks the distance between the player's current position and their destination, and continues looping until that distance is less than 1.
During each iteration of the loop, I print out a message indicating that the player is travelling, with some animated dots. I then use the MoveTowards method to move the player's position towards their destination, using the same value as before. After each movement, I print out the distance between the player's current position and their destination, so the player can see how far they have left to go. If the player presses a key while travelling, the loop will break and the game will print a message indicating that they have stopped.
Once the player has reached their destination (i.e., the distance between their position and their destination is less than 1), the loop breaks and the game prints a message indicating that they have arrived. I then adjust the player's position by dividing it by the map's scale, effectively "zooming out" the value to its original, smaller-scale value.
So, after implementing a basic map movement system in my game, I realized that it wasn't quite working as intended. Since my game's map is laid out as a 2D array with landmarks placed at specific locations, the distances between those locations were relatively small and all integers. As a result, when I tried to move the player incrementally towards their destination, they were effectively just jumping directly to that destination in one step. This wasn't the experience I was going for, so I needed to come up with a solution.
After some brainstorming, I realized that I could use scaling to make the distances between landmarks longer, which would allow for the incremental movement that I wanted. So, I implemented a "scale" variable in my game's map class that would multiply all the distances between landmarks by a chosen factor. Implementing this solution was a bit challenging, but through trial and error, I came up with a working solution! With the scale implemented, I then had to adjust my movement code to take it into account. In the code snippet provided, I retrieve the player's current position and their destination from the world object, and then multiply both values by the map's scale. This effectively "zooms in" on the smaller-scale values and makes them larger and more granular. Once the player has reached their destination, I adjust the player's position by dividing it by the map's scale, effectively "zooming out" the value to its original, smaller-scale value.
Overall, adding the movement went pretty well and I'm very happy with the results. Now that the player can move around the map, all I need to add is the random encounters and entering the towns, temples, and dungeons, then all the world map systems will be complete!
Endless Prose
The long awaited 3rd addition to the Epic Prose series!
Status | In development |
Author | logicandchaos |
Genre | Role Playing |
Tags | Text based |
More posts
- Finishing the LibraryApr 05, 2024
- Text Adventure Library - Builder PatternMar 27, 2024
- Text Adventure Library - Slaying the Spaghetti Monster!Nov 22, 2023
- From Prototype to ProductionSep 25, 2023
- Redesign!Jul 22, 2023
- Improving the Name Generator using ChatGPTApr 20, 2023
- Creatures & Encounters!Mar 30, 2023
- Exploring DungeonsMar 13, 2023
Leave a comment
Log in with itch.io to leave a comment.