A Barrier, Pressure Switch and a SpikeTrap
Development Update
I wanted to update on how motivated I am working on this project. I love the idea of the game, sharing info about it and challenging myself with new things. This is hitting all the boxes for me, and I am excited with the progress that is made with each blog post. Well without wasting any more time, here is what was worked on since the last post. Enjoy!
Barrier
I added a barrier in the game to act as a type of door. This barrier cannot be opened with a key and must be opened with a switch. There is basically no code for this object other than adding this on the grid cell position as an unwalkable cell. The barrier is being detected by the cell it is placed on, and that cell will add that barrier to the unwalkable list. The art I made for the barrier is below.
Pressure Switch
This is a switch that will disable objects that it is connected with. I made the script flexible to add multiple objects to the switch just in case a level may need multiple items to be disabled. The switch has a collider that is set up as a trigger to detect if the player has entered the trigger. If the player enters the trigger, it will turn the collider off, and change the sprite to inactive so there is a visual that the switch has been changed.
Below are two variations of pressure switches that I drew for a on and off state. Also, below is an image of what the pressure switch script looks like in the inspector as well as a code sample of how I am detecting the player and handling changes to objects. As you can see the “Objects to Disable” is able to add many different objects to that list to be disabled when the switch has been triggered.
Spike Trap
This is a hazard that is a trap that will toggle for a given amount of time between spikes visible and hidden. When the spikes are hidden, the player can pass across the cell safely. If the spikes are visible, then the player will take damage. I wanted this hazard to give some challenge during play when traversing the zones. Below I have some images showing the art I drew for the trap, how it looks in the inspector to adjust values for balancing purposes, and a code sample on how I am handling the change from spikes hidden and shown.
Bug Fixing
As always, when I am adding new content in my game, I try and fix some bugs. I worked on the player movement to allow the player to move a certain number of cells in a direction. The main purpose of the game is to be like frogger with puzzles added in, so making the player move 2 cells in a direction or even 3 cells in a direction will add to the challenge.
I also fixed a bug where a certain number of cells are being checked in a direction before the player moves. This check is looking for unwalkable cells only. Doors, obstacles, and barriers are considered unwalkable. I also have a check if the cell in that path is a door, check for a key in the players inventory, and if there’s a key, unlock the door but do not move the player.
Conclusion
I enjoyed the challenge of how I am handling the player movement in the game. It was rewarding to finally be able to detect each cell in a direction, check if any of the cells are unwalkable and if it is a door (unlock the door if the player has a key), and not move the player if that is the case. I spent a couple days to a week figuring out how to get this working the way I wanted it to, and I am really satisfied with the results of my hard work!
What’s Next?
So, what’s next? Here is a sneak peek of what I am working on next…. Level Design, Yay!!
I have my planned zones and what mechanic will be introduced in each zone already made, but I currently do not have the layout of the levels made. I will talk more about it in my next blog post! I hope that was a good sneak peek and an enjoyable read! Until next time, have a nice day!