Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » i need help with making a spawn engine
- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
i need help making a spawn engine for my new game
(please help me)
(please help me)
Last edited by ToyinRocks (June 22, 2023 01:32:22)
- legendary34678
-
Scratcher
1000+ posts
i need help with making a spawn engine
What do you mean by a spawn engine? What does it do?
- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
it spawns enemies and collectibles across a scrolling platformer
- NMario84
-
Scratcher
1000+ posts
i need help with making a spawn engine
Do you need them to despawn off screen as well, and then re-spawn at the same spot if they do despawn?
- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
and d I have something for special collectibles
(or this would go into an existing script If it didn't mess anything up)
when green flag clicked
forever
if <touching [ v] ?> then
forever
broadcast [ v]
end
endend
(or this would go into an existing script If it didn't mess anything up)
Last edited by ToyinRocks (June 22, 2023 04:16:29)
- NMario84
-
Scratcher
1000+ posts
i need help with making a spawn engine
Well…… I suppose you could draw a huge square covering the whole screen, make it invisible (using ghost effect), and then have some script where object spawn points are touching the screen as it is being scrolled in?
There's probably a better way than that, I am sure.
There's probably a better way than that, I am sure.

- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
What do you mean by a spawn engine? What does it do?I don't have the xy problem
- qwertycodechamp90411
-
Scratcher
100+ posts
i need help with making a spawn engine
If you mean spawning entities at a certain spot, this should work
This spawns a monster every a seconds at the coordinates of the thing being spawned. The 5's in the custom block definition are if the monster moves 5 pixels at a time.
For a scrolling platformer, move the spawner and the monsters along with the level.
If you want to make it so that it spawns a monster if there is no monster yet, change the condition from if a mod timer = 0 to if clone? = 0, where ‘clone’ is a variable that changes to 1 when a clone is spawned, and 0 when a clone is deleted. If clone is 1, it will not spawn, and will change back to 0 upon deletion of the monster. If you want a three second cooldown before a respawn, use
Also, if the spawner can't move further along, make sure to stop the spawner.
when green flag clicked
hide
reset timer
forever
if <((a) mod (timer)) = [0]> then
create clone of [me v]
end
end
when I start as a clone
show
forever
move around, do stuff, idk just move around do whatever::motion
if <touching [edge v] ?> then
detect if too far off edge::custom
end
end
define detect if too far off edge
set [variablex v] to (x position)
set [variabley v] to (y position)
go to x: ((x position) + (5)) y: ((y position) + (5))
if <not <<((x position) - (5)) = (variablex)> or <((y position) - (5)) = (variabley)>>> then
delete this clone
end
go to x: ((x position) - (5)) y: ((y position) - (5))
This spawns a monster every a seconds at the coordinates of the thing being spawned. The 5's in the custom block definition are if the monster moves 5 pixels at a time.
For a scrolling platformer, move the spawner and the monsters along with the level.
If you want to make it so that it spawns a monster if there is no monster yet, change the condition from if a mod timer = 0 to if clone? = 0, where ‘clone’ is a variable that changes to 1 when a clone is spawned, and 0 when a clone is deleted. If clone is 1, it will not spawn, and will change back to 0 upon deletion of the monster. If you want a three second cooldown before a respawn, use
forever
if <(clone) = [0]> then
reset timer
wait until <(timer) = [3]>
create clone of [me v]
set [clone? v] to [1]
end
end
Also, if the spawner can't move further along, make sure to stop the spawner.
Last edited by qwertycodechamp90411 (June 30, 2023 06:28:55)
- RealNames10
-
Scratcher
17 posts
i need help with making a spawn engine
define Enemy X:(X) Y:(Y) Type(Type)
set [x] to (X)
set [y] to (Y)
set [type] to (Type)
create clone of [myself]
Enemy X:((pick random (-100) to (100)) Y:((pick random (-100) to (100))
when I start as a clone
forever
AI Loop
go to x: ((x) - (scrollx)) y: ((y) - (scrolly))
end
Last edited by RealNames10 (July 1, 2023 17:40:21)
- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
do you guys use states in your projects?
- qwertycodechamp90411
-
Scratcher
100+ posts
i need help with making a spawn engine
What’s a state (I don’t know scratch terminology lol)
- coolio1214
-
Scratcher
37 posts
i need help with making a spawn engine
when I receive [died v]hope that helped
go to x: (10) y: (30)
- ToyinRocks
-
Scratcher
17 posts
i need help with making a spawn engine
What’s a state (I don’t know scratch terminology lol)a state is like a shortcut for hitboxes
- Discussion Forums
- » Help with Scripts
-
» i need help with making a spawn engine





