summaryrefslogtreecommitdiff
path: root/sounds.bmx
blob: 2936b49cf4ff690961962ace0fccdf8c00c5600e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
' Vectoroids
'
' Copyright 2005 Ian Cowburn
'
' $Id$
'
Strict

Incbin "SFX/explode1.wav"
Incbin "SFX/explode2.wav"
Incbin "SFX/explode3.wav"
Incbin "SFX/fire.wav"
Incbin "SFX/life.wav"
Incbin "SFX/lsaucer.wav"
Incbin "SFX/sfire.wav"
Incbin "SFX/ssaucer.wav"
Incbin "SFX/thrust.wav"
Incbin "SFX/thumphi.wav"
Incbin "SFX/thumplo.wav"


Type Sounds
	Global explode:TSound[]
	Global fire:TSound
	Global life:TSound
	Global lsaucer:TSound
	Global sfire:TSound
	Global ssaucer:TSound
	Global thrust:TSound
	Global thumphi:TSound
	Global thumplo:TSound
	
	Global thrust_channel:TChannel
	Global ssaucer_channel:TChannel
	Global lsaucer_channel:TChannel
	
	Global frame:Int
	Global hi:Int
	
	Global thrust_on:Int
	Global small_on:Int
	Global large_on:Int

	Function Init()
		explode=New TSound[3]
		explode[2]=LoadSound("incbin::SFX/explode1.wav")
		explode[1]=LoadSound("incbin::SFX/explode2.wav")
		explode[0]=LoadSound("incbin::SFX/explode3.wav")
		fire=LoadSound("incbin::SFX/fire.wav")
		life=LoadSound("incbin::SFX/life.wav")
		lsaucer=LoadSound("incbin::SFX/lsaucer.wav",True)
		sfire=LoadSound("incbin::SFX/sfire.wav")
		ssaucer=LoadSound("incbin::SFX/ssaucer.wav",True)
		thrust=LoadSound("incbin::SFX/thrust.wav",True)
		thumplo=LoadSound("incbin::SFX/thumplo.wav")
		thumphi=LoadSound("incbin::SFX/thumphi.wav")
		
		frame=0
		hi=True
		
		thrust_channel=thrust.Cue()
		ssaucer_channel=ssaucer.Cue()
		lsaucer_channel=lsaucer.Cue()
	End Function
	
	Function Update(freq:Int)
		If frame>freq
			frame=0
			
			If hi
				thumphi.Play()
			Else
				thumplo.Play()
			EndIf
			
			hi=Not hi
		EndIf
		frame:+1
	End Function
	
	Function AsteroidExplosion(size:Int)
		explode[size].Play()
	End Function
	
	Function ShipExplosion()
		explode[0].Play()
	End Function
	
	Function PlayerFire()
		fire.Play()
	End Function
	
	Function SaucerFire()
		sfire.Play()
	End Function
	
	Function ExtraLife()
		life.Play()
	End Function

	Function PlayerThrust(on:Int)
		thrust_channel.SetPaused(Not on)
		thrust_on=on
	End Function
	
	Function SmallSaucer()
		ssaucer_channel.SetPaused(False)
		small_on=True
	End Function
	
	Function LargeSaucer()
		lsaucer_channel.SetPaused(False)
		large_on=True
	End Function
	
	Function NoSaucer()
		lsaucer_channel.SetPaused(True)
		ssaucer_channel.SetPaused(True)
		small_on=False
		large_on=False
	End Function
	
	Function Clear()
		PlayerThrust(False)
		NoSaucer()
	End Function
	
	Function Pause()
		thrust_channel.SetPaused(True)
		ssaucer_channel.SetPaused(True)
		lsaucer_channel.SetPaused(True)
	End Function
	
	Function EndPause()
		thrust_channel.SetPaused(Not thrust_on)
		ssaucer_channel.SetPaused(Not small_on)
		lsaucer_channel.SetPaused(Not large_on)
	End Function
End Type