Okay, sorry about that.
Rem Project: fps
Rem Created: 24/04/2006 20:22:51
Rem ***** Main Source File *****
MaxEnemies=250
enemy=150
enemyglobalcount=0
enemycount=149
bulletnumber=5
hide mouse
`make player character
make object box 1, 2, 6, 2
make object sphere 6, 6
`make crude environment
`walls
make object box 50, 504, 10, 2
make object box 51, 504, 10, 2
make object box 52, 2, 10, 500
make object box 53, 2, 10, 500
`ground
make object box 55, 500, 1, 500
`bullets
make object cube 10, 1
make object cube 11, 1
make object cube 12, 1
make object cube 13, 1
make object cube 14, 1
`position player, walls, ground
position object 1, 250, 6, 250
position object 50, 250, 5, 501
position object 51, 250, 5, -1
position object 52, -1, 5, 250
position object 53, 501, 5, 250
position object 55, 250, 0, 250
color object 55, rgb(0, 128, 0)
set camera fov 60
set global collision on
do
ox#=Object Position x(6)
oy#=Object Position y(6)
oz#=Object Position z(6)
rem set camera position and angle to head
position camera object position x(1), object position y(1)+3, object position z(1)
rotate camera camera angle x()+(mousemovey()/3.0), object angle y(1), object angle z(1)
rotate object 1, 0, object angle y(1)+(mousemovex()/3.0), 0
if camera angle x()>-180 and camera angle x()<-90 then xrotate camera -90
if camera angle x()>90 and camera angle x()<180 then xrotate camera 90
rem Basic forward/backward/left/right movement
if upkey()=1 then move object 1, 0.5
if downkey()=1 then move object 1, -0.5
if leftkey()=1 then move object left 1, 0.5
if rightkey()=1 then move object right 1, 0.5
position object 6, object position x(1), object position y(1), object position z(1)
nx#=Object Position x(6)
ny#=Object Position y(6)
nz#=Object Position z(6)
rem sliding collision XX
`now that we're done moving the collider around, we'll check to see if there's
`a collision
if object collision(6, 0)>49 and object collision(6, 0)<101
`The player's requested move caused a collision, so we'll try to give them
`as much of their move as we can without allowing them to collide
`So first off we'll see if using the old X value eliminates the collision condition
position object 6, ox#, ny#, nz#
if object collision(6, 0)>49 and object collision(6, 0)<101
`Using the old X value did not eliminate the collision. Now we'll try the
`old Z value.
Position object 6, nx#, ny#, oz#
if object collision(6, 0)>49 and object collision(6, 0)<101
`Using the old Z value did not eliminate the collision, so now we'll
`see if the new Y value is the one causing the problem.
Position Object 6, nx#, oy#, nz#
if object collision(6, 0)>49 and object collision(6, 0)<101
`Ok, nothing we've tried will eliminate the collision condition, so
`we'll just put the player back where they started from.
ny#=oy#
nx#=ox#
nz#=oz#
Else
`The new Y value, was the problem, so we'll just set the Y value back to OY#
ny#=oy#
EndIf
Else
`The New Z value was the problem so we'll set it back to OZ#
nz#=oz#
EndIf
else
`The new X value was the culprit, so we'll set it back to OX#
nx# = ox#
endif
EndIf
Position Camera nx#, ny#, nz#
Position Object 6, nx#, ny#, nz# : position object 1, nx#, ny#, nz#
`shooting and bullet control
if mouseclick()=1 and bulletnumber>0
show object 10+GlobalBullet
position object 10+GlobalBullet, camera position x(), camera position y(), camera position z()
rotate object 10+GlobalBullet, camera angle x(), camera angle y(), 0
GlobalBullet=GlobalBullet+1
if GlobalBullet=5 then GlobalBullet=0
bulletnumber=bulletnumber-1
endif
for bullet=10 to 14
if object collision (bullet, 0)>49
hide object bullet
position object bullet, -10, -10, -10
rotate object bullet, 0, 0, 0
bulletnumber=bulletnumber+1
endif
move object bullet, 1
next bullet
`artificial intelligence
if EnemyCount<MaxEnemies then MakeEnemy=1
if MakeEnemy=1
make object box enemy+EnemyGlobalCount, 2, 6, 2
position object enemy+EnemyGlobalCount, rnd(500), 5, rnd(500)
rotate object enemy+EnemyGlobalCount, 0, rnd(360), 0
color object enemy+EnemyGlobalCount, rgb(0, 0, 128)
EnemyCount=EnemyCount+1
EnemyGlobalCount=EnemyGlobalCount+1
MakeEnemy=0
endif
for b=150 to EnemyCount
`move enemy
OldX#=object position x(b)
OldY#=object position y(b)
OldZ#=object position z(b)
move object b, 0.25
if object collision(b, 0) <> 0
position object b, OldX#, OldY#, OldZ#
rotate object b, 0, rnd(360), 0
move object b, 0.25
endif
`response to player
dx#=object position x(1)-object position x(b)
dy#=object position y(1)-object position y(b)
dz#=object position z(1)-object position z(b)
dist#=abs(sqrt(abs(dx#*dx#)+abs(dy#*dy#)+abs(dz#*dz#)))
viewa#=wrapvalue(atanfull(dx#,dz#))
if dist#<60
rotate object b, 0, viewa#, 0
endif
next b
print enemycount, " ", bulletnumber
loop
As you can see, the ground isn't a matrix, just a massive cuboid. Maybe
that's the problem?