Hello everyone. I recently did Ruccus's FPS tutorial, and completed it. Now I am trying to add some of my own code on top of that, and it's not going so well.
NOTE: I am not comparing this to FPSC, I'm just trying to get these basic features done.
My I have two main issues here.
1. The gun has jagged edges. FPSC doesn't. Is FPSC using some type of anti-aliasing?
2. I can't apply the hand texture to the model along with the gun texture, although in FPSC you can do it, and I can't use the model without applying both textures.
`Inspire FPS Engine
`Created by Inspire
`Date Started: July 5, 2006
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE
`Load the Level
loadlevel()
`Load the Weapons
loadgun()
`Define the main variables
GOSUB _definevar
DO
`Camera
GOSUB _camera
`HUD
GOSUB _hud
`Define variables for lag reduction
FPS=SCREEN FPS()
X#=OBJECT POSITION X(1)
Y#=OBJECT POSITION Y(1)
Z#=OBJECT POSITION Z(1)
GUNFRAME#=OBJECT FRAME (10)
`Movement and Jumping
GOSUB _movement
GOSUB _jumping
`Shooting and Reloading
GOSUB _shoot
GOSUB _reloading
`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
SYNC
LOOP
`**********SUBROUTINES**********
_definevar:
EnemyHP=500` Enemy's Health
Ammo=100` Starting Ammo
MaxAmmo=100` Maximum amount of Ammo
Clips=10 ` Starting Clips
MaxClips=10` Maximum amount of Clips
Jumping=0
ScreenWidth#=SCREEN WIDTH()
ScreenHeight#=SCREEN HEIGHT()
RETURN
_camera:
POSITION CAMERA X#,Y#,Z#
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#
RETURN
_hud:
TEXT 0,0,"FPS: "+STR$(FPS)
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"
TEXT 0,ScreenHeight#-50,"Ammo: "+str$(Ammo)
TEXT 0,ScreenHeight#-40,"Clips: "+str$(Clips)
CIRCLE ScreenWidth#/2,ScreenHeight#/2,5
RETURN
_movement:
IF KEYSTATE(17)=1
XAngle#=OBJECT ANGLE X(1)
XROTATE OBJECT 1,0
MOVE OBJECT 1,.5
XROTATE OBJECT 1,XAngle#
LOOP OBJECT 10,51,65
ENDIF
IF KEYSTATE(31)=1
XAngle#=OBJECT ANGLE X(1)
XROTATE OBJECT 1,0
MOVE OBJECT 1,-.5
XROTATE OBJECT 1,XAngle#
ENDIF
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.3
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.3
RETURN
_jumping:
IF SPACEKEY()=1 AND Jumping=0 THEN Jump=1
IF Jump=1
Jump_Speed#=.5
Jumping=1
Jump=0
ENDIF
IF Jumping=1
DEC Jump_Speed#,.001
POSITION OBJECT 1,X#,Y#+Jump_Speed#, Z#
ENDIF
RETURN
_shoot:
IF KEYSTATE(19)=0 AND MOUSECLICK()=1
IF Ammo>0 THEN DEC Ammo,1
ENDIF
RETURN
_reloading:
IF MOUSECLICK()=0 AND KEYSTATE(19)=1 AND Ammo<MaxAmmo AND Clips>0
PLAY OBJECT 10,81,147
Reload=1
ENDIF
IF Reload=1 THEN INC Time#,.01
IF Time#>=1 THEN Ammo=MaxAmmo:DEC Clips,1:Time#=0:Reload=0
IF Reload=1 THEN CENTER TEXT ScreenWidth#/2,ScreenHeight#/2,"Reloading..."
RETURN
`**********OBJECT SUBROUTINES**********
`***AMMO CRATE***
_ammocrate:
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
RETURN
`***ENEMY***
_enemy:
IF EnemyHP=0 AND OBJECT EXIST(2)=1 THEN DELETE OBJECT 2
RETURN
`**********FUNCTIONS**********
FUNCTION loadlevel()
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000):POSITION OBJECT 1,0,0,-400
MAKE OBJECT SPHERE 2,50:COLOR OBJECT 2,RGB(255,000,000):POSITION OBJECT 2,130,0,0
MAKE OBJECT BOX 4,15,20,50:COLOR OBJECT 4,RGB(000,255,255):POSITION OBJECT 4,-40,0,0
MAKE OBJECT BOX 3,70,70,1:POSITION OBJECT 3,0,0,150
SET DIR "wall"
LOAD IMAGE "Wall_D2.dds",3
TEXTURE OBJECT 3,3
LOAD IMAGE "Wall_N.dds",4
SET BUMP MAPPING ON 3,4
SET OBJECT SPECULAR POWER 3,100
SET DIR ".."
MAKE OBJECT PLAIN 5,1000,1000:XROTATE OBJECT 5,-90
FOR Object = 1 TO 4
POSITION OBJECT Object, OBJECT POSITION X(Object), OBJECT SIZE Y(Object)/2,OBJECT POSITION Z(Object)
NEXT Object
ENDFUNCTION
FUNCTION loadgun()
SET DIR "ak47"
LOAD IMAGE "gun_D.dds",1
LOAD IMAGE "hand_tex.jpg",2
LOAD MESH "HUD.x",1
MAKE OBJECT 10,1,1
SET OBJECT SMOOTHING 10,100
SET OBJECT SPECULAR 10,rgb(255,255,255)
SET OBJECT SPECULAR POWER 10,100
POSITION OBJECT 10,X#-1,Y#-1,Z#-5
ROTATE OBJECT 10,-Camx#+38,Camy#+180,0
LOCK OBJECT ON 10
DISABLE OBJECT ZDEPTH 10
SET OBJECT INTERPOLATION 10,50
SET OBJECT SPEED 10,50
ENDFUNCTION