It get's confused when I put gun=guna.
"cannot cast string fs@change_gun@guna..."
What the heck does that one mean.
rem using a formula that makes sounds without media
createsound("laser",1,1500,700,8000,0.01,0.2,0,0,0,0)
createsound("explosion",2,6200,700,2000,20,0.2,0,0,0,0)
createsound("explosion2",3,1200,1400,3000,10,0.1,0,0,0,0)
createsound("powerup",4,800,700,8000,-0.02,0.2,0,0,0,0)
createsound("warning",5,800,1000,6000,0.5,0.1,0,0,0,0)
createsound("vibrato1",6,500,2000,8000,0,0.1,0.05,0.2,0,0)
createsound("vibrato2",7,400,2000,8000,0,0.1,0.05,0.2,0,0)
createsound("vibrato3",8,600,2000,8000,0,0.1,0.05,0.2,0,0)
createsound("bass hit",9,20,200,14000,0.00,1.2,.0,0,0,0)
createsound("hihat",10,800,200,5000,60.06,2.2,.1,0,0,0)
createsound("door knock",11,200,200,8000,.1,4.0,2.1,10,9.2,9.2)
createsound("vinyl scratch",12,500,200,8000,0.06,0.2,.1,0,0,0)
createsound("cb1",13,250,500,2500,0.00001,0.2,4.0,0.4,0,0)
createsound("cb2",14,500,500,2500,0.00001,0.2,4.0,0.4,0,0)
createsound("cb3",15,437.5,1500,1500,0.0001,0.2,0.0,4.0,0.4,0)
createsound("cb4",16,573.75,1500,1500,0.0,0.2,4.0,0.4,0,0)
createsound("bubble burst",17,100,800,6000,-.4,2.0,0.1,10,1.2,0.2)
Sync On:Sync Rate 60:Autocam off:Position Camera 0,10,0
Global LastTime as Integer
LastTime=Timer()
global gun as string
global maxe as integer
global hp as integer
Global gunspeed as float
Global maxammo as integer
Global relodetime as integer
hp=100
global you as integer
global espeed as integer
global ammo as integer
ammo=maxammo
dim e_hp(100) as integer
maxe=100
e=maxe
make_enemies()
gun="machinegun"
you=10000
make object cylinder you,.5
Set Object Cull you,0
Scale Object you,100,500,100
xrotate object you,90
position object you,4,-3,6
Do
make_gun()
change_gun()
Make_Bullet()
Move_Bullet()
Move_Camera()
stats()
next_level()
Sync
Loop
function change_gun()
for g=1 to 50
for gune=1 to 2
make object cube g,.5
position object g,rnd(2000)-1000,10,rnd(2000)-1000
p=object collision (you,gune)
if p>1
restore guns
read guna
gun=guna
next i
endfunction
function make_enemies()
for i=1 to maxe
Make Object Cube i,20
Position Object i,rnd(2000)-1000,10,rnd(2000)-1000
color object i,rgb(255,0,0)
Next i
endfunction
Function Move_Camera()
Turn Camera Left LeftKey()+30-RightKey()-30
Move Camera Upkey()+30-Downkey()-30
EndFunction
Function Make_Bullet()
If MouseClick()<>1 Then ExitFunction
If Timer()-LastTime<relodetime Then ExitFunction
play sound 1
LastTime=Timer()
For i = 101 to maxammo+101
if Object Exist(i)=0 Then Exit
Next i
If i>maxammo+101 then exitfunction
Make Object Sphere i,1,6,6
Position Object i,Camera Position X(),Camera Position Y(),Camera Position Z()
Set Object To Camera Orientation i
Move Object Right i,6
Move Object Down i,3
EndFunction
Function Move_Bullet()
for i=101 to e
For j= 1 to 5
If Object Exist(i)=0 Then Exit
Move Object i,gunspeed
c=Object Collision(i,0)
if c>0
Position Object c,Rnd(2000)-1000,10,Rnd(2000)-1000
Delete Object i
e=e-1
ammo=ammo-1
Endif
Next j
d=object collision (you,i)
if d<1
hp=hp-10
endif
If Object Exist(i)
Scale Object i,100,100,101
If Object Size Z(i)>2 Then Delete Object i
Endif
Next i
EndFunction
function make_gun()
if gun="machinegun"
gosub mg:
endif
if gun="rocket luancher"
gosub rl:
endif
endfunction
mg:
maxammo=300
gunspeed=20
relodetime=300
return
rl:
maxammo=10
gunspeed=35
relodetime=20
return
rem this complicated functin that makes it so that you can create sounds without media
function createsound(name$,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#)
if file exist(name$+".wav")=1 then delete file name$+".wav"
open to write 1,name$+".wav"
chunk=int(((length#/1000)*44100*16)/8) `sample size (no of samples * bitrate * channels / 8)
samples=int((length#/1000)*44100) `length *44100
restore
for x=1 to 40
read byte2
write byte 1, byte2
next x
write long 1,chunk
rem generate and write wave
for x=1 to samples
output#=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#+tremelodepth#*sin(phi#)))*3.0
inc theta#,vibratospeed#
inc phi#,tremelospeed#
dec frequency#,bend#
if loudness#>0 then dec loudness#,decay#
write word 1,output#
next x
close file 1
load sound name$+".wav",soundnumber
data 82:data 73:data 70:data 70:data 208:data 59:data 1:data 0:data 87
data 65:data 86:data 69:data 102:data 109:data 116:data 32:data 16
data 0:data 0:data 0:data 1:data 0:data 2:data 0:data 34:data 86:data 0
data 0:data 136:data 88:data 1:data 0:data 4:data 0:data 16:data 0
data 100:data 97:data 116:data 97
endfunction
function stats()
set cursor 0,350
print gun;", hp=",hp; ", targeted enemy hp=",e_hp
set cursor 50,0
print
endfunction
function next_level()
if e<>0 then exitfunction
maxe=maxe+20
e=maxe
espeed=espeed+5
endfunction
guns:
data "machinegun","rocket luancher"
I posted the whole thing becuase I added a bunch.
-"I'm over twice as strong as I was when we last met"-
-"Good, Twice the fall, double the glory"-