In this blog we will be adding a Mushroom power up and question blocks with mystery rewards. So let’s get started.
We will first start with our mushroom code
So first we will see if the mushroom is mirrored and if so then we will have it move right. So now our mushroom will move once it is spawned in but that movement will not happen quite yet as he is not being spawned in yet.
Now we see if the mushroom is un-mirrored then we will make it go left. After this we will add a sub event which checks and sees if the mushroom is stopped and if so it checks if it is mirrored. If it is mirrored it will set it non mirrored and go the other way. And if it is not mirrored it will become mirrored and move the other way. But I think I mentioned this in an earlier blog do not add another line of code after “Mushroom is mirrored” Simply hit “x” on your keyboard while clicking on mushroom is mirrored code. Then add the set mirrored code instead of wasting time doing it manually.
But before we can show what the mushroom would look like moving we first have to spawn it and to do this we will add question block code. Which will allow us to spawn not only more coins but also a Mushroom power up.
So lets get started.
To start we will add a collision detection between our cPlayer and the question block. But we don’t want it to break just on contact with the question block we have to make sure it only happens when Mario hits it with his head when he jumps. The next condition is slightly weird but it will make more sense a little bit later but it is “animation used not playing” this ensures that you can only hit each question block once. Now we will add our first sub condition which is question block type = coin. Next we will spawn a coin on our question block and then we reuse the coin code from yesterdays blog which I don’t think I’ll repeat as I talked about yesterday in depth so if you haven’t read that blog check it out.
But here’s where it gets interesting now we need to add another sub event to our main set of events and this will check if the type of question block is mushroom and there is one in the center at the top.
And once it Mario collides with the middle top question block the mushroom will start moving as soon as it is spawned. It should look like this
Thats gonna be it for this blog thank you all for reading I hope you enjoyed check out my YT channel @Drago Gaming link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg?view_as=subscriber