In that code, you use the left/right arrowkeys to turn around the cube, and the up/down to zoom in.
The problem: When I color the cubes, they either 1) don't retain their colors and randomly switch, or 2) the cube somehow teleports to a random side when I'm not looking. I've tried many different options, such as removing the light, but if i do that then i can't see anything at all.
So if someone would please tell me what I'm doing wrong, that would be greatly appreciated.
#constant sqrSize 10
autocam off : hide mouse
sync on : sync rate 60
global currentFace as string
global currentFacePos as integer
dim faces(3) as string
faces(0) = "B"
faces(1) = "L"
faces(2) = "F"
faces(3) = "R"
currentFace = "F"
currentFacePos = 2
`make light 1
`set spot light 1,30,90
`set light range 1,50
`set normalization off
`set ambient light 15
`load image "tempTexture.jpg",1,0
make object box 1,sqrSize-1,sqrSize,1 : set object ambient 1,1 : color object 1,rgb(155,55,55)
make object box 2,sqrSize-1,sqrSize,1 : set object ambient 2,1 : color object 2,rgb(55,55,55)
offset limb 1,0,0,0,(sqrSize/2)-0.5
offset limb 2,0,0,0,(-sqrSize/2)+0.5
make object box 3,1,sqrSize,sqrSize : set object ambient 3,1 : color object 3,rgb(155,155,55)
make object box 4,1,sqrSize,sqrSize : set object ambient 4,1 : color object 4,rgb(155,55,155)
offset limb 3,0,sqrSize/2,0,0
offset limb 4,0,-sqrSize/2,0,0
make object sphere 5,-500 : color object 5,0 : set object ambient 5,0
set camera aspect 1
moveCamera(0,0,40)
d# = 40
a# = 0
do
if rightkey()
repeat : until (rightkey()) = 0
`a# = getCurrAng(currentFace)
if (currentFacePos) = 3
currentFacePos = 0
else
inc currentFacePos
endif
currentFace = faces(currentFacePos)
a# = wrapvalue(a#+90)
moveCamera(a#,-1,d#)
endif
if leftkey()
repeat : until (leftkey()) = 0
`a# = getCurrAng(currentFace)
if (currentFacePos) = 0
currentFacePos = 3
else
dec currentFacePos
endif
currentFace = faces(currentFacePos)
a# = wrapvalue(a#-90)
moveCamera(a#,1,d#)
endif
if upkey()
repeat : until upkey() = 0
dec d#,5
moveCamera(a#,0,d#)
endif
if downkey()
repeat : until downkey() = 0
inc d#,5
moveCamera(a#,0,d#)
endif
sync : loop
function moveCamera(currAng,increment,dist)
oldT = timer()
ang = int(currAng)
`dist = 40
amnt = 0
do
newT = timer()
if newT > oldT
x# = sin(ang)*dist
y# = 0
z# = cos(ang)*dist
position camera x#,y#,z#
` position light 1,x#,y#,z#
point camera 0,0,0
`point light 1,0,0,0
inc amnt
if amnt = 90 or increment = 0
exitfunction
endif
ang = wrapvalue(ang)
ang = ang + increment
endif
oldT = timer()
sync : loop
endfunction
function getCurrAng(f$)
select f$
case "B"
exitfunction 180
endcase
case "L"
exitfunction 90
endcase
case "F"
exitfunction 0
endcase
case "R"
exitfunction 270
endcase
endselect
endfunction -1