Main Menu

2D VECTORS

Started by gingerprince, October 03, 2006, 02:24:08 PM

Previous topic - Next topic

gingerprince

If I have an object (2d) at coords OBJECTX,OBJECTY moving at any angle (0 - 360) at velocity `VEL`.
How do I calculate the DELTAX,DELTAY value to add to OBJECTX,OBJECTY coords to allow me to move the object?

cheers!


kevin

#1
 COS() and SIN()


PlayBASIC Code: [Select]
 setfps 60
Angle#=rnd(360)

Speed#=2

x#=400
y#=300

do
cls 0

; option 1
; x#=x#+cos(angle#)*Speed#
; y#=y#+sin(angle#)*Speed#
; circle x#,y#,10,true


; option 2
; x#=x#+cosRadius(angle#,Speed#)
; y#=y#+sinRadius(angle#,Speed#)
; circle x#,y#,10,true

; option 2
x#=cosNewValue(x#,angle#,Speed#)
y#=sinNewValue(y#,angle#,Speed#)
circle x#,y#,10,true


if spacekey() then angle#=rnd(360)

Sync
loop







  2D vector Library

gingerprince