# Better Movement Tutorial

Teaches about using trig to move objects better and more realistically

Original Author: Dude2

### Code

`Hey everyone! Have you ever wondered fow to get your objects to move everywhere (instead of up, down, left and right)? If so, read on!In math, there are two functions calles Sine and Cosine. I could get into all the details on how they work, but i'm pretty sure you'll get bored. Anyway, you use them in vb as Sin(x) and Cos(x) with x being a number. To implement it in a moving sub would be like:Sub moveit(angle as double)x = x + sin(angle)y = y + cos(angle)End SubGo ahead, try it! You find that if you put in a degree (like 90, which should make it go to thr right), it WILL NOT WORK. That is because you need to get radians and multiply them by the degrees. That is where mist newbies screw up. To get the amount of one radian, you do this:Const Pi = 3.14Const Rad = 3.14 / 180Then, we make a little change to the procedure:Sub moveit(angle as integer)x = x + sin(angle * rad)y = y + cos(angle * rad)end suband that is basically it.C U Later!Dude2PS> Please vote for me if you think it is good/helpful!`

Posted: 2002-06-01
By: ArchiveBot
Viewed: 80 times

Categories

Visual Basic 6

Attachments

No attachments for this post