Top Down Scroller | Part 5 | You've Won!

griffpatch · Beginner ·🛠️ AI Tools & Apps ·7y ago

Key Takeaways

Scripts a top down scrolling game in Scratch with a winning condition

Full Transcript

hi sis Grif patch welcome to part 5 of my top-down scrolling tutorial for scratch in this episode we're going up the project had in a ending screen and the timer and really just wrap up the game so I hope you will enjoy this let's get on with it what we need now is a way of winning the level now in was Amba cube why did for that is just add a colorful exit so let's go into costumes and we'll add in a new color for the exit now the exit can be a light blue color like this so let me just add in an exit over here so that's our exit now when I get and touch that I want it to finish the game so I just come over here a second there we go as soon as I walk onto that product finish I don't want to finish my touch it I want I it to be completely on top of it to finish the game and we can do that I go into the player later okay so we've got the touching enemy there I can borrow that and also have it for touching the exit so if I have another touching at the bottom here so touching no not zombie touching color so if I am touching this blue color like this then I'm going to set the game to win now that at the moment would end as soon as I touch it not close I'm sitting on top of it so I need another special little trick here so I need another if statement inside and I'm gonna say I'm not touching and I'm going to choose the background color so if I'm touching the blue exit and I'm not touching the black so any way that can happen is if I'm actually right on top of it because I'm touching a black otherwise you see an end is set to win at the moment that will be the same as dying because there is no difference between winning and dying I'll just restart the game but watch this so I'm now overlapping it and as soon as I go over it restarts so it is working I just need to actually have an exit so at the moment down here in the main game loop at the end if ended die I shape the screen otherwise it's going to be winning and so what we need here is the wind screen so what I shall do in there is create a new custom block called win and again don't run without screen refresh leave that unchecked so here it is but win in there the position that booty again and then whatever I want to do when I win has to happen here so what are we going to do when we win but be the best thing to do would be to put a well done you have one message on the screen so let's add in a U of one message so when it does this win let's do a broadcast and wait it's gonna be a new message maybe you won so and let's create a new sprite paint and we're gonna call this for now and I'm going to call the costume win as well and I'm going to write some text on the screen what color we're going to do it in let's do it in okay look let's do it in black to start with and we're going to use the pixel font you win like that okay now this is quite a nice little trick watch this if I grab the corner make it bigger of that of course does not show up on the screen nicely but watch this if I copy it and paste it you can use these buttons do that if you want to always positions if you zoomed out five pixels to the right five down so if I use the arrow keys I can press it five times up one two three four five and the left five one two three four five then that exactly over the top of each other then change the outline to be white you can start see that appearing and bump up the width to be maybe four five maybe five and then click back now I've got an outline around my font book which is quite funky you can choose the width the outline using this so I can make it really big and that what's really well with the pixel font very perfect thing like that's one thing you don't have to like that any kind of wind thing you like and I can group that together so there's a you win sign and I can move that to somewhere on the screen where I want it let me slightly up at the buff like that okay code so when I receive and this is going to be set up to hide this message that and when I receive my win you won I want to show my message so what I'm going to do in here is I'm going to just pause the game and that'll be the end of the game until you press the green flag again so I'm gonna have a control then gonna have a forever and then I mean I just put a weight in there like that so it's gonna loop forever one more thing of course I need to put a go-to X Y and I'm gonna have zero zero so it appears in the middle so let's just see if this works okay here I go I need to make it onto the exit and I won perfect and if I die I died so you might want a bit of text on screen here saying press any key to start let's do that as well already we use this wind sprite so if I do play that I can right click in here so that's right to press any key to start okay so shrink that down so it fits on the screen like that and I'm going to create the little bit of background so copy paste you've up by 5 1 2 3 4 5 left by 500 3 4 5 give it a walk now order white make it slightly thicker and to back I'll make it for 5 thick okay so hopefully actually might need to be thicker than that let's have a look so in the code that's over when I receive in fact let's do it in the setup so we've already got it so so rather than hiding let's get rid of that what we actually want to do is duplicate the code from the win go to 0-0 show no forever loop I want it here instead is a set costume - Oh didn't name it win - that's no use let's call it ready okay switch to the ready costume and show it so that means at the very beginning it has the press any key to start move that down a little bit it's too high what I realize now having just written that it's actually that's probably a better way of doing this what I'm going to do not call this a setup I'm going to have a new message and I'm gonna call this ready like that okay so this is will be broadcast when it's time to start a game it'll set the costume and I'm going to put the weight for any key press in here so let's put in the wait until and sensing and we're going to put in here the key pressed any key and when we press any key we're going to hide this message okay so then go into player where we've got the any key here and instead of doing that let's do a broadcast and wait so broadcast ready at and then we can get rid of that wait any key because the ready is and they do it for us since if ago so there's the press any key and then not winning on it putting the key it disappears and we're off I as the key we off died okay only one thing left to do and that is have a timer to see how long it took us to complete that level so let's have a go at that simplest way of doing that is that in sensing we have a timer here so let's call the reset timer just before we start our repeat until loop our game so every time it starts we reset the timer now we can make the time of visible on screen by clicking this little timer box here there it is there but the pond with that is that the timer is changing all the time even when we're dead even when we've won so that's not quite as useful so let's stop that so not making this timer visible let's create our own available called time nightmare and all uppercase cuz it could be for all sprites this and let's click it double click it to make it into a nice single box like that just put it in the middle there for now and we're going to update that to be a nice time that's displayed on the screen so what we're going to do is put this into right at the beginning of this repeat until the kind of a set and we're going to change time now we could just drop in timer in there like this so if I run that timer starts zero starts moving and when we die timer stops which is what we want and it stays set as it was until we start moving and then it goes back to zero but I don't really want all this it's a bit too big time so let's just change the set time to make it look a little bit nicer let's only have one decimal place so if we get round yeah and then we get the multiply and divide so set time to divide by ten on the left we put round and we have times by 10 and put time on the left so we're going to times time it by 10 round it there's number and then divide it by 10 and what that has the effect of doing they start the game is showing just one decimal place if we times by 100 you would show two decimal places okay if we compete the game there we are it stops and shows us what time we got that work it's much nicer like that just wanting to do at the very top of the game before the game loop at all let's run the set time to zero just so that when we started the first time it set to zero rather than the last amount that we played the game that is pretty much it I think we've pretty much got over the need for their game there so you can design the level by coming into the costumes here draw whatever blevells you want you can create the exit you can add new zombies by going into the code and in this script here remember with the unimpressed just move that to the bottom there so that it will always run when II press em so I can now click in here and press m and it'll add new zombies in if you need to delete all the zombies simply go into your scripts here and you can say delete all mobs as soon as I click that like that run it there's no zombies see and if I want to add new ones in move that below and I'll click here click here and I'll click here I'm clicking the M key by the way run it now and there you are far too many okay so again I can delete them all by clicking on delete all mobs it's like this run it again all gone so I want to press one up here one down there and then run it there you go so it's really easy okay that's it I'm gonna stop the tutorial I hope that was a helpful tutorial for you and that you enjoyed it do you subscribe to me I'm Grif match and thank you for watching bye now

Original Description

This is part 5 of a five part series on how to script a top down scrolling game in scratch. Based on Zombie Cube (https://scratch.mit.edu/projects/284516654/) Part 1 - Looked at Scrolling (https://youtu.be/GXsjYupfDYk) Part 2 - Introduces a zombie cube enemy and gives it a simple zombie AI Part 3 - Uses a List to hold Zombie Clone Positions and we placing them in the level. Part 4 - We deal with enemies actually catching you and camera shake. Part 5 - We add the exit so we can complete the game + a timer All coding by griffpatch - Subscribe to me to not miss out on any new tutorials :) 🚀 *Boost Your Creativity with Griffpatch* The Griffpatch Academy will take you from "Gamer to Game Creator" Learn more at 👉 https://griffpatch.academy 👈 😺 Scratch was developed by the Lifelong Kindergarten Group at the MIT Media Lab. See http://scratch.mit.edu
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from griffpatch · griffpatch · 19 of 60

1 Burrow Blitz - A game by Griffpatch
Burrow Blitz - A game by Griffpatch
griffpatch
2 Burrow Blitz Level 1 Speed Run!
Burrow Blitz Level 1 Speed Run!
griffpatch
3 Scratch Messaging Extension (for chrome & firefox)
Scratch Messaging Extension (for chrome & firefox)
griffpatch
4 Scrolling Platformer Tutorial | Part 1 | Get Scrolling
Scrolling Platformer Tutorial | Part 1 | Get Scrolling
griffpatch
5 Scrolling Platformer Tutorial | Part 2 | Gravity
Scrolling Platformer Tutorial | Part 2 | Gravity
griffpatch
6 Scrolling Platformer Tutorial | Part 3 | Platform Detection
Scrolling Platformer Tutorial | Part 3 | Platform Detection
griffpatch
7 Scrolling Platformer Tutorial | Part 4 | Off Screen Sprites and Player Death
Scrolling Platformer Tutorial | Part 4 | Off Screen Sprites and Player Death
griffpatch
8 Scrolling Platformer Tutorial | Part 5 | Collectables
Scrolling Platformer Tutorial | Part 5 | Collectables
griffpatch
9 Scrolling Platformer Tutorial | Part 6 | Danger Sprites (Bug fix)
Scrolling Platformer Tutorial | Part 6 | Danger Sprites (Bug fix)
griffpatch
10 Scrolling Platformer Tutorial | Part 7 | Exit Portal
Scrolling Platformer Tutorial | Part 7 | Exit Portal
griffpatch
11 Scratch 3 | Box2d |  Physics Extension
Scratch 3 | Box2d | Physics Extension
griffpatch
12 Scrolling Platformer Tutorial | Part 8 | Vertical Scrolling
Scrolling Platformer Tutorial | Part 8 | Vertical Scrolling
griffpatch
13 Zombie Cube | Speedrun challenge
Zombie Cube | Speedrun challenge
griffpatch
14 Scratch 3 | Physics Extension | Version 2
Scratch 3 | Physics Extension | Version 2
griffpatch
15 Top Down Scroller | E1 - Scrolling | Scratch Tutorial
Top Down Scroller | E1 - Scrolling | Scratch Tutorial
griffpatch
16 Top Down Scroller | Part 2 | Enemy AI
Top Down Scroller | Part 2 | Enemy AI
griffpatch
17 Top Down Scroller | Part 3 | Enemy Clones & List
Top Down Scroller | Part 3 | Enemy Clones & List
griffpatch
18 Top Down Scroller | Part 4 | Live Die Repeat (Game Over)
Top Down Scroller | Part 4 | Live Die Repeat (Game Over)
griffpatch
Top Down Scroller | Part 5 | You've Won!
Top Down Scroller | Part 5 | You've Won!
griffpatch
20 Cloud Game Tutorial | Part 1 | The Basics
Cloud Game Tutorial | Part 1 | The Basics
griffpatch
21 Cloud Game Tutorial | Part 2 | Encoding and Decoding
Cloud Game Tutorial | Part 2 | Encoding and Decoding
griffpatch
22 Scratch 3 Dev Tools Browser Extension by griffpatch
Scratch 3 Dev Tools Browser Extension by griffpatch
griffpatch
23 Cloud Game Tutorial | Part 3 | Multiplayer
Cloud Game Tutorial | Part 3 | Multiplayer
griffpatch
24 Scrolling Platformer Tutorial | Part 9 | Momentum
Scrolling Platformer Tutorial | Part 9 | Momentum
griffpatch
25 Scrolling Platformer Tutorial | Part 10 | Wall Jumping
Scrolling Platformer Tutorial | Part 10 | Wall Jumping
griffpatch
26 Cloud Game Tutorial | Part 4 | Auto Game Joining
Cloud Game Tutorial | Part 4 | Auto Game Joining
griffpatch
27 Game Preview - "Getting Over It" with Griffpatch - A fan recreation in Scratch
Game Preview - "Getting Over It" with Griffpatch - A fan recreation in Scratch
griffpatch
28 Speed Run with Outtakes | Getting Over It | 4 minutes 30 seconds
Speed Run with Outtakes | Getting Over It | 4 minutes 30 seconds
griffpatch
29 Griffpatch's Live Stream
Griffpatch's Live Stream
griffpatch
30 MMO Platformer Speedrun Challenge
MMO Platformer Speedrun Challenge
griffpatch
31 Appel Platformer | Scratch Game Blog
Appel Platformer | Scratch Game Blog
griffpatch
32 Cloud Game Tutorial | Part 5 | Smooth Movement
Cloud Game Tutorial | Part 5 | Smooth Movement
griffpatch
33 How to Design a Level for Appel
How to Design a Level for Appel
griffpatch
34 Fastest Appel Speedruns | Jan 2021
Fastest Appel Speedruns | Jan 2021
griffpatch
35 Tile Scrolling Platformer (Mario) | 1. Setup
Tile Scrolling Platformer (Mario) | 1. Setup
griffpatch
36 Tile Scrolling Platformer | 2. Grid List
Tile Scrolling Platformer | 2. Grid List
griffpatch
37 Tile Scrolling Platformer | 3. Tile Collisions
Tile Scrolling Platformer | 3. Tile Collisions
griffpatch
38 Tile Scrolling Platformer | 4. Platforming Scripts
Tile Scrolling Platformer | 4. Platforming Scripts
griffpatch
39 Tile Scrolling Platformer | 5. The Level Editor
Tile Scrolling Platformer | 5. The Level Editor
griffpatch
40 Tile Scrolling Platformer | 6. Level Codes
Tile Scrolling Platformer | 6. Level Codes
griffpatch
41 Tile Scrolling Platformer | 7. Drop Through Platforms
Tile Scrolling Platformer | 7. Drop Through Platforms
griffpatch
42 How to make Physics in Scratch | Full Tutorial
How to make Physics in Scratch | Full Tutorial
griffpatch
43 Tile Scrolling Platformer | 8. Enemy Clones
Tile Scrolling Platformer | 8. Enemy Clones
griffpatch
44 Simple Pathfinding Tutorial
Simple Pathfinding Tutorial
griffpatch
45 Tile Scrolling Platformer | 9. Enemies in Level Editor
Tile Scrolling Platformer | 9. Enemies in Level Editor
griffpatch
46 Simple Maze Generation | Scratch Tutorial
Simple Maze Generation | Scratch Tutorial
griffpatch
47 Tile Scrolling Platformer | 10. Mystery Blocks
Tile Scrolling Platformer | 10. Mystery Blocks
griffpatch
48 Simple Car Steering Simulation | Scratch Tutorial
Simple Car Steering Simulation | Scratch Tutorial
griffpatch
49 Simple Background Scrolling Tutorial
Simple Background Scrolling Tutorial
griffpatch
50 Tile Scrolling Platformer | 11. Death, Background & Sound
Tile Scrolling Platformer | 11. Death, Background & Sound
griffpatch
51 Mid Week Update & Channel Membership
Mid Week Update & Channel Membership
griffpatch
52 Simple Grid List Tutorial with Image Scanning
Simple Grid List Tutorial with Image Scanning
griffpatch
53 Tile Scrolling Platformer | 12. Auto Arranging Tiles
Tile Scrolling Platformer | 12. Auto Arranging Tiles
griffpatch
54 Code a Fun Space Shooter Game 🚀 | 1. Move & Shoot | Scratch Tutorial
Code a Fun Space Shooter Game 🚀 | 1. Move & Shoot | Scratch Tutorial
griffpatch
55 Space Shooter 2 - Enemy Collisions
Space Shooter 2 - Enemy Collisions
griffpatch
56 Tile Scrolling Platformer | 13. Level Progression & Editor Improvements
Tile Scrolling Platformer | 13. Level Progression & Editor Improvements
griffpatch
57 Space Shooter 3 - Camera Shake & FX
Space Shooter 3 - Camera Shake & FX
griffpatch
58 Tile Scrolling Platformer | 14. Sloping Tiles
Tile Scrolling Platformer | 14. Sloping Tiles
griffpatch
59 Pathfinding a Maze using Lists
Pathfinding a Maze using Lists
griffpatch
60 Tile Scrolling Platformer | 15. Crouch & Slide
Tile Scrolling Platformer | 15. Crouch & Slide
griffpatch

Related AI Lessons

How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Learn to create a second version of yourself inside Obsidian using AI with a step-by-step guide
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Learn how to prepare for the Spain civil service TIC exam using AI in 2026, boosting your chances of success with technology-driven study techniques
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Create viral AI kissing videos using AIAI.com in a step-by-step process, leveraging AI technology for creative content creation
Medium · AI
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Prepare for TIC teacher exams in Spain using AI with these actionable steps
Dev.to AI
Up next
Low-Tech, High-Impact: Replacing Your Receptionist With a $15 AI Phone System
Maximum Lawyer
Watch →