Discuss Scratch

AlinGrozav
Scratcher
2 posts

Need help with Tower Defense project

Begginer scratcher here guys , I need your help with this one .

https://scratch.mit.edu/projects/996569433/ this is the link to the project.

Inside the enemy sprite , how can I update the enemy coordinates and enemy progress , inside the EnemyX , EnemyY and EnemyProgress lists , for each clone? (Right now its updating only the last clone spawned)
Pixilized
Scratcher
100+ posts

Need help with Tower Defense project

Replace the cloneID variable with a new variable just called ID. This is because you need this variable to be “for this sprite only”. Then, each clone will have a different value if asked to report “ID” because the variable thinks the clones are new sprites. So, just use this block in the clone script.
define Update Position
replace item (ID) of [Enemy X v] with (x position)
replace item (ID) of [Enemy Y v] with (y position)

Last edited by Pixilized (April 8, 2024 12:02:44)


MKYCATS2
Scratcher
80 posts

Need help with Tower Defense project

I have a problem with something that could really help with this. i haven't tried this, but is it possible to have clones that have the same variable with a different number for each clone (an id variable) and use and change it without messing with the other clones' variables? if so, use that. like this:
when green flag clicked
set [clones v] to (0)

when i receive [whatever you want v]
repeat (whatever)
change [clones v] by (1)
create clone of [myself v]
end

when i start as a clone
set [id variable v] to (clones)
add whatever you want here - the id variable will keep track of what list section it's supposed to
but if it isn't possible, then do the hard way:
when i start as a clone
if <(clones) = (1)> then
do ... for first
else
if <(clones) = (2)> then
do ... for second
else
more ifs
end
end
AlinGrozav
Scratcher
2 posts

Need help with Tower Defense project

Pixilized wrote:

Replace the cloneID variable with a new variable just called ID. This is because you need this variable to be “for this sprite only”. Then, each clone will have a different value if asked to report “ID” because the variable thinks the clones are new sprites. So, just use this block in the clone script.
define Update Position
replace item (ID) of [Enemy X v] with (x position)
replace item (ID) of [Enemy Y v] with (y position)


Thanks a lot , you`re a life saver.
Pixilized
Scratcher
100+ posts

Need help with Tower Defense project

No problem! I’m happy to help.

Powered by DjangoBB