REM ***********************************************
REM Title: Cube
REM Author: Phaelax
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
sync on
autocam off
hide mouse
 
load image "ast4.bmp", 1
load image "bullet hole.bmp", 2
load image "clouds.bmp", 3
load image "fog.bmp", 4
load image "grass.bmp", 5
load image "rainbow2.bmp", 6
 
make_cube(1, 100)
 
texture_cube(1,1,1)
texture_cube(1,2,2)
texture_cube(1,3,4)
texture_cube(1,4,3)
texture_cube(1,5,5)
texture_cube(1,6,6)
 
 
position object 1, 0,0,300
 
 
 
do
 
 
   gosub camera_stuff
 
   sync
loop
 
 
 
function make_cube(obj, size#)
   make object plain obj, size#, size#
   size# = size#/2
   make mesh from object 1, obj
   offset limb obj, 0, 0, 0,-size#
 
   add limb obj,1,1
   add limb obj,2,1
   add limb obj,3,1
   add limb obj,4,1
   add limb obj,5,1
 
   offset limb obj, 1, 0, size#, 0
   rotate limb obj, 1, 90, 0, 0
 
   offset limb obj, 2, 0, 0, size#
   rotate limb obj, 2, 0, 180, 0
 
   offset limb obj, 3, 0, -size#, 0
   rotate limb obj, 3, 270, 0, 0
 
   offset limb obj, 4, -size#, 0, 0
   rotate limb obj, 4, 0, 270, 0
 
   offset limb obj, 5, size#, 0, 0
   rotate limb obj, 5, 0, 90, 0
 
   set object cull obj, 0
endfunction
 
 
 
function texture_cube(obj, side, img)
   side = side - 1
   texture limb obj, side, img
endfunction
 
 
 
camera_stuff:
  oldcx#=cx#
  oldcz#=cz#
  speed# = 5
  if upkey()=1
    cx#=newxvalue(cx#,a#,speed#)
    cz#=newzvalue(cz#,a#,speed#)
  endif
  if downkey()=1
    cx#=newxvalue(cx#,a#,-speed#)
    cz#=newzvalue(cz#,a#,-speed#)
  endif
  if leftkey()=1
    cx#=newxvalue(cx#,wrapvalue(a#-90.0),speed#)
    cz#=newzvalue(cz#,wrapvalue(a#-90.0),speed#)
  endif
  if rightkey()=1
    cx#=newxvalue(cx#,wrapvalue(a#+90.0),speed#)
    cz#=newzvalue(cz#,wrapvalue(a#+90.0),speed#)
  endif
 
 
  a#=wrapvalue(a#+(mousemovex()/3.0))
  cxa#=cxa#+(mousemovey()/3.0)
  if cxa#<-90.0 then cxa#=-90.0
  if cxa#>90.0 then cxa#=90.0
  `cy# = get_ground_height(1,cx#,cz#)
  position camera cx#,cy#+100,cz#
  rotate camera wrapvalue(cxa#),a#,0
RETURN