I was just working on switching guns for my up-coming game, so I thought I'd post it here before I continued
Press 1,2 and 3 to choose guns
remstart
`Configuration Settings
Open to Read 1,"config.ini"
read string 1,null$
read string 1,hertz$
read string 1,null$
read string 1,null$
read string 1,dmx$
read string 1,dmy$
read string 1,dmd$
read string 1,null$
read string 1,null$
read string 1,wind$
Close File 1
SRate=Val(Hertz$)
DmX=Val(dmx$)
DmY=Val(dmy$)
DmD=Val(dmd$)
Wind=val(wind$)
`Setup
Sync on : Sync Rate SRate
Set Display Mode DmX,DmY,DmD : Hide Mouse
If Wind=1 then Set Window On : Maximize Window
Autocam off : Set Camera range 1,0x7fffffff
remend
`Setup
Sync on : Sync Rate 60
Set Display Mode 1024,768,16 : Hide Mouse
Autocam off : Set Camera range 1,0x7fffffff
`Setup Player
Make object plain 1,1,1 : Hide Object 1
`Setup World
Dim LevNum(10)
for L=1 to 10
LevNum(L)=L+9
Next L
Make Object Plain LevNum(2),1000,1000
XRotate Object LevNum(2),90 : Fix Object Pivot LevNum(2)
`**Main loop**
Do
`Control Player
caxi#=wrapvalue(caxi#+MouseMoveY())
cayi#=wrapvalue(cayi#+MouseMoveX())
cax#=curveangle(caxi#,cax#,10.0)
cay#=curveangle(cayi#,cay#,10.0)
if Keystate(17)=1
xs#=Sin(cay#)*20
zs#=Cos(cay#)*20
Endif
if Keystate(31)=1
xs#=-Sin(cay#)*20
zs#=-Cos(cay#)*20
Endif
if Keystate(32)=1
xs#=Sin(cay#-90)*20
zs#=Cos(cay#-90)*20
Endif
if Keystate(30)=1
xs#=Sin(cay#+90)*20
zs#=Cos(cay#+90)*20
Endif
xs#=xs#*0.50 : zs#=zs#*0.50
x#=x#+xs# : z#=z#+zs#
y#=40.0
position camera x#,y#,z#
rotate camera cax#,cay#,0
`Guns
oldgun=gun
if inkey$()="1" then gun=1
if inkey$()="2" then gun=2
if inkey$()="3" then gun=3
if Gun<>OldGun
SwapGun=1
endif
if swapgun=1
if object exist(1)=1
swg#=90
swgy#=15
if gy#<y#-15
Delete Object 1
endif
if object exist(1)=0
swg#=0
swgy#=0
SwapGun=0
endif
endif
endif
If Gun=1
if object exist(1)=0
Make Object box 1,5,5,20
Endif
Endif
If Gun=2
if object exist(1)=0
Make Object box 1,5,5,20
color object 1,rgb(255,0,0)
Endif
Endif
If Gun=3
if object exist(1)=0
Make Object box 1,5,5,20
color object 1,rgb(255,255,0)
Endif
Endif
`Position Gun
gx#=x#+sin(cay#+30)*20
gz#=z#+cos(cay#+30)*20
gy#=curvevalue(y#-(5+swgy#),gy#,3.0)
gxa#=curveangle(wrapvalue(cax#+swg#),gxa#,5.0)
gxap#=curveangle(cax#,gxap#,5.0)
gya#=curveangle(cay#,gya#,5.0)
if object exist(1)=1
position object 1,gx#,gy#,gz#
rotate object 1,gxa#,gya#,0
endif
`**End Loop**
Sync
Loop
`**Functions**
Function GetFreeObj()
for i=1 to 65535
if object exist(i)=0
exitfunction i
endif
next i
Endfunction i