I'll try to come up with some small "game"like code using wasd and arrowkeys to move 2 players separately...
EDIT:
sync on : sync rate 100
`Create world
make matrix 1, 100, 100, 50, 50
position matrix 1, -50, 0, -50
`Create player 1
make object cube 1, 2
color object 1, rgb(0, 255, 0)
position object 1, -50, 1, -50
point object 1, 50, 1, 50
`Create player 2
make object cube 2, 2
color object 2, rgb(0, 0, 255)
position object 2, 50, 1, 50
point object 2, -50, 1, -50
`Setup an array (to store the camera's position)
`2 cameras
`3 values to store (x, y and z positions)
dim Camera#(2, 3)
`>> Reset the 2 camera's
Camera#(1, 1) = -60 : Camera#(1, 2) = 20 : Camera#(1, 3) = -60
Camera#(2, 1) = 60 : Camera#(2, 2) = 20 : Camera#(2, 3) = 60
do
ink 0, 0
box 320, 0, 639, 239
ink rgb(255, 255, 255), 0
text 325, 5, str$(screen fps())
`Control players
`PLAYER 1 CONTROLS
if upkey() > 0 then move object 1, 1
if downkey() > 0 then move object 1, -1
if leftkey() > 0 then yrotate object 1, wrapvalue(object angle y(1) - 4)
if rightkey() > 0 then yrotate object 1, wrapvalue(object angle y(1) + 4)
`PLAYER 2 CONTROLS
if keystate(17) > 0 then move object 2, 1
if keystate(31) > 0 then move object 2, -1
if keystate(30) > 0 then yrotate object 2, wrapvalue(object angle y(2) - 4)
if keystate(32) > 0 then yrotate object 2, wrapvalue(object angle y(2) + 4)
`>> Update cameras
for c = 1 to 2
ChaseCam(c, c)
next c
`>> Draw camera to the screen
position camera Camera#(1, 1), Camera#(1, 2), Camera#(1, 3)
point camera object position x(1), object position y(1), object position z(1)
set camera view 0, 0, 320, 240
position camera Camera#(2, 1), Camera#(2, 2), Camera#(2, 3)
point camera object position x(2), object position y(2), object position z(2)
set camera view 320, 240, 640, 480
sync
loop
`>> This function handles the camera (partly based on binary moons tutorial)
function ChaseCam(cam, obj)
`Get player data
posx# = object position x(obj)
posy# = object position y(obj)
posz# = object position z(obj)
ay# = wrapvalue(object angle y(obj) - 180)
`Calculate camera position
camx# = newxvalue(posx#, ay#, 10.0)
camy# = posy# + 5.0
camz# = newzvalue(posz#, ay#, 10.0)
`Smoothen camera values
camx# = curvevalue(camx#, Camera#(cam, 1), 15)
camy# = curvevalue(camy#, Camera#(cam, 2), 15)
camz# = curvevalue(camz#, Camera#(cam, 3), 15)
`Update camera
Camera#(cam, 1) = camx#
Camera#(cam, 2) = camy#
Camera#(cam, 3) = camz#
endfunction
I have to say it looks pretty good to me...
It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.