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

#1 2008-10-12 18:13:14

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

Help with Velocity

I am making a stealball game where you have to hit the ball and get it away from your oponent.I just need help with the balls physics.I need so that the harder you hit the ball the faster it goes,But i also want the ball to slow down.Im not great with this kind of math so i just made up a script.
http://scratch.mit.edu/projects/keroro645/290423

Offline

 

#2 2008-10-12 19:55:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Help with Velocity

To determine the power of the shot find how fast the cursor is moving.

like this
forever
Set power to 0
change power by ABS( oldX-x position)
change power by ABS( oldY-y position)
set power to (power*0.1) //You may want to lower this variable or it will make the ball go crazy
set oldX to xposition
set oldY to yposition
end

When the ball is hit do this

when touching (paddle)
change velocity by power


To lower velocity do this
forever
set velocity to (velocity*0.95)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer