I didn't see where you had put in for the bullets. Anyway, this code makes a sphere where the player is when the LMB is clicked. The bullet can collide with the enemy. The enemy object is simply hidden and is not repositioned.
I used the same coordinates as you did for checking the boundaries for the bullet, but doing it this way seems very limiting. You're not always going to have this exact same size of room. I would suggest allowing the bullet to move a certain amount of times before it dies. With regard to the player, you could check collision against the outer walls instead of physical X and Z coordinates.
Rem Project: 3rd person game
Rem Created: Saturday, August 28, 2010
Rem ***** Main Source File *****
`Set display
set global collision on
set display mode desktop width(),desktop height(),16
set window off
autocam off
hide mouse
sync on
sync rate 60
`set point light 0,-2000,1000,-750
shoot = 0 : moves = 0 : bullet = 50
EnemyStatus = 1
`Camera
position camera 0,250,-800
point camera 0,-30,0
set camera range 10,100000
`Flor
make object box 1,1000,10,1000
position object 1,0,-100,150
color object 1,RGB(172,99,27)
set object collision on 1
`walls
make object box 3,1000,250,10
position object 3,0,30,650
color object 3,rgb(200,100,0)
make object box 4,1000,250,10
position object 4,0,30,-350
color object 4,rgb(200,100,0)
make object box 6,10,250,1000
position object 6,500,30,150
color object 6,rgb(200,100,0)
make object box 7,10,250,1000
position object 7,-500,30,150
color object 7,rgb(200,100,0)
`World floor
make object box 8,5000,10,5000
position object 8,0,-101,150
color object 8,RGB(62,146,36)
set object collision on 3
`Player
make object box 2,35,75,10
position object 2,0,190,-50
color object 2,rgb(0,255,255)
set shadow shading on 2
`Fake player
make object box 5,35,75,10
position object 5,0,190,-50
color object 5,rgb(255,0,255)
set object collision on 5
hide object 5
`Limb
make object sphere 9999,10
make mesh from object 1,9999
delete object 9999
add limb 2,1,1
offset limb 2,1,0,0,-400
delete mesh 1
hide limb 2,1
`Enemy
make object box 666,35,75,10
position object 666,0,-58,250
color object 666,rgb(255,0,0)
set shadow shading on 666
set object collision on 666
` shot
make object sphere bullet,4
color object bullet,rgb(0,255,255)
set shadow shading on bullet
hide object bullet
`Main loop
do
gosub camera
position mouse desktop width()/2,desktop height()/2
`Crosshair(mouse)
circle desktop width()/2,desktop height()/2-200,5
`Create text
set text size 23 : set text font "ALGERIAN"
text 50,50,"Controls :"
set text size 20
text 50,80,"mouse = look"
text 50,100,"wsad = move"
text 50,120,"space = jump"
text 50,140,"esc = quit"
`Increse gravity if no collision between floor and player
if object collision (1,5) = 0
dec gr#,0.5
endif
`Update player position
position object 2,object position x(2),object position y(2)+gr#,object position z(2)
`Collision floor 1, player
if object collision (1,5) and gr# < 0
gr# = 0
endif
`Moving the player
if keystate(17)=1 then move object 2,5
if keystate(31)=1 then move object 2,-5
if keystate(30)=1 then move object left 2,4
if keystate(32)=1 then move object right 2,4
` check to see if player is shooting
if mouseclick() = 1 and shoot = 0
shoot = 1 : moves = 0
` place shot at player's position
position object bullet,object position x(2),object position y(2),object position z(2)
show object bullet
` rotate bullet so it moves in the right direction
set object to camera orientation bullet
endif
` move bullet if active
if shoot = 1
oay# = object angle y(bullet)
x# = newxvalue(object position x(bullet),oay#,8.0)
z# = newzvalue(object position z(bullet),oay#,8.0)
position object bullet,x#,object position y(bullet),z#
` check to see if bullet collide with anything
collide = object collision(bullet,0)
` check to see if bullet hit enemy
if collide = 666 and EnemyStatus > 0
hide object 666 : EnemyStatus = 0
hide object bullet
shoot = 0
endif
endif
`Restrictions
if object position z(2) > 627
position object 2,object position x(2),object position y(2),627
endif
if object position z(2) < -327
position object 2,object position x(2),object position y(2),-327
endif
if object position x(2) > 477
position object 2,477,object position y(2),object position z(2)
endif
if object position x(2) < -477
position object 2,-477,object position y(2),object position z(2)
endif
if shoot > 0
if keystate(30) = 1 then shoot = 0 : hide object bullet
x# = object position x(bullet)
z# = object position z(bullet)
if z# > 627.0 or z# < -327.0 or x# > 477.0 or x# < -477.0
hide object bullet : shoot = 0
endif
endif
`Jumping
if object collision (1,5) and spacekey() = 1
gr# = 13
endif
`Death scenario
if EnemyStatus > 0
if object collision (666,5)
position object 2,0,190,-50
position object 666,0,-58,250
gr# = 0
endif
endif
`Fake player position
position object 5,object position x(2),object position y(2)-15,object position z(2)
point object 5,limb position x(2,1),limb position y(2,1),limb position z(2,1)
`Enemy AI
if EnemyStatus > 0
point object 666,object position x(5),0,object position z(5)
xrotate object 666,0
move object 666,1
endif
sync
loop
camera:
`Mouse Camera Movement
camy# = camy# + mousemovex()/3
yrotate object 2,camy#
`Camera position
position camera limb position x(2,1),250,limb position z(2,1)
point camera object position x(2),object position y(2),object position z(2)
return
So many games to code.......so little time.