Coding Fire Mario | SMB in Scratch E19

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello fellow scratchers it's fire flower time yes i'm griff patch and welcome to another episode of our tile scrolling series i know a lot of you have been very excited for this one as we introduce yet another awesome mario power-up adding fireball projectiles adds yet another dimension to the game i know you guys will be creating amazing things with this though we'll start with adding the fire mario costume set and then the collectible power adding it to the level designer then we'll script the new projectile itself before finally battling with the collision detection code to make sure it all works perfectly wow there's quite a lot to cover don't forget that i shared the completed episode 16 project it's linked under the video if you need a hand catching up but otherwise hold on tight and let's get scratching so we'll start by picking up those shiny new costumes and sounds head over to the updated tile scrolling asset project and there's a link under the video or find it on my grip patch tutor account as normal jumping into the mario sprite costume 20 onwards contains the fun new fire mario costumes since there's quite a number of these i'd advise you simply drag the entire mario sprite into your backpack like me next up check out the enemy sprite there's just a single new costume in here costume 34 it's the fire flower powerup itself so we might as well just backpack this single costume and lastly the sound sprite we have four new sounds it took me a while to find these but they are going to make a lot of difference if you're making a mario game i'll play them back to you in a second but for now you can either backpack the four sounds individually or drop the entire sprite like me into your backpack might be a little slow as there's a large soundtrack in here to be copied great so open up your tile scrolling episode 18 projects and as we begin do make sure to save your projects as a copy we don't want to lose our hard work if things went wrong and name this episode 19. so fire mario has a new whole set of costumes so we'll begin there just drag out the backpacked mario sprite and one by one drag the new costumes to the original mario sprite starting at costume 20 i'd like to count them off as we go so 20 21 22 23 24 25 scroll of it and 26 27 28 29 and 30. then we are good to delete the mario 2 sprite since we are all up to date while we're copying resources let's also bring in the fire flower costume i can't wait to collect this we want to copy this into the enemy sprite carefully done these things are explosive and hey why not also drop one to the tile sprite that is required to let us place them into the level editor lastly we should bring in the new sounds we want to copy just the last four across into the existing sound sprite to bring that up to date too and remove the sound to sprite oh i promised i'd let you hear these so listen to these babies let's go oh mamma mia just what i needed oh no these will really help to complete the mario feel right many scratches noted their absence and well they were dead right so thanks for the nudge so the game begins with mini mario recapping on episode 18 you'll remember that we set up mario's costume names in such a way that each costume name begins with the costume set name and then is followed by an action like walk or crouch etcetera we already had the costume sets for mario and mini mario and now you'll find we have the costumes for fire mario using the same naming convention of fire this is excellent news as to switch into fire mario mode all we need to do is add a when f key pressed block at some point we can just delete this but it's just super useful for testing and then set the mario variable to the word fire with a capital f and hurrah i hope you enjoyed this video if you did then smash the like button and don't forget to subscribe okay okay i'm teasing we have so much more to cover but man i wish everything was as easy as changing costume sets it's a good lesson that making good use of variables can save you a lot of scripting like this mario variable to change costumes okay next up we will be adding the new collectible fire flower powerup it will work just like the mushroom power-up of course so let's begin by adding it to the level editor click into the tile sprite the new fire flower costume is costume number 70 so let's remember that and click into the editor sprite we need to assign a level editor key to this new costume so make the tile keymap list visible scroll down to the bottom and make sure we have a new row for that's right item 70 the fire flower we always map enemy sprites to the number nine key so do the same here just remember to click out of the row once you've typed that in but before the power up will appear we need to ensure the enemy sprite knows about it too so in the enemy sprite find the define spawn type custom block here is where we spawn the life powerup that is the mushroom we can duplicate this i did that using the new scratch add-ons control alt drag trick just loving that guys yeah and we'll check for that fire flower costume number 70. for starters just switch the costume of the spawn sprite by entering the word fire flower that's a capital f on fire and flower without a space as costumes are case sensitive pop that back into the main script and we are good to go so hit the zero key to enter the level editor and then cycle through the enemies with the nine key great here's the fire flower now where to put it just pop it in this mystery block under the goomba right press zero again to save it and i'm dead excited to see this work boing yes we are really crushing this now we have two power-ups to enjoy the only problem is they both act the same at the moment just like mushrooms we need the fire flower to turn us into fire mario we can do something about that right away click into the enemy's sprite and find the define tick life script this is the main processing script for the mushroom collectibles and here is where we check for its collection when touching mario ah right firstly the sound we're playing here is the wrong one click into the sound sprite and find the new just what i needed sound mine is sound number 27. just what i needed drag this into the enemy sprite now back in the enemy sprite we can switch it to play the sound when we collect a power up nice so we have two different power-ups to consider now we'll need an if else block and put in an and operator so when the root costume of the collected sprite is fire flower we want to switch it to fire mario but we also have to check whether mario variable equals mario because mini mario is not allowed to upgrade directly to fire mario then if both of these are true we set mario to fire with a capital f otherwise we want to upgrade to super mario after all so broadcast the collect one up lastly the delete this clone sits under the if else block as we want to delete the power up after it is collected and with that it's testing time smash the green flag and let's get ourselves a fire flower [Music] okay did you see that we changed from mini mario to super mario like i said we must upgrade to super mario first to get to become fire mario super mario and then fire mario yeah i do wish though that there was a bit more of a transition but this will do for now because we've got bigger fish to fry like what's the point of being fire mario if you can't fire fireball projectiles okay so this is the fun bit first off we need to detect a new controller key press we handle these in the control sprite wow it's been a while since we've been in here we have available for each type of control now on the snares and other consoles the fireball button is linked to the b button therefore make a new variable naming it button b for this sprite only now to save us extra work we'll process the key right here with an if else block check for the x key being pressed here the x key is often used to map to the snez's b key don't question it we want to be sure that we can distinguish the initial key press from the key just being held down so when the key is pressed use a change button b variable by one that will make the value increase as we hold the key down and then to counter this in the else we set button b to the empty value yes that's a set not a change that way when we release the key the value will be reset if i run the project you can see that working the button b value stays blank until that is we hold down the x key and then the value shoots up great this will be useful so fireballs click into the mario sprite mario can only fire two at a time find the define reset player script we'll make a new variable named fireballs for all sprites this will keep track of how many we have fired in the reset player script therefore set fireballs to zero now where are the other presses processed find the when i receive move player script handle keys left right jump and crouch there we go we need a new custom block handle keys fire run without screen refresh we'll make use of the block right away but do it at the end after the check around player great i'll just move the new define block into some free space before we get to work let's check for the b button if with an equals block and we compare using a button b of controls block from the sensing category that is comparing it to the value one remember this number counts up as it's held down so it will only be one for the moment it is first pressed we can only fire as fire mario if mario equals fire then and we can only fire if we are not already using our two fireballs if fireballs is less than two then yes we could use lots of and blocks here but i try to avoid using long lines of blocks in scratch i prefer nice neat narrow scripts so we're firing a new fireball we change fireball by one to record the new fireball we need the sound click into the sound sprite and find the tenth sound it's called fireball and drag it into the mario sprite then back in the mario sprite start sound fireball cool lastly i'm going to broadcast to trigger the launching of the fireball a new event then named mario fireball that'll do us okay so not a lot to test here yet but we can try it out pressing the x key should sound the fireball sound effect and we can only do it twice and then we've run out excellent so it's time to actually clone a new fireball sprite the question is how best to do it i'm in two minds and i don't know which idea is best option one is to reuse the enemy sprite now that may not sound like a good plan as mario's fireballs are not enemies and in fact only want to hurt other enemies not mario but if you think about the work we did with koopa shells only a couple of episodes ago then you'll remember how these are already primed for killing other enemies by using the enemy sprite again we could save ourselves a lot of other boilerplate coding that is all the sprite movement collision checks etcetera but option two is the more conventional route and that would be to create a new sprite for these projectiles that would be my preferred route if scratch was able to easily reuse our custom blocks between sprites but sadly this is not the case so a lot of script repetition would be needed i really don't like that so i'm going to plumb for option one we'll reuse the enemy sprite if you click into that now you'll find the flame costume already sitting at costume 15. so that's good start so in a clean space we can make use of the when i receive mario fireball that we just broadcast of course we must be careful not to run this event on all the enemy clones so check if type equals empty value all clones have the type variable set so this must be the original sprite then good we can spawn the fireball by setting type to fiber and then create a clone of myself do be careful to remember to set type back to the empty value afterwards otherwise the main sprite will be mistaken for a clone too and that would be really bad trust me okay we are on we've spawned a new clone but it's far from set up we handle this in the when i start as clone hat block can you find it firstly we want to be sure we are a fireball if type equals fireball then right we have lots of work to set this clone up but it will follow the same structure that we have used in the past try to keep up set root costume to flame capital f that's the name of our fireball costume then we can set costume to the same so we might as well use the root costume to simplify that next set the width and height to 8. the fireball is quite small so you may like to make this even smaller it doesn't affect the size of the sprite on the screen only how close it can get to the walls before it collides next up we position the sprite to appear from mario so setting x to the x value of mario make sure to use the x variable not the x position we do the same for y but hold on we should offset the fireball up a small amount so it appears from our hand so add 14. to allow the fireball to spin set rotation style to all around now what direction do we want the fireball to be thrown in if else and we can check for the direction of mario if greater than zero then we are facing right so set speed x to ten else we're facing left so set speed x to minus ten in mario fireballs always fire downwards we can replicate this by setting speed y to say -6 okay nearly there paint sprite will ensure the costume is set and the sprite positioned as soon as it's cloned ah set visible to two now this is interesting remember what this does a visible zero value means that the sprite is hidden one that it is currently showing but two that means it's always visible because it's a deadly enemy sprite one that kills other enemy sprites perfect we want that then lastly set frame to zero anything less is used for inactive enemies that have yet to come on screen right the clone is all set up we can test this i can switch to the fire mario with the f key and click b to fire a projectile there it is and yay it was super effective against the gumball right but well it's not really moving very fast is it i'm going to try one on the piranha plot oh yeah you are out of there so they feel more like landmines than fireballs and also it's a little off-putting that there's no sound when the enemy flips did you notice that we can quickly address that find the define flip custom block this is where an enemy is flipped by something the sound we want should be in the sound sprite it's called kick shell and is sound number 16. drag that into the enemy's sprite and we'll follow it back to the scripts start sound kick shell right at the top of that define block a quick test [Music] and that is sounding much better okay let's put this fireball into motion what we need is the define move enemy custom block and scroll right down to the end i'm going to duplicate the check for moving a cooper shell but we'll check now for a type of fireball now remove the tick cooper block we need new scripts for the fireball make a new custom block named tick fireball run without screen refresh now we'll use the block right away and don't forget to stop this script now in some free space we'll code up the fireball movement script we'll start with the fireball's spinning animation for this we want the sprite to rotate by 90 degrees but not every frame perhaps every third frame so change frame by 1 and check for frame being greater than 2. and then turn the sprite by 90 degrees before setting frame back to 0 ready to loop around again good next up we want to move the sprite in the x direction using our move movespritex block this takes care of the collision detection the movement and the resolution for us in fact we can give that test now and see it in action are you ready for this and press x oh yeah that is amazing it's like a fireball cannon that would make it far too easy though mario with a cannon but look we can still see the rotating fireballs have stopped dead as they impacted the level that was because the moving spritex block sets the speed x to zero when it touches a wall now that's no problem we in fact can use that check if speed x equals zero and if it does then we'll delete this clone but we need to be careful if we play the game you can see that the fireball does indeed now get deleted when we hit the wall but our fireballs variable has not gone down so once we fired both our fireballs we still can't fire anymore disaster well not really we just need to keep track of whether we delete a fireball clone take out the delete clone block and we'll make a new custom block name it delete clone and we'll use it in place of the original delete this clone block here now stuff in an if block before performing the actual delete this clone and all we need to do is check if type equals fireball then if it is we change fireballs by -1 super we can test this again watch to see the fireballs count go back down wonderful these hot flaming projectiles are really coming together our next step will be to get the fireballs bouncing around then to ensure they despawn when going off screen fix the tricky issue of them passing through enemies as they get hit and finally concluding with correcting mario's power down from fire mario back to super mario still quite a lot to do then but oh i'm afraid you'll have to come back in a few days when i post the second part of this longer two-part episode but don't worry you don't have to wait a whole week so if you have enjoyed this video or if you need part two sooner then smash that like button all the more for it and make sure to subscribe to the channel to be alerted as soon as it arrives if you are a huge fan or an educator then do consider joining the channel membership as your support helps to fund this channel and well just make it even better than ever so thank you for watching have a great week ahead and i'll be seeing you very soon scratch on guys
Info
Channel: griffpatch
Views: 30,800
Rating: undefined out of 5
Keywords: scratch coding, scratch programming, scratch game, scratch 3, griffpatch, griffpatcho, SMB3, SBM3 Advanced 4, Mario in scratch, scrolling, block coding
Id: IOW1JJqtaqk
Channel Id: undefined
Length: 22min 51sec (1371 seconds)
Published: Sun Nov 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.