Discuss Scratch

CrazyCoolYT
Scratcher
25 posts

Game Over isn't working, would like some help

In my top down shooter, whenever you get hit by a zombie, you lose a life. Lose a life enough times and you'll reach zero (obvi) which is supposed to trigger a game over screen. However, I got around to fixing some bugs and I caused another one – the game over screen just doesn't trigger.

Here's the link to my project: https://scratch.mit.edu/projects/689579905/

I've tried using a system where while GamePlaying = true, then if Lives = 0 or Lives < 0 then broadcast GameOver, but it just doesn't seem to work.
Does anybody have any ideas?

Most of the code in this system is found under the game objects “Player” and “GameOver”. Should be pretty simple and work easily but just doesn't.

Thank you so much!

Hey! You, reading this! Wanna kill some zombies like a super-freakin'-cool action hero (insert cool emoji)? Well, you're in luck, because I've got just the game for you!

https://scratch.mit.edu/projects/689579905/

You're welcome!
BigNate469
Scratcher
500+ posts

Game Over isn't working, would like some help

I know that this might not directly help you, but you should group all of the scripts under your hat blocks under ONE hat block- rather than:
when I receive [some message v]
Do something

when I receive [the same message v]
Do something else
Use:
when I receive [some message v]
Do something
Do something else
That way, you know what order things happen in- because everything happens in an order when it comes to computer programming, you just can't always see that.

Highlight any part of this signature and press ctrl+shift+down arrow to see the rest of it
forever
if <person asks [what's a signature] :: sensing> then
Redirect to [https://en.scratch-wiki.info/wiki/Signature] :: motion
end
end
Please read the list of Officially Rejected Suggestions before posting a suggestion for Scratch! 100th post
This signature is designed to be as helpful as possible.
View all of the topics you've posted in:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=topics
View all of your posts:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=posts
Forum tips:
Don't title topics something like “HELP ME!!!”. It's not helpful, and won't get you as many responses.
Don't post in topics where the latest post is over ~2 months old, unless you have something critical to add. Especially in topics that are several years old- it isn't helpful, and is known as necroposting.
Don't post unrelated things in topics, including questions of your own. Make a new topic for your questions.
You can use the
 [code] and [/code] 
tags to show other users how to format something that Scratch would otherwise format.
You can use the
 [color=color name or hexadecimal value here] and [/color] 
tags to color text.
Little-known Scratch URLs:
scratch.pizza (redirects to main page)
https://scratch.mit.edu/projects/PROJECT ID HERE/remixtree (replace “PROJECT ID HERE” with project id number. Shows all the remixes of the project, and the remixes of those projects, and the remixes of those projects, and so on, as a chart. Link currently redirects to one of my projects)
BigNate469
Scratcher
500+ posts

Game Over isn't working, would like some help

Also, the answer to your question: put the repeat loop that checks the number of lives the player has under a
when I receive [Game Start v]
Rather than a
when green flag clicked

Highlight any part of this signature and press ctrl+shift+down arrow to see the rest of it
forever
if <person asks [what's a signature] :: sensing> then
Redirect to [https://en.scratch-wiki.info/wiki/Signature] :: motion
end
end
Please read the list of Officially Rejected Suggestions before posting a suggestion for Scratch! 100th post
This signature is designed to be as helpful as possible.
View all of the topics you've posted in:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=topics
View all of your posts:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=posts
Forum tips:
Don't title topics something like “HELP ME!!!”. It's not helpful, and won't get you as many responses.
Don't post in topics where the latest post is over ~2 months old, unless you have something critical to add. Especially in topics that are several years old- it isn't helpful, and is known as necroposting.
Don't post unrelated things in topics, including questions of your own. Make a new topic for your questions.
You can use the
 [code] and [/code] 
tags to show other users how to format something that Scratch would otherwise format.
You can use the
 [color=color name or hexadecimal value here] and [/color] 
tags to color text.
Little-known Scratch URLs:
scratch.pizza (redirects to main page)
https://scratch.mit.edu/projects/PROJECT ID HERE/remixtree (replace “PROJECT ID HERE” with project id number. Shows all the remixes of the project, and the remixes of those projects, and the remixes of those projects, and so on, as a chart. Link currently redirects to one of my projects)
eefie_gang
Scratcher
26 posts

Game Over isn't working, would like some help

All you need to do is add a forever loop around the code in player sprite that broadcasts game over. what its doing is when the flag is clicked is it checking if the game is playing one time so all you need is a forever loop and that Should fix it.

when green flag clicked
forever
if <(Game Playing) = [True]> then
repeat until <(Game Playing) = [Flase]>
if <<[(Lives)] < [0]> or <[(Lives)] = [0]>> then
broadcast [GAME OVER v]
hide variable [Lives v]
set [Game Playing v] to [False]
end
end
end
end
That should be the code

ask [Are you subscribed to Nolswit on Youtube?] and wait
if <(answer) = [Yes]> then
say [Thank you!]


else
Redirect to [www.youtube.com/@Nolswit]
end
Currently working on: Nuclear Platformer
BigNate469
Scratcher
500+ posts

Game Over isn't working, would like some help

eefie_gang wrote:

All you need to do is add a forever loop around the code in player sprite that broadcasts game over. what its doing is when the flag is clicked is it checking if the game is playing one time so all you need is a forever loop and that Should fix it.

when green flag clicked
forever
if <(Game Playing) = [True]> then
repeat until <(Game Playing) = [Flase]>
if <<[(Lives)] < [0]> or <[(Lives)] = [0]>> then
broadcast [GAME OVER v]
hide variable [Lives v]
set [Game Playing v] to [False]
end
end
end
end
That should be the code
The issue with that is that it would be endlessly running when it does not need to be. Attaching it to the message block that runs on the game start makes more sense, because that way you don't have another laggy forever loop running when it doesn't need to be.

Highlight any part of this signature and press ctrl+shift+down arrow to see the rest of it
forever
if <person asks [what's a signature] :: sensing> then
Redirect to [https://en.scratch-wiki.info/wiki/Signature] :: motion
end
end
Please read the list of Officially Rejected Suggestions before posting a suggestion for Scratch! 100th post
This signature is designed to be as helpful as possible.
View all of the topics you've posted in:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=topics
View all of your posts:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=posts
Forum tips:
Don't title topics something like “HELP ME!!!”. It's not helpful, and won't get you as many responses.
Don't post in topics where the latest post is over ~2 months old, unless you have something critical to add. Especially in topics that are several years old- it isn't helpful, and is known as necroposting.
Don't post unrelated things in topics, including questions of your own. Make a new topic for your questions.
You can use the
 [code] and [/code] 
tags to show other users how to format something that Scratch would otherwise format.
You can use the
 [color=color name or hexadecimal value here] and [/color] 
tags to color text.
Little-known Scratch URLs:
scratch.pizza (redirects to main page)
https://scratch.mit.edu/projects/PROJECT ID HERE/remixtree (replace “PROJECT ID HERE” with project id number. Shows all the remixes of the project, and the remixes of those projects, and the remixes of those projects, and so on, as a chart. Link currently redirects to one of my projects)
CrazyCoolYT
Scratcher
25 posts

Game Over isn't working, would like some help

Thank you guys! I had it on Game Start before but I tried changing it over to “when flag is clicked” to see if that fixed anything. This advice was great, thank you!

Hey! You, reading this! Wanna kill some zombies like a super-freakin'-cool action hero (insert cool emoji)? Well, you're in luck, because I've got just the game for you!

https://scratch.mit.edu/projects/689579905/

You're welcome!

Powered by DjangoBB