Hi, I've made, with a lot of help, a simple shooting peice.
But, when you are shooting the fps goes to around 9, when it is usually 3 to 4 thousand, can you see where this insane lag comes from?
`Created by <your name>
`Date Started: <current date>
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE
`Create all media needed
` Our character
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000):POSITION OBJECT 1,0,0,-400
` An enemy
load object "media\template body 2.x", 2:POSITION OBJECT 2,130,0,0
` A large wall
MAKE OBJECT BOX 3 ,500,400,10:POSITION OBJECT 3,0,0,150
` An ammo crate
MAKE OBJECT BOX 4,15,20,50:COLOR OBJECT 4,RGB(000,255,255):POSITION OBJECT 4,-40,0,0
` Some ground to walk on
MAKE OBJECT PLAIN 5,1000,1000:XROTATE OBJECT 5,-90
`hitbox
make object box 6, 8,8,8
position object 6,object position x (2),object position y (2)+35, object position z (2)-20
`Make sure all the objects are on ground level
FOR Object = 1 TO 4
POSITION OBJECT Object, OBJECT POSITION X(Object), OBJECT SIZE Y(Object)/2,OBJECT POSITION Z(Object)
NEXT Object
`Add limb for intersection checks
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
`Bullet Intersection Limb
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,500
HIDE LIMB 1,1
`Front Intersection Limb
ADD LIMB 1,2,1
OFFSET LIMB 1,2,0,0,OBJECT SIZE Z(1)/2
HIDE LIMB 1,2
`Back Intersection Limb
ADD LIMB 1,3,1
OFFSET LIMB 1,3,0,0,-OBJECT SIZE Z(1)/2
HIDE LIMB 1,3
`Right Intersection Limb
ADD LIMB 1,4,1
OFFSET LIMB 1,4,OBJECT SIZE X(1)/2,0,0
HIDE LIMB 1,4
`Left Intersection Limb
ADD LIMB 1,5,1
OFFSET LIMB 1,5, -OBJECT SIZE X(1)/2,0,0
HIDE LIMB 1,5
`Define the main variables needed
EnemyHP=200` Enemy's Health
Ammo=32` Starting Ammo
MaxAmmo=32` Maximum amount of Ammo
Clips=5` Starting Clips
MaxClips=5` Maximum amount of Clips
Jumping=0
ScreenWidth#=SCREEN WIDTH()
ScreenHeight#=SCREEN HEIGHT()
`Start main DO/LOOP
DO
`Screen FPS
FPS=SCREEN FPS()
TEXT 0,0,"FPS: "+STR$(FPS)
`Movement Controls
IF KEYSTATE(17)=1
XAngle#=OBJECT ANGLE X(1)
XROTATE OBJECT 1,0
MOVE OBJECT 1,.2
XROTATE OBJECT 1,XAngle#
ENDIF
IF KEYSTATE(31)=1
XAngle#=OBJECT ANGLE X(1)
XROTATE OBJECT 1,0
MOVE OBJECT 1,-.2
XROTATE OBJECT 1,XAngle#
ENDIF
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.1
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.1
`Define variables for lag reduction
X#=OBJECT POSITION X(1)
Y#=OBJECT POSITION Y(1)
Z#=OBJECT POSITION Z(1)
`Camera Positioning
POSITION CAMERA X#,Y#,Z#
`Space key Controls
IF SPACEKEY()=1 AND Jumping=0 THEN Jump=1
`JUMP Variable Definition
IF Jump=1
Jump_Speed#=.5
Jumping=1
Jump=0
ENDIF
`Jumping
IF Jumping=1
DEC Jump_Speed#,.001
POSITION OBJECT 1,X#,Y#+Jump_Speed#, Z#
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 MOUSECLICK()=1
IF Ammo>0 THEN DEC Ammo,1
wait 100
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), X#,Y#,Z#)>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 THEN DELETE OBJECT 2
`Reloading (press R)
IF KEYSTATE(19)=1 AND Ammo<MaxAmmo AND Clips>0
Reload=1
ENDIF
`Reloading Part 2 (delay)
IF Reload=1 THEN INC Time#,.001
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, X#,Y#-50,Z#, X#,Y#,Z#)>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,ScreenHeight#-50,"Ammo: "+str$(Ammo)
TEXT 0,ScreenHeight#-40,"Clips: "+str$(Clips)
`Show that we're reloading
IF Reload=1 THEN CENTER TEXT ScreenWidth#/2,ScreenHeight#/2,"Reloading..."
`Add a target reticule to the screen
CIRCLE ScreenWidth#/2,ScreenHeight#/2,5
`Check for collision with objects, and handle appropriately
`Ground Intersection Check
IF INTERSECT OBJECT (5,X#,(Y#-OBJECT SIZE Y(1)/2),Z#,X#,Y#,Z#)>0
Jumping=0
ELSE
IF Jumping=0
Jumping=1: Jump_Speed=-1
ENDIF
ENDIF
`Front Intersection Check
IF INTERSECT OBJECT (3,LIMB POSITION X(1,2),LIMB POSITION Y(1,2),LIMB POSITION Z(1,2),X#,Y#,Z#)
`If intersection infront, move the user backwards
MOVE OBJECT 1,-1
ENDIF
`Back Intersection Check
IF INTERSECT OBJECT (3,LIMB POSITION X(1,3),LIMB POSITION Y(1,3),LIMB POSITION Z(1,3),X#,Y#,Z#)
`If intersection behind, move user forwards
MOVE OBJECT 1,1
ENDIF
`Right Intersection Check
IF INTERSECT OBJECT (3,LIMB POSITION X(1,4),LIMB POSITION Y(1,4),LIMB POSITION Z(1,4),X#,Y#,Z#)
`If intersection to the right, move the user left
MOVE OBJECT LEFT 1,1
ENDIF
`Left Intersection Check
IF INTERSECT OBJECT (3,LIMB POSITION X(1,5),LIMB POSITION Y(1,5),LIMB POSITION Z(1,5),X#,Y#,Z#)
`If intersection to the left, move user right
MOVE OBJECT RIGHT 1,1
ENDIF
`Refresh the screen(SYNC) and call the LOOP function
SYNC
LOOP
If you need the template body file I have used in there just say and I'll upload it, though I doubt thats whats causing, just open that up, use a box instead of the enemy, and try shooting, see how bad it lags.
My site: www.skyknight.co.uk