Spikes, Spike Balls, Ect. Playdate Pulp
This is my final blog post on my Playdate Pulp game. This finishes the game by looking at all of the small things that made the game more interesting. So first we had the spike ball which was a ball with spikes on the edge. They will continue in a straight line until they hit a wall in then they switch directions. For this, you need four different spike balls that each go one way. Now for the code.
You first get its X and Y coordinates then depending on which way it’s going plus or minus one of its X and Y. This tells us what block it’s going to go to next. Now we need to make sure when it hits a wall it will go the other way instead of going into the wall. To do this create a variable called solid block then make it equal to solid and then the spike balls next X and Y’s. What this does is it will return 1 if the target is solid and 0 if it is not solid. Now we create an if event saying that if solid target is equal to one then swap for the variable spike ball to the opposite spike ball so if it’s spike ball up the variable changes to spike ball down. Now it’s time to move the spike ball since the next block is not solid. First, tell it to swap white then tell the X and Y variables to swap spike balls which makes sure if the next block is solid we swap to the other spike ball. The last thing to do is make sure the spike ball damages the player. To do this whenever the spike ball moves check if its X and Y’s are equal to the player if yes damage the player. You can also have it so that when the player moves it can check if the X and Ys are equal if you want to make it so the player can’t move onto the spike balls without getting damaged. Next is the spikes.
The Spikes are a very simple thing to code. All you have to do is to make two designs one of the spikes retracted and one of the spikes protracted. Once done just tell it that whenever it updates swap to the other spike, so if the spikes are retracted it will protract the spike. The only other thing is that you need to do damage. To do this just make an emit every time your player moves then on this emit the spikes will check if they are protracted and then if the players X and Y are equal to it. If so deal damage otherwise do nothing. Next is potions.
The potions are just a simple way to heal. I made them heal two hearts but you can do however many you want. I had it so when you pick up the potions it will ask you if you want to store it, or if you want to use it right then. If you store it you just add one to a variable then when you open storage and use it minus one from the variable. If they choose to use i then just tell health to plus 4 and you’re good. Our next thing is jump pads and Pressure Plates.
The pressure plates & jump pads. You can use these in a lot of different ways. I made the pressure plate be something that you step on and then a single block will change maybe revealing a path or something. I did this by having a blockX and blockY variable then if it is being used the level script will change the variable. Then when it is stepped on it tells those two variables to swap to white. The jump pad makes the player jump over a certain block. I did this by having two other variables that a levels script will change then on collect it uses the goto function will tell the player to go to a certain place. The final mechanic is turrets and their projectiles.
Thank you for looking at all of my posts. I hope this has helped you or you enjoyed reading.