Clone for clone

id: 750916

category: Help with Scripts

posts: 2

I am making a shooter game where you have to shoot the enemy ships, and I need to make the enemy ships shoot lazers and the best thing i could think of was a clone block. so I added the ‘create clone of’ block but it wont shoot from the cloned spaceships (the spaceships are clones of a hidden spaceship on the screen) even though I am using the ‘When I start as a clone’ block to start the script! Can someone help please?
Ranger_07 Ranger_07 loading
One option is to use a list to make the bullet clones. Implementing it would go something like this:
replace the “create clone of” block with this:
//the list "laserSpawn" must be for all sprites
add [someLaserType] to [laserSpawn v] //your laser type would be used to create different kinds of lasers
add (x position) to [laserSpawn v]
add (y position) to [laserSpawn v]
add (direction) to [laserSpawn v]
Then in the laser sprite add this:
forever
create lasers
end
define create lasers
//Make sure you check the "run without screen refresh"
if <(length of [laserSpawn v]) > (0)> then
repeat until <(length of [laserSpawn v]) < (4)>
set [laserType v] to (item (1) of [laserSpawn v]) //the variable "laserType" should be for this sprite only so that each clone can have it as different values
set x to (item (2) of [laserSpawn v])
set y to (item (3) of [laserSpawn v])
point in direction (item (4) of [laserSpawn v])
create clone of [myself v]
repeat (4)
delete (1) of [laserSpawn v]
end
end
end
hopefully this helps