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

#1 2012-07-19 06:10:19

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Gliding without using glide

So yeah, towards a specific point on the screen in a specific amount of time without using the glide block?

Oh, and without using any movement blocks except for the change x and y position...

Offline

 

#2 2012-07-19 06:11:58

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Gliding without using glide

Sure. Gimme a second.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#3 2012-07-19 06:41:34

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Gliding without using glide

when gf clicked
go to x:(0) y:(0)
set [ox v] to (x position)
set [oy v] to (y position)
set [x v] to [100]
set [y v] to [50]
set [time v] to [2]
repeat ((time)*(100))
change x by (((x)-(ox))/((time)*(100)))
change y by (((y)-(oy))/((time)*(100)))
wait (((1)/(100))-(calibration)) secs // calibration is a very small number to adjust for delays in the repeat block
end

Last edited by Hardmath123 (2012-07-19 06:41:52)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4 2012-07-19 06:43:53

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Gliding without using glide

Thank you!
You never actually declared calibration though... what should it be?

Offline

 

#5 2012-07-19 06:50:29

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Gliding without using glide

LS97 wrote:

Thank you!
You never actually declared calibration though... what should it be?

Well... I didn't tinker enough, but it should be really, really small, like 0.0005-ish. It's to counter-balance the delay induced by repeat until and wait. Hold on, I'll quickly write a program to find it out for me.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6 2012-07-19 06:53:37

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Gliding without using glide

0.03 works fine.  smile  But change all instances of 100 to 10 or 25, otherwise you'll be waiting negative time...  tongue


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#7 2012-07-19 07:59:14

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Gliding without using glide

Hardmath123 wrote:

0.03 works fine.  smile  But change all instances of 100 to 10 or 25, otherwise you'll be waiting negative time...  tongue

OK, thank you very much!  big_smile

Offline

 

#8 2012-07-19 08:25:51

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Gliding without using glide

You're welcome.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#9 2012-07-19 10:23:48

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Gliding without using glide

when gf clicked
set [goal x v] to [100]
set [goal y v] to [100]
set [time v] to [3]
set [start v] to (timer)
set [start x v] to (x position)
set [start y v] to (y position)
repeat until <((timer)-(start)) > (time)>
  change x by (((((goal x)-(start x))*(((timer)-(start))/(time)))+(start x))-(x position))
  change y by (((((goal y)-(start y))*(((timer)-(start))/(time)))+(start y))-(y position))
end
change x by ((goal x)-(x position))
change y by ((goal y)-(y position))
...why no goto block? 0.o


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

Board footer