Trying to build some 360 x 360 degree orbit code for my personal library here. I'm having no trouble getting the Y axis orbit rotation correct. The Z on the other hand is killing me. I don't know if it's just not possible or if I'm missing the something. I know I should probably using SIN, COS, TAN but I'm just not good in math and I prefer to use these commands as they are more "beginner" intended. The new value command seems to do what I want but I just cant get it right. Thanks if you can help!
Left / Right arrow keys Orbit around Y axis.
Up / Down arrow keys should orbit around Z Axis.
Rem Project: Orbit Experimentation
Rem Created: 1/3/09 3:29:22 PM
Rem ***** Main Source File *****
Set Display mode 1024,768,32
MAKE CAMERA 1
SET CAMERA VIEW 1,599,0,1024,300
COLOR BACKDROP 1,rgb(0,0,0)
SET CAMERA RANGE 1,10,20000
SYNC ON
Make Matrix 1,400,400,20,20
position matrix 1,-200,0,-200
make object cube 1, 10
position object 1,0,-10,20
Make Object Cube 2,5
color object 2,rgb(255,0,0)
position camera 0,0,30,-50
Position Camera 1,0,100,0
Point_Camera(0,1)
Point_Camera(1,1)
YAngle# = OBJECT ANGLE Y(1)
ZAngle# = OBJECT ANGLE Z(1)
Do
If LeftKey()
Yangle# = wrapvalue(Yangle# - .1)
SXVal# = NEWXVALUE(Object position X (1), YAngle#,32)
SZVal# = NEWZVALUE(Object position Z (1), YAngle#,32)
Position Object 2, SXVal#,SYVal#,SZVal#
Endif
If RightKey()
Yangle# = wrapvalue(Yangle# + .1)
SXVal# = NEWXVALUE(Object position X (1), YAngle#,32)
SZVal# = NEWZVALUE(Object position Z (1), YAngle#,32)
Position Object 2, SXVal#,SYVal#,SZVal#
Endif
If UpKey() `NOTE UPKEY CODE NOT CORRECT
ZAngle# = wrapvalue(ZAngle# + .1)
SXVal# = NEWXVALUE(Object position X (1), ZAngle#,32)
SYVal# = NEWYVALUE(Object position Y (1), ZAngle#,32)
Position Object 2, SXVal#,SYVal#,SZVal#
Endif
If DownKey() `NOTE DOWNKEY CODE NOT CORRECT
ZAngle# = wrapvalue(ZAngle# - .1)
SXVal# = NEWXVALUE(Object position X (1), ZAngle#,32)
SYVal# = NEWYVALUE(Object position Y (1), ZAngle#,32)
Position Object 2, SXVal#,SYVal#,SZVal#
endif
Point_Object(2,1)
sync
loop
Function Point_Camera(Camera,Object_Number)
Point Camera Camera, Object Position X(Object_Number),Object Position Y(Object_Number),Object Position Z(Object_Number)
Endfunction
Function Point_Object(Object_Number_1,Object_Number_2)
Point Object Object_Number_1, Object Position X(Object_Number_2),Object Position Y(Object_Number_2),Object Position Z(Object_Number_2)
Endfunction
Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Long Island Amateur Game Development Group http://www.meetup.com/LIAGDG/