Top Down Scroller | Part 5 | You've Won!
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
▶
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Burrow Blitz - A game by Griffpatch
griffpatch
Burrow Blitz Level 1 Speed Run!
griffpatch
Scratch Messaging Extension (for chrome & firefox)
griffpatch
Scrolling Platformer Tutorial | Part 1 | Get Scrolling
griffpatch
Scrolling Platformer Tutorial | Part 2 | Gravity
griffpatch
Scrolling Platformer Tutorial | Part 3 | Platform Detection
griffpatch
Scrolling Platformer Tutorial | Part 4 | Off Screen Sprites and Player Death
griffpatch
Scrolling Platformer Tutorial | Part 5 | Collectables
griffpatch
Scrolling Platformer Tutorial | Part 6 | Danger Sprites (Bug fix)
griffpatch
Scrolling Platformer Tutorial | Part 7 | Exit Portal
griffpatch
Scratch 3 | Box2d | Physics Extension
griffpatch
Scrolling Platformer Tutorial | Part 8 | Vertical Scrolling
griffpatch
Zombie Cube | Speedrun challenge
griffpatch
Scratch 3 | Physics Extension | Version 2
griffpatch
Top Down Scroller | E1 - Scrolling | Scratch Tutorial
griffpatch
Top Down Scroller | Part 2 | Enemy AI
griffpatch
Top Down Scroller | Part 3 | Enemy Clones & List
griffpatch
Top Down Scroller | Part 4 | Live Die Repeat (Game Over)
griffpatch
Top Down Scroller | Part 5 | You've Won!
griffpatch
Cloud Game Tutorial | Part 1 | The Basics
griffpatch
Cloud Game Tutorial | Part 2 | Encoding and Decoding
griffpatch
Scratch 3 Dev Tools Browser Extension by griffpatch
griffpatch
Cloud Game Tutorial | Part 3 | Multiplayer
griffpatch
Scrolling Platformer Tutorial | Part 9 | Momentum
griffpatch
Scrolling Platformer Tutorial | Part 10 | Wall Jumping
griffpatch
Cloud Game Tutorial | Part 4 | Auto Game Joining
griffpatch
Game Preview - "Getting Over It" with Griffpatch - A fan recreation in Scratch
griffpatch
Speed Run with Outtakes | Getting Over It | 4 minutes 30 seconds
griffpatch
Griffpatch's Live Stream
griffpatch
MMO Platformer Speedrun Challenge
griffpatch
Appel Platformer | Scratch Game Blog
griffpatch
Cloud Game Tutorial | Part 5 | Smooth Movement
griffpatch
How to Design a Level for Appel
griffpatch
Fastest Appel Speedruns | Jan 2021
griffpatch
Tile Scrolling Platformer (Mario) | 1. Setup
griffpatch
Tile Scrolling Platformer | 2. Grid List
griffpatch
Tile Scrolling Platformer | 3. Tile Collisions
griffpatch
Tile Scrolling Platformer | 4. Platforming Scripts
griffpatch
Tile Scrolling Platformer | 5. The Level Editor
griffpatch
Tile Scrolling Platformer | 6. Level Codes
griffpatch
Tile Scrolling Platformer | 7. Drop Through Platforms
griffpatch
How to make Physics in Scratch | Full Tutorial
griffpatch
Tile Scrolling Platformer | 8. Enemy Clones
griffpatch
Simple Pathfinding Tutorial
griffpatch
Tile Scrolling Platformer | 9. Enemies in Level Editor
griffpatch
Simple Maze Generation | Scratch Tutorial
griffpatch
Tile Scrolling Platformer | 10. Mystery Blocks
griffpatch
Simple Car Steering Simulation | Scratch Tutorial
griffpatch
Simple Background Scrolling Tutorial
griffpatch
Tile Scrolling Platformer | 11. Death, Background & Sound
griffpatch
Mid Week Update & Channel Membership
griffpatch
Simple Grid List Tutorial with Image Scanning
griffpatch
Tile Scrolling Platformer | 12. Auto Arranging Tiles
griffpatch
Code a Fun Space Shooter Game 🚀 | 1. Move & Shoot | Scratch Tutorial
griffpatch
Space Shooter 2 - Enemy Collisions
griffpatch
Tile Scrolling Platformer | 13. Level Progression & Editor Improvements
griffpatch
Space Shooter 3 - Camera Shake & FX
griffpatch
Tile Scrolling Platformer | 14. Sloping Tiles
griffpatch
Pathfinding a Maze using Lists
griffpatch
Tile Scrolling Platformer | 15. Crouch & Slide
griffpatch
More on: Visual / Block Coding
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Medium · AI
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI