This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-08 12:26:03

deebs17
New Scratcher
Registered: 2012-10-08
Posts: 2

RTS movement mechanic.

I'm in the middle of making an RTS on scratch but I've run into a problem. I need to be able to have the sprite glide to the location I click, however the time it takes needs to vary on the distance. So 10 pixels could take a second but 100 pixels could take 10 seconds. I already have : when flag clicked, forever, if mouse down? and selected = 1 (variable), point towards mouse pointer, Glide 2 seconds to x: mouse x y: mouse y.
any Ideas? sorry for no scratch blocks, I didn't want to get it wrong.

Offline

 

#2 2012-10-08 12:29:42

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: RTS movement mechanic.

when gf clicked
forever
 if <mouse down?>
  point towards [mouse-pointer v]
  glide ((distance to [mouse-pointer v]) * (0.1)) secs to x: (mouse x) y: (mouse y)
 end
end
smile

Offline

 

#3 2012-10-08 12:33:41

deebs17
New Scratcher
Registered: 2012-10-08
Posts: 2

Re: RTS movement mechanic.

thanks, really needed it.

Offline

 

#4 2012-10-08 12:37:21

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: RTS movement mechanic.

No problem! Good luck with your project.  smile

Offline

 

Board footer