Rem Project: Text RPG
Rem Created: 10/08/2005 00:40:10
 
Rem ***** Main Source File *****
 
sync on : sync rate 0
 
type item
   ty as string
   ext1 as integer
   ext2 as string
   ext3 as float
   ext4 as integer
endtype
 
type levelData
   width as integer
   height as integer
   method as string
endtype
 
global currentLevel as levelData
 
position camera 10,2,10
buildLevel()
 
sync
do
 
   control camera using arrowkeys 0,.1,1
   text 20,20,str$(screen fps())
 
   sync
loop
end
 
 
function buildLevel()
 
   xPtr as integer : yPtr as integer
 
   restore level1
 
   read currentLevel.method
   if currentLevel.method = "tiled"
      read currentLevel.width
      read currentLevel.height
 
      dim level(currentLevel.width,currentLevel.height) as string : Rem * 4 because tiles are 4x4
 
      c=1
      for xPtr=1 to currentLevel.width
         for yPtr=1 to currentLevel.height
                  read level(xPtr,yPtr)
                  select level(xPtr,yPtr)
                     case "0"
                        make object plain c,1,1
                        position object c,xPtr,-.5,yPtr
                        xrotate object c,90
                     endcase
                     case "1"
                        make object cube c,1
                        position object c,xPtr,0,yPtr
                     endcase
                     case "2"
                        make object plain c,1,1
                        position object c,xPtr,-.5,yPtr
                        xrotate object c,90
 
                        make object cube c+1,.75
                        position object c+1,xPtr,-.25,yPtr
                     endcase
                     case "3"
                        make object plain c,1,1
                        position object c,xPtr,-.5,yPtr
                        xrotate object c,90
 
                        position camera xPtr,2,yPtr
                     endcase
                     case "4"
                        make object plain c,1,1
                        position object c,xPtr,-.5,yPtr
                        xrotate object c,90
 
                        make object cube c+1,1
                        color object c+1,rgb(100,100,100)
                        position object c+1,xPtr,0,yPtr
                     endcase
                     case "5"
                        make object plain c,1,1
                        position object c,xPtr,-.5,yPtr
                        xrotate object c,90
 
                        make object cube c+1,1
                        color object c+1,rgb(255,0,0)
                        position object c+1,xPtr,0,yPtr
                     endcase
                  endselect
                  inc c,2
         next yPtr
      next xPtr
 
   endif
 
endfunction
 
`0 = floor/nothing
`1 = wall
`2 = random objecty sh!te <- THAT IS NOT BAD LANGUAGE :@
`3 = start
`4 = door
`5 = enemy
 
level1:
rem style and dimensions
data "tiled",20,20
rem data
data "1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"
data "1","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","2","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","5","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","1","4","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","2","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","3","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1"
data "1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"