Quote: "how can you tell which is x and which is y if they can both be left to right and up to down?!?! ahhh!"
It seems that you are reading UPKEY() ,DOWNKEY(), LEFTKEY(), RIGHTKEY() as meaning up (towards the sky), down (towards the earth) left and right. UPKEY(), DOWNKEY() etc. are the control names of the arrow keys on your keyboard. The names don't really mean anything except to tell you (and the computer) which key you are pressing.
The directions in the 3D world are their own thing, so try and separate your mind from the direction in the world and the name of the control keys.
The other thing that you seem to be confusing, is rotation versus position as BN2 mentioned above.
if upkey()=1 then xAng=wrapvalue(xAng+1)
What I can assume from this code is that the x
ANGLE not the x coordinate or the x position, but the
ANGLE is being changed by pressing the up arrow key. That means the object is
tilting forward or backward
not moving forward or backward or up or down.
if upkey()=1 then yPos=yPos+1
From this code, I can assume that the y
POSITION is changing by pressing the up arrow key. This is different from an angle changing which would cause rotation or tilt.
In general, if you are looking straight into your computer screen, the axes' directions are Y is up and down, X is left and right, and Z is straight into the monitor.
I knocked together a small bit of code that will allow you to move the camera around on the screen. The program will display your current X,Y and Z position as well as the current angles the camera is rotated at. In the center of the screen is a 3D axis that show what direction you are currently heading.
Steer with the mouse including some limited looking up and down, and move forward or backward with the up and down arrows keys. You'll notice that if you change direction, pressing the UP KEY won't always mean what you think it will. The code may be too difficult for you to understand just yet, but it's really the running of the code and seeing how the directions you face can change and the axis you are on can switch that's important.
Copy the code into your dark basic editor and press F5 to run it:
set display mode 800,600,32
sync on
sync rate 60
autocam off
hide mouse
rem make a matrix for reference
make matrix 1,1000,1000,25,25
rem make an axis
ink rgb(255,0,0),0
text 0,128,"-X"
line text width("-X")+5,128,(256-5)-(text width("+X")),128
text (256-5)-(text width("+X")),128,"+X"
ink rgb(0,255,0),0
text 128,0,"+Y"
line 128,text height("-Y")+5,128,(256-5)-(text height("+Y"))
text 128,(256-5)-(text height("-Y")),"-Y"
get image 1,0,0,256,256
sync
cls
ink rgb(0,0,255),0
text 0,128,"-Z"
line text width("-Z")+5,128,(256-5)-(text width("+Z")),128
text (256-5)-(text width("+Z")),128,"+Z"
get image 2,0,0,256,256
sync
make object plain 1,25,25
make mesh from object 1,1
add limb 1,1,1
delete mesh 1
rotate limb 1,1,90,270,90
texture object 1,1
texture limb 1,1,2
set object 1,1,0,0
ink rgb(0,255,255),0
color backdrop 0
do
text 0,0,"Camera Rotations (angles) : "
text 0,20,"Camera angle X = "+str$(camera angle x())
text 0,40,"Camera angle Y = "+str$(camera angle y())
text 0,60,"Camera angle Z = "+str$(camera angle z())
text 0,100,"Cameras 3D position (on X, Y, and Z axes) : "
text 0,120,"Camera position X = "+str$(camera position x())
text 0,140,"Camera position Y = "+str$(camera position y())
text 0,160,"Camera position Z = "+str$(camera position z())
gosub _move_camera
sync
loop
`----------------------------------------------------------------
_move_camera:
newx#=newxvalue(camera position x(),yang#,(upkey()-downkey())*5)
newz#=newzvalue(camera position z(),yang#,(upkey()-downkey())*5)
position camera newx#,13,newz#
yang#=wrapvalue(camera angle y()+mousemovex())
dec xang#,mousemovey()
if xang# > 20 then xang#=20
if xang# < -20 then xang#=-20
rotate camera wrapvalue(xang#),yang#,0
newx#=newxvalue(camera position x(),yang#,25)
newz#=newzvalue(camera position z(),yang#,25)
position object 1,newx#,camera position y()+2,newz#
return
`----------------------------------------------------------------
Positions in the 3d world are given based on an X,Y and Z coordinate system. Up, Down, Left, and Right don't really exist because they are always relative to the current orientation of either the camera, or another object. Orientation means "how something is rotated." The camera could be upside down in the 3D world but relative to that view, "up" could be -Y which seems to be the opposite of what one would expect.
However, the world axes are always oriented the same way. While the camera can rotate, or an object can rotate, the world axes stay the same. If the camera hasn't rotated at all and is at 0,0,0, then up, relative to the camera is +Y. To the world, up is also +Y. Now let's say I rotated the camera on it's Z axes 90 degrees so that it is basically on it's side. You can try this yourself by laying on your side on the floor. Up, in relation to the camera, would be on the -X axis or in relation to where the top of your head would be pointing if you were laying on the floor on your side; but to the 3D world (not the camera), up is still +Y or towards the ceiling of your house in the real world.
Does that make any sense?
Enjoy your day.