Discuss Scratch

JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

Glad the last fix worked as expected (eventually)!

This is the change needed for the current bug.
In the Enemy sprite:

when I start as a clone
. . .
change [:Score v] by (1)
change [:Enemies v] by (-1) //Swap order of this block
DeathAnimation //And this block
delete this clone

To get this:

when I start as a clone
. . .
change [:Score v] by (1)
DeathAnimation
change [:Enemies v] by (-1)
delete this clone
Thanks for all the help!
JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

Hey, everyone who helped me and is helping me, my laptop isn’t working like it should. It just doesn’t function the same way. Sometimes it works properly, sometimes it doesn’t. It’s sort of like luck and you have to get lucky, or something else like the power. Either way, whenever I can work on the project, I will try to get something done, so expect half-finished updates.
mrgibbles10
Scratcher
35 posts

Help with my Shooter Game!

The new bug you described should be very simple to fix. You're just not setting the “EnemyType” for each clone, so it defaults to zero and behaves strangely.

This is what you need to fix:

define SpawnEnemy (type)
if <(type) = (1)> then
switch costume to (NormalMove1 v)
set [EnemyType v] to (1) //Here
end
if <(type) = (2)> then
switch costume to (SpeederMove1 v)
set [EnemyType v] to (2) //Here
end
if <(type) = (3)> then
switch costume to (OrbitonMove1 v)
set [EnemyType v] to (3) //Here
end
create clone of (myself v)

I also noticed that the “Play” button that appears on the main menu will continue to detect clicks after the game has started, crucially re-broadcasting “StartGame” and messing a lot of stuff up.

I would recommend just stopping the script after the button was clicked:

when green flag clicked
. . .
forever
. . .
if <mouse down?> then
broadcast (StartGame v)
stop [this script v] //Here
else
. . .
end

I tested it out, and both of these fixes seem to get the game working properly.
I hope that this helped!
JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

The new bug you described should be very simple to fix. You're just not setting the “EnemyType” for each clone, so it defaults to zero and behaves strangely.

This is what you need to fix:

define SpawnEnemy (type)
if <(type) = (1)> then
switch costume to (NormalMove1 v)
set [EnemyType v] to (1) //Here
end
if <(type) = (2)> then
switch costume to (SpeederMove1 v)
set [EnemyType v] to (2) //Here
end
if <(type) = (3)> then
switch costume to (OrbitonMove1 v)
set [EnemyType v] to (3) //Here
end
create clone of (myself v)

I also noticed that the “Play” button that appears on the main menu will continue to detect clicks after the game has started, crucially re-broadcasting “StartGame” and messing a lot of stuff up.

I would recommend just stopping the script after the button was clicked:

when green flag clicked
. . .
forever
. . .
if <mouse down?> then
broadcast (StartGame v)
stop [this script v] //Here
else
. . . //What do I put here?
end

I tested it out, and both of these fixes seem to get the game working properly.
I hope that this helped!
What do I put in the else?
mrgibbles10
Scratcher
35 posts

Help with my Shooter Game!

JWmeteor wrote:

What do I put in the else?

My apologies! I just copied down the script incorrectly!

when green flag clicked
. . .
forever
. . .
if <touching (mouse-pointer v)?> then
. . .
if <mouse down?> then
broadcast (StartGame v)
stop [this script v] //Here
end
else
. . .
end

You don't need to put anything in the “else.”


JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

JWmeteor wrote:

What do I put in the else?

My apologies! I just copied down the script incorrectly!

when green flag clicked
. . .
forever
. . .
if <touching (mouse-pointer v)?> then
. . .
if <mouse down?> then
broadcast (StartGame v)
stop [this script v] //Here
end
else
. . .
end

You don't need to put anything in the “else.”


Oh, okay!
JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

There is a new bug in the game. We both want a new enemy type, a Juggernaut to be added to the game. It should be walking and at the same time, it would have cracks the more it was damaged. So like this:

if <(EnemyHealth) = [3]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (3)))
end
if <(EnemyHealth) = [2]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (2)))
end
if <(EnemyHealth) = [1]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (1)))
end

Or we could just use the JuggernautCostume variable.
What I'm trying to say is that when I spawn a Juggernaut enemy (enemy ID: 4) in with the custom block while the game is still running, and I kill the enemy, a lot of bugs happen. The title screen comes back while the main game sprites are still there, and a lot of issues are happening.
Can you please help?

Last edited by JWmeteor (Aug. 20, 2026 23:54:26)

mrgibbles10
Scratcher
35 posts

Help with my Shooter Game!

JWmeteor wrote:

There is a new bug in the game. We both want a new enemy type, a Juggernaut to be added to the game. It should be walking and at the same time, it would have cracks the more it was damaged. So like this:

if <(EnemyHealth) = [3]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (3)))
end
if <(EnemyHealth) = [2]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (2)))
end
if <(EnemyHealth) = [1]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (1)))
end

Or we could just use the JuggernautCostume variable.
What I'm trying to say is that when I spawn a Juggernaut enemy (enemy ID: 4) in with the custom block while the game is still running, and I kill the enemy, a lot of bugs happen. The title screen comes back while the main game sprites are still there, and a lot of issues are happening.
Can you please help?


From what I can tell, you have some conflicting scripts. The original AnimateEnemy custom block, and the new Juggernaut animation stack.

I would just combine them into the AnimateEnemy block:

define AnimateEnemy (animationSpeed) (enemyType)
if <(enemyType) = (4)> then
. . . // <- Do Juggernaut animation the same as it is; it works fine.
else
. . . // <- Do regular animation already under the custom block
end

You can just pass the EnemyType variable into the AnimateEnemy block, and it should work.

Sorry that I can't do more thorough testing right now; I won't have access to my usual setup for a couple more days. Scratching on a cell-phone isn't easy!
Anyways, from what I can observe, the animation issue was just some conflicting scripts.

About the main screen reappearing: It looks like the Options button is detecting clicks when it shouldn't, kind of like how the Play button was a while ago.
I think you just have to add <(:SettingsOpen) = (true)> to the <touching (mouse pointer)?> condition.

Finnally, I was messing around with dying to and killing the Juggernaut, however I was unable to create some of the issues you described (main menu reappearing upon the enemies death). Try out the forementioned fix, and see if it works (you may have just clicked the ghost button after killing the juggernaut?).

I'll look more closely soon on a proper system!
JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

JWmeteor wrote:

There is a new bug in the game. We both want a new enemy type, a Juggernaut to be added to the game. It should be walking and at the same time, it would have cracks the more it was damaged. So like this:

if <(EnemyHealth) = [3]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (3)))
end
if <(EnemyHealth) = [2]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (2)))
end
if <(EnemyHealth) = [1]> then
switch costume to (join [JuggernautMove] (join (JuggernautCostume) (join [Health] (1)))
end

Or we could just use the JuggernautCostume variable.
What I'm trying to say is that when I spawn a Juggernaut enemy (enemy ID: 4) in with the custom block while the game is still running, and I kill the enemy, a lot of bugs happen. The title screen comes back while the main game sprites are still there, and a lot of issues are happening.
Can you please help?


From what I can tell, you have some conflicting scripts. The original AnimateEnemy custom block, and the new Juggernaut animation stack.

I would just combine them into the AnimateEnemy block:

define AnimateEnemy (animationSpeed) (enemyType)
if <(enemyType) = (4)> then
. . . // <- Do Juggernaut animation the same as it is; it works fine.
else
. . . // <- Do regular animation already under the custom block
end

You can just pass the EnemyType variable into the AnimateEnemy block, and it should work.

Sorry that I can't do more thorough testing right now; I won't have access to my usual setup for a couple more days. Scratching on a cell-phone isn't easy!
Anyways, from what I can observe, the animation issue was just some conflicting scripts.

About the main screen reappearing: It looks like the Options button is detecting clicks when it shouldn't, kind of like how the Play button was a while ago.
I think you just have to add <(:SettingsOpen) = (true)> to the <touching (mouse pointer)?> condition.

Finnally, I was messing around with dying to and killing the Juggernaut, however I was unable to create some of the issues you described (main menu reappearing upon the enemies death). Try out the forementioned fix, and see if it works (you may have just clicked the ghost button after killing the juggernaut?).

I'll look more closely soon on a proper system!
Sorry to hear about that! The issue is very complicated to me, so I have to reach out and get help. You don't have to help right now if you're on a phone for now. Also thanks for all the help that you have done for the game!
mrgibbles10
Scratcher
35 posts

Help with my Shooter Game!

Hello!

I've looked at the issue again, and the core issue seems to be the same: The strange costume behaviour is being caused by two conflicting scripts.
The usual AnimateEnemy block and a new “when I start as clone” stack are both trying to change the costume based on different parameters.

The fix should just involve adding the juggernaut's script to the main AnimateEnemy block.
Make sure to edit the custome block so it has the enemyType input:

define AnimateEnemy (animationSpeed) (enemyType)
if <(enemyType) < (4)> then
switch costume to ((StartCostume) + (([floor v] of (Costume)) mod (3)))
change [Costume v] by (animationSpeed)
end
if <(enemyType) = (4)> then
if <(JuggernautCostume) < (4)> then
switch costume to (join (join [JuggernautMove] (JuggernautCostume)) (join [Health] (EnemyHealth)))
change [JuggernautCostume v] by (1)
wait (0.025) seconds
else
set [JuggernautCostume v] to (1)
end
end

Then make sure to add the “set {JuggernautCostume} to (1)” block back into the setup stack, in addition to a EnemyType reporter in the AnimateEnemy block:

when I start as a clone
if <(EnemyType) = (1)> then
. . .
end
if <(EnemyType) = (2)> then
. . .
end
if <(EnemyType) = (3)> then
. . .
end
if <(EnemyType) = (4)> then
set [EnemySpeed v] to (3)
set [EnemyHealth v] to (3)
set [JuggernautCostume v] to (1) // <- Add variable set
end
forever
AnimateEnemy (0.4) (EnemyType) // <- Add variable reporter
end

I tested this, and it looks like it works.

For the strange issue of the menu reappearing, it looks like the issue is similar to a previous issue with the “Play” button. Essentially, the “Options” button is still testing for clicks even when it should be hidden. To fix this, all you have to do is add this to its main script:

when green flag clicked
go to x: (160) y: (-125)
show
set [:SettingsOpen? v] to (false)
forever
. . .
if <<touching (mouse pointer v)?> and <(:SettingsOpen?) = [true]>> then // <- Here you add the second condition: ":SettingsOpen? = true"
. . .
else
. . .
end
end

I think that these fixes should take care of the bugs you were seeing.
JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

Hello!

I've looked at the issue again, and the core issue seems to be the same: The strange costume behaviour is being caused by two conflicting scripts.
The usual AnimateEnemy block and a new “when I start as clone” stack are both trying to change the costume based on different parameters.

The fix should just involve adding the juggernaut's script to the main AnimateEnemy block.
Make sure to edit the custome block so it has the enemyType input:

define AnimateEnemy (animationSpeed) (enemyType)
if <(enemyType) < (4)> then
switch costume to ((StartCostume) + (([floor v] of (Costume)) mod (3)))
change [Costume v] by (animationSpeed)
end
if <(enemyType) = (4)> then
if <(JuggernautCostume) < (4)> then
switch costume to (join (join [JuggernautMove] (JuggernautCostume)) (join [Health] (EnemyHealth)))
change [JuggernautCostume v] by (1)
wait (0.025) seconds
else
set [JuggernautCostume v] to (1)
end
end

Then make sure to add the “set {JuggernautCostume} to (1)” block back into the setup stack, in addition to a EnemyType reporter in the AnimateEnemy block:

when I start as a clone
if <(EnemyType) = (1)> then
. . .
end
if <(EnemyType) = (2)> then
. . .
end
if <(EnemyType) = (3)> then
. . .
end
if <(EnemyType) = (4)> then
set [EnemySpeed v] to (3)
set [EnemyHealth v] to (3)
set [JuggernautCostume v] to (1) // <- Add variable set
end
forever
AnimateEnemy (0.4) (EnemyType) // <- Add variable reporter
end

I tested this, and it looks like it works.

For the strange issue of the menu reappearing, it looks like the issue is similar to a previous issue with the “Play” button. Essentially, the “Options” button is still testing for clicks even when it should be hidden. To fix this, all you have to do is add this to its main script:

when green flag clicked
go to x: (160) y: (-125)
show
set [:SettingsOpen? v] to (false)
forever
. . .
if <<touching (mouse pointer v)?> and <(:SettingsOpen?) = [true]>> then // <- Here you add the second condition: ":SettingsOpen? = true"
. . .
else
. . .
end
end

I think that these fixes should take care of the bugs you were seeing.
YOU… HAVE… RETURNED!!! Also thanks for the help!

Last edited by JWmeteor (Aug. 26, 2026 21:22:18)

JWmeteor
Scratcher
44 posts

Help with my Shooter Game!

mrgibbles10 wrote:

Hello!

I've looked at the issue again, and the core issue seems to be the same: The strange costume behaviour is being caused by two conflicting scripts.
The usual AnimateEnemy block and a new “when I start as clone” stack are both trying to change the costume based on different parameters.

The fix should just involve adding the juggernaut's script to the main AnimateEnemy block.
Make sure to edit the custome block so it has the enemyType input:

define AnimateEnemy (animationSpeed) (enemyType)
if <(enemyType) < (4)> then
switch costume to ((StartCostume) + (([floor v] of (Costume)) mod (3)))
change [Costume v] by (animationSpeed)
end
if <(enemyType) = (4)> then
if <(JuggernautCostume) < (4)> then
switch costume to (join (join [JuggernautMove] (JuggernautCostume)) (join [Health] (EnemyHealth)))
change [JuggernautCostume v] by (1)
wait (0.025) seconds
else
set [JuggernautCostume v] to (1)
end
end

Then make sure to add the “set {JuggernautCostume} to (1)” block back into the setup stack, in addition to a EnemyType reporter in the AnimateEnemy block:

when I start as a clone
if <(EnemyType) = (1)> then
. . .
end
if <(EnemyType) = (2)> then
. . .
end
if <(EnemyType) = (3)> then
. . .
end
if <(EnemyType) = (4)> then
set [EnemySpeed v] to (3)
set [EnemyHealth v] to (3)
set [JuggernautCostume v] to (1) // <- Add variable set
end
forever
AnimateEnemy (0.4) (EnemyType) // <- Add variable reporter
end

I tested this, and it looks like it works.

For the strange issue of the menu reappearing, it looks like the issue is similar to a previous issue with the “Play” button. Essentially, the “Options” button is still testing for clicks even when it should be hidden. To fix this, all you have to do is add this to its main script:

when green flag clicked
go to x: (160) y: (-125)
show
set [:SettingsOpen? v] to (false)
forever
. . .
if <<touching (mouse pointer v)?> and <(:SettingsOpen?) = [true]>> then // <- Here you add the second condition: ":SettingsOpen? = true"
. . .
else
. . .
end
end

I think that these fixes should take care of the bugs you were seeing.
Wait, what about the when I start as a clone script?
mrgibbles10
Scratcher
35 posts

Help with my Shooter Game!

JWmeteor wrote:

Wait, what about the when I start as a clone script?

If you mean the script that used to handle the Juggernaut's animation, you should just be able to remove it.

I also made a small mistake with the menu glitch. It's not quite as simple as adding that extra condition. My fix prevents the player from accidentally clicking it in-game, but it also prevents the player from clicking it the menu . . .

To truly fix it, I would take a similar approach to the Play button: Just stop the script!

Upon the Option button's receival of the StartGame broadcast, you can just run a “stop other scripts in sprite” block:

when I receive [StartGame v]
stop [other scripts in sprite v]

Last edited by mrgibbles10 (Yesterday 00:40:50)

Powered by DjangoBB