I think this code will help you. It sets up multiple cameras and has a Tetris-like game on the left and has 3D spheres bouncing around on the right. The spheres are not animated, but you could easily put something animated there.
` 2D and 3D screens together - LBFN 10/19/09
sync on : sync rate 60
backdrop on : color backdrop 0
randomize timer()
hide mouse
global ScreenWidth as integer : ScreenWidth = screen width()
global ScreenHeight as integer : ScreenHeight = screen height()
global MoveDelay# as float : MoveDelay# = timer()
global Tspeed as integer : TSpeed = 6 : global MoveDir as integer
global tx as integer : global ty as integer
dim direction(5)
direction(1) = 2 : direction(2) = 10 : direction(3) = 9
direction(4) = 5 : direction(5) = 6
global XSpeed# as float : XSpeed# = 1.0
global YSpeed# as float : YSpeed# = 1.0
for d = 1 to 5
make object sphere d,20
if d = 1 then set object ambience 1,rgb(255,0,0)
if d = 2 then set object ambience 2,rgb(255,255,0)
if d = 3 then set object ambience 3,rgb(255,0,255)
if d = 4 then set object ambience 4,rgb(0,255,0)
if d = 5 then set object ambience 5,rgb(0,0,255)
position object d,100.0,10.0,-50.0
next d
MakeImages()
MakeCameras()
ink rgb(255,255,0),0
repeat
text 10,10,"FPS: " + str$(screen fps())
ShowGraphics()
for d = 1 to 5
MoveObj(d)
next d
GetInput()
MoveTetris()
` Debug()
sync
until spacekey() = 1
DeleteStuff()
show mouse
end
function ShowGraphics()
ink rgb(255,255,255),0
line 20,40,20,ScreenHeight - 20 : line 20,ScreenHeight - 20, (Screenwidth / 2) - 1,ScreenHeight -20
line (Screenwidth / 2) - 1,40,(Screenwidth / 2) - 1,ScreenHeight - 20
endfunction
function MakeCameras()
SET CAMERA VIEW 0, 0, 0, ScreenWidth - 1, ScreenHeight
make camera 1
SET CAMERA VIEW 1, ScreenWidth / 2,0,ScreenWidth,ScreenHeight
color backdrop 1,rgb(180,0,180)
x# = object position x(1) : y# = object position y(1) : z# = object position z(1)
position camera 1,x#,y# + 50.0,z# - 200.0
point camera 1,x#,y#,z#
endfunction
function MakeImages()
create bitmap 1,96,96
ink rgb(255,0,0),0
box 0,17,22,31 : box 24,17,46,31 : box 48,17,70,31 : box 24,1,46,15
get image 100,0,0,70,32
cls
ink rgb(0,128,255),0
box 0,1,22,15 : box 24,1,46,15 : box 24,17,46,31 : box 48,17,70,31
get image 101,0,0,70,32
cls
ink rgb(255,255,0),0
box 0,1,22,15 : box 0,17,22,31 : box 0,33,22,47 : box 0,49,22,63
get image 102,0,0,24,72
cls
ink rgb(255,0,255),0
box 0,17,22,31 : box 24,17,46,31 : box 48,17,70,31 : box 24,1,46,15
get image 103,0,0,70,32
delete bitmap 1 : create bitmap 1,(ScreenWidth / 2),ScreenHeight - 18
rem make pseudo-Tetris
delete bitmap 1 : set current bitmap 0
sprite 100,48,ScreenHeight - 52,100
sprite 101,96,ScreenHeight - 52,101
sprite 102,192,ScreenHeight - 84,102
tx = (ScreenWidth / 4) - 40 : ty = -36
sprite 103,tx,ty,103
endfunction
function DeleteStuff()
for d = 1 to 5
delete object d
next d
delete camera 1
for d = 100 to 103
delete image d
delete sprite d
next d
endfunction
function MoveObj(obj)
`if obj = 5 then text 100,80,"5 direction = " + str$(direction(obj))
select direction(obj)
case 1
move object up obj,YSpeed#
y# = object position y(obj)
if y# > 107.0 then direction(obj) = 2
endcase
case 2
move object down obj,YSpeed#
y# = object position y(obj)
if y# < -132.0
` pick rnadom direction
nd = rnd(100)
if nd < 20 then direction(obj) = 1
if nd >= 20 and nd <= 60 then direction(obj) = 9
if nd > 60 then direction(obj) = 5
endif
endcase
case 5
x# = object position x(obj) : y# = object position y(obj)
x# = x# + XSpeed# : y# = y# + YSpeed#
position object obj,x#,y#,object position z(obj)
if y# > 107.0 then direction(obj) = 6
if x# > 262.0 then direction(obj) = 9
endcase
case 6
x# = object position x(obj) : y# = object position y(obj)
x# = x# + XSpeed# : y# = y# - YSpeed#
position object obj,x#,y#,object position z(obj)
if x# > 262.0 then direction(obj) = 10
if y# < -132.0 then direction(obj) = 5
endcase
case 9
x# = object position x(obj) : y# = object position y(obj)
x# = x# - XSpeed# : y# = y# + YSpeed#
position object obj,x#,y#,object position z(1)
if x# < - 52.0 then direction(obj) = 5
if y# > 107.0 then direction(obj) = 10
endcase
case 10
x# = object position x(obj) : y# = object position y(obj)
x# = x# - XSpeed# : y# = y# - YSpeed#
position object obj,x#,y#,object position z(obj)
if x# < - 52.0 then direction(obj) = 6
if y# < -132.0 then direction(obj) = 9
endcase
endselect
endfunction
function Debug()
`text 10,30,"x# = " + str$(object position x(1))
`text 10,50,"y# = " + str$(object position y(1))
`text 10,70,"z# = " + str$(object position z(1))
text 10,90,"tx = " + str$(tx)
text 10,110,"ty = " + str$(ty)
endfunction
function GetInput()
if leftkey() = 1 then MoveDir = 8
if rightkey() = 1 then MoveDir = 4
if downkey() = 1 then MoveDir = 2
endfunction
function MoveTetris()
if timer() > MoveDelay#
if MoveDir = 8 and tx > 20 then tx = tx - TSpeed
if MoveDir = 4 and tx < (ScreenWidth / 2) - sprite x(103) then tx = tx + Tspeed
if MoveDir = 2 and ty < 396 then ty = ty + TSpeed
if ty <= 394
ty = ty + TSpeed
sprite 103,tx,ty,103
endif
MoveDelay# = timer() + 200.0
endif
endfunction
I hope this is helpful.
LB
So many games to code......so little time.