Saturday, April 25, 2009

If you are familiar with scratch and you don't know how to use x and y velocity on it then here's how.First you make two variables:X velocity and Y velocity.Then you make you're sprite.
Make it so that when the right arrow key is pressed and X velocity is less then the maximum speed which is say 5,Change X velocity by 0.5 .And the same when left arrow key pressed exept if it is more than -5 or minus the max speed limit and change it by -0.5 .Then when up arrow key pressed, if Y velocity is less than your max speed,change it by 0.5.The same gos for down arrow key exept minus the max speed and change it by -0.5 .Then make it so that forever- If not the right or left arrow keys are pressed,if X velocity is more than 0,change it by -0.5 and if it's less than 0 change it by 0.5 .Then make that with Y velocity.And now finally make it forever change X by X velocity and change Y by Y velocity.And there you have it-it moves smoothly.Now if you want it to not be able to crash into walls make the right side of the wall say blue and the left side say green.Now say forever-If X velocity is more than 0 and touching blue (right side of wall) set X velocity to 0 and if it's less than 0 and touching green (left wall) set it to 0.The same gos for Y velocity.This was my first blog and I hope you enjoyed it and thankyou for reading.Here is a scratch project I made with it-ball flyer-scratch.

No comments:

Post a Comment