Discuss Scratch

DarkstalkerLS
Scratcher
9 posts

Please help with clones.

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

I have been coding an Mk48.io game where it's a scrolling background, the player (purple) stays at (0,0) and the bot launches torpedoes. However, when you increase speed, the torps stop launching from the bot. Please help.
KevinOVO
New Scratcher
90 posts

Please help with clones.

I think this works?


in your “Bot” sprite:

when I start as a clone :: cat
show
set [Bot Health v] to [50]
set [Bot X v] to (pick random (-300) to (300))
set [Bot Y v] to (pick random (-200) to (200))
forever
set [Bot Turning v] to (pick random (-5) to (5))
repeat (5)
turn ccw (Bot Turning) degrees
go to x: ((Bot X) - (Scroll X)) y: ((Bot Y) - (Scroll Y))
change [Bot X v] by (([sin v] of (direction)::operators) * [1])
change [Bot Y v] by (([cos v] of (direction)::operators) * [1])
+set [Bot X - Torp v] to (Bot X)
+set [Bot Y - Torp v] to (Bot Y)
if on edge, bounce
end
end
DarkstalkerLS
Scratcher
9 posts

Please help with clones.

Thank you. I do ask if you know how to fix where the torpedoes go, as they now go off-screen, not to the player.
KevinOVO
New Scratcher
90 posts

Please help with clones.

I think there're two problems, one is that the “Bot” you spawned is a clone, and that go to block makes it goes to original sprite instead of the clone

when I start as a clone :: cat
show
+go to x: ((Bot X - Torp) - (Scroll X)) y: ((Bot Y - Torp) - (Scroll Y))
point towards (Bot Torp Aiming v)
set [Bot X - Torp Mov v] to (Bot X - Torp)
set [Bot Y - Torp Mov v] to (Bot Y - Torp)
...

the other is that the “Bot Torp Aiming” sprite wasn't on your player

when green flag clicked :: cat
hide
forever
+go to (Player v)
end
or use
go to x: ((Player X) - (Scroll X)) y: ((Player Y) - (Scroll Y))
or
go to x: (0) y: (0)

Powered by DjangoBB