Discuss Scratch

BilboUnicorn
Scratcher
26 posts

Targeting?

So what I am trying to do is have a laser target a specific sprite, destroy it, then move on to another. And it can't just be going after ANY sprite. Here's an attempt of an example. N is the must-not-be-destroyed item, L is the laser that must be ‘heat seaking’, and T are the three targets that it needs to go after based on which ones are closest. Any ideas?



N L


T



T

T
BilboUnicorn
Scratcher
26 posts

Targeting?

Seven views but still no ideas…
drmcw
Scratcher
1000+ posts

Targeting?

Search for tower defense games they do that and I think scubajerry has a few good examples of this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.

Last edited by drmcw (Oct. 25, 2013 06:38:42)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
BilboUnicorn
Scratcher
26 posts

Targeting?

drmcw wrote:

Search for tower defense games they do that and I think scubajerry has a few good examples of this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.
Thanks, that's exactly what I needed!
scubajerry
Scratcher
1000+ posts

Targeting?

drmcw wrote:

Search for tower defense games they do that and I think scubajerry has a few good examples of this.. You just need to store the distance of each target, find the smallest and target that. If the targets are sprites then use the distance to block. If they are clones then you'll need to store the x,y positions and/or distance to laser in a list anyway.

That was my first try. This one is more general purpose.

Powered by DjangoBB