In today’s blog I will be giving Mario fireballs with the fire flower I will be adding to the game. With this Mario will be able to kill all the enemies including spiked enemies and koopas.
But without further ado lets get started
`To start we will have to add a question block that contains our fire flower. I chose the middle bottom block like this.
Now that we have that code Mario will not get a coin from this block and instead he will spawn a fire flower. Now that our fire flower can actually spawn we will need to give it some code. We’ll start with this piece
Once the flower collides with our cPlayer it will play the power up sound set Mario’s powered up variable to true and then it will wait 0.5 seconds and destroy itself. Now once we have Mario’s powered up variable set as true it means he will have the ability to shoot fireballs once we add a little bit more code. Our next step is to tell our fireball what to do. Although this may seem a little bit premature but we need to understand how our fireball will work and to do so we need to have an idea of how it will work once it is spawned. So now we know that it will spawn and then be deleted after 1.75 seconds.
Now we need to add the code to spawn it.
Now just as always we need to add events before we add actions so our first one will be on space key pressed and then to make sure that we don’t cheat and spawn any fireballs before we should be able to we need to ensure that powered up is true. And the only way powered up can be true is if we collect our fire flower power up. Now we need to add a subevent which will be is mirrored and then we can start adding events.
Our first event will be spawn a fireball on our game layer and we need to set the fireballs bullet angle to 180 degrees so that it spins then we set powered up to false we wait 0.5 seconds and then set it to true.
And it should look something like this:
Now this is good but we still need to make it so that it looks like this when our game is mirrored as well otherwise it will look strange. To do that we will use this code.
So with this we will simply add another is mirrored and invert it using the “i” key also make sure when using this only have the actual aevnet selected like this
otherwise the “i” key wont do anything. But now lets start with the code, it’s pretty simple as we just need to spawn our fireball on our game layer next we need to set poweredup to false wait 0.2 seconds and set it to true.And then when we face the other direction our fireball should look like this.
And with that our code for today is done and ourfireaball and fireflower are looking great.
Thanks for reading this blog and be sure to check out my Yt channel @Drago Gaming Link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg?view_as=subscriber
And thanks to Raymond Roque and Gamegen for help with this project without them this wouldn’t have been possible.