Ah... I was wondering why that was so familiar... sorry.
It's probably because that loop I removed the # from EnemyHP. Real numbers are for numbers with a decimal point ( like 100.2382 ). If the number is always going to be whole (such as with EnemyHP) there's no need to make them real.
The variables that don't need to be real:
EnemyHP
Ammo
MaxAmmo
Clips
MaxClips
JUMPING
Reload
In this code I didn't remove all the unnecessary real symbols but I did add the combined if statment and made another one combined (the check for spacebar and the start of the jump).
Hope this helps.
REMSTART
-------- Title: My First FPS
-------- Author: xxxxx xxxxxx
-------- Date: October 15, 2005
REMEND
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE
`Define the main variables needed
EnemyHP#=2000` Enemy's Health
Ammo#=1000` Starting Ammo
MaxAmmo#=1000` Maximum amount of Ammo
Clips#=3` Starting Clips
MaxClips#=3` Maximum amount of Clips
JUMPING#=0`
posx#=250` Player position
posz#=250` Player position
eposx#=500` Enemy position
eposz#=453` Enemy position
`Create Main Player
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000):POSITION OBJECT 1,posx#,Ground#,posz#
`Create Enemy Player
MAKE OBJECT SPHERE 2,50:COLOR OBJECT 2,RGB(255,000,000):POSITION OBJECT 2,eposx#,Ground#,eposz#
`create ammo crate
`LOAD OBJECT "crate2.x", 4
make object cube 4,100
POSITION OBJECT 4,199,Ground#,199
`create playing field
MAKE MATRIX 1,1000,1000,50,50
`add texture to matrix
LOAD IMAGE "johnny.bmp",1
PREPARE MATRIX TEXTURE 1,1,1,1
`make matrix the ground
GROUND#=GET GROUND HEIGHT(1,posx#,posz#)+10
`Add limb for intersection checks
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,500
HIDE LIMB 1,1
`Add a second limb for ground checks
ADD LIMB 1,2,1
OFFSET LIMB 1,2,0,-50,0
DELETE MESH 1
HIDE LIMB 1,2
`Start main DO/LOOP
DO
`Camera Positioning
POSITION CAMERA OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)
`Movement Controls
IF KEYSTATE(17)=1 THEN MOVE OBJECT 1,.9
IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-.9
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.3
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.3
`Space key Controls
IF SPACEKEY()=1 AND JUMPING#=0
JUMP_SPEED#=1
JUMPING#=1
ENDIF
`Jumping
IF JUMPING#=1
DEC JUMP_SPEED#,.005
POSITION OBJECT 1,OBJECT POSITION X(1),OBJECT POSITION Y(1)+JUMP_SPEED#, OBJECT POSITION Z(1)
IF OBJECT POSITION Y(1)<=GROUND# THEN JUMPING#=0
ENDIF
`Mouse Camera Movement
CAMY#=CAMY#+MOUSEMOVEX()*.1
CAMX#=CAMX#+MOUSEMOVEY()*.1
IF CAMX#>90 AND CAMX#<135 THEN CAMX#=90
IF CAMX#>270 AND CAMX#<225 THEN CAMX#=90
YROTATE CAMERA CAMY#
XROTATE CAMERA CAMX#
YROTATE OBJECT 1,CAMY#
XROTATE OBJECT 1,CAMX#
`Mouseclick Shooting
IF KEYSTATE(19)=0 AND MOUSECLICK()=1
IF Ammo#>0 THEN DEC Ammo#,1
IF OBJECT EXIST(2)=1
IF Ammo#>0 AND INTERSECT OBJECT (2, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0 THEN DEC EnemyHP#,1
ENDIF
ENDIF
`Check if the enemy should die, if so delete it
if EnemyHP#=0 AND OBJECT EXIST(2)=1
DELETE OBJECT 2
MAKE OBJECT SPHERE 2,50
COLOR OBJECT 2,RGB(255,000,000)
POSITION OBJECT 2,RND(600),mat_ground#,RND(600)
EnemyHP#=2000
endif
`Reloading (press R)
IF MOUSECLICK()=0 AND KEYSTATE(19)=1 AND Ammo#<MaxAmmo# AND Clips#>0
Reload#=1
ENDIF
`Reloading Part 2 (delay)
IF Reload#=1 THEN INC Time#,.005
IF Time#>=1 THEN Ammo#=MaxAmmo#:DEC Clips#,1:Time#=0:Reload#=0
`Ammo Crate code (obtain ammo from ground)
IF OBJECT EXIST(4)=1
IF Ammo#<MaxAmmo# AND INTERSECT OBJECT (4, LIMB POSITION X(1,2), LIMB POSITION Y(1,2), LIMB POSITION Z(1,2), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0
INC Clips#,(MaxClips#-Clips#)
INC Ammo#,(MaxAmmo#-Ammo#)
DELETE OBJECT 4
ENDIF
ENDIF
`Display text above enemy and crate object
IF OBJECT EXIST(2)=1 THEN CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP#)
IF OBJECT EXIST(4)=1 THEN CENTER TEXT OBJECT SCREEN X(4),OBJECT SCREEN Y(4)-20,"Ammo Crate"
`Display our Ammo and Clips on-screen
TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo#)
TEXT 0,SCREEN HEIGHT()-40,"Clips: "+str$(Clips#)
`Show that we're reloading
IF Reload#=1 THEN CENTER TEXT SCREEN WIDTH()/2,SCREEN HEIGHT()/2,"Reloading..."
`Add a target reticule to the screen
CIRCLE SCREEN WIDTH()/2,SCREEN HEIGHT()/2,5
`Refresh the screen(SYNC) and call the LOOP function
SYNC
LOOP