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

#1 2010-08-27 16:55:30

pip
Scratcher
Registered: 2008-01-17
Posts: 14

Catapult Problems...

Hi,
I have been trying to make a catapult game in which you pull back this cup on a string with a rock in it, let it go, and try to hit a target. My problem? My problem is that when you let go of the cup, it needs to spring back to it's original location, rather quickly. Of course I could have it go there instantly but I think it would look better animated. So, I came up with this. -145 being the orriginal x position

repeat (-145 minus x position)
change x by 1
end repeat

That worked fine except for one thing: It was horribly slow.
So then I did this

repeat (-145 minus x position divided by 15)
change x by 15
end repeat

That would have worked but of course, unless they drag it back a multiple of 15, it will miss it's original location.

Any ideas? Thanks, Pip  smile

Offline

 

#2 2010-08-27 17:01:04

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Catapult Problems...

{repeat (round( ( (-145 - x position) / 15) -0.5 ) )
[change x by 15]
end repeat}
[change x by ( (-145 - x position) mod 15)]

Hope that helps  wink

Last edited by SeptimusHeap (2010-08-27 17:01:36)


http://i46.tinypic.com/dw7zft.png

Offline

 

#3 2010-08-27 17:15:58

pip
Scratcher
Registered: 2008-01-17
Posts: 14

Re: Catapult Problems...

Great, thanks

Offline

 

#4 2010-08-27 17:34:59

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Catapult Problems...

Or you could use the <glide( - )secs to x sad  - )y sad  block.  wink

Last edited by Jwosty (2010-08-27 17:35:17)


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#6 2010-08-27 17:41:48

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Catapult Problems...

rdococ wrote:

That was what I was thinking, Jwosty!

big_smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

Board footer