-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowerups.bb
More file actions
79 lines (69 loc) · 1.83 KB
/
Copy pathpowerups.bb
File metadata and controls
79 lines (69 loc) · 1.83 KB
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
Type powerup
Field x,y,dx,dy
Field image
Field mode
End Type
Function spawnPowerup(x,y,dx,dy)
SeedRnd = MilliSecs()
powerup.powerup = New powerup
powerup\x = x
powerup\y = y
powerup\dx = dx
powerup\dy = dy
powerup\mode = Rand(1,4)
If powerup\mode = 1 Then
powerup\image = powerupHealth
ElseIf powerup\mode = 2 Then
powerup\image = powerupShoot
ElseIf powerup\mode = 3 Then
powerup\image = powerupSpeed
ElseIf powerup\mode = 4 Then
powerup\image = powerupShield
EndIf
End Function
Function updatePowerups()
For powerup.powerup = Each powerup
DrawImage powerup\image,powerup\x,powerup\y
powerup\x = powerup\x + powerup\dx
powerup\y = powerup\y + powerup\dy
If powerup\x <= 0 Or powerup\x >= 1280 Or powerup\y <= 0 Or powerup\y >= 720 Then
Delete powerup
Else
If ImagesOverlap(player\image,player\x,player\y,powerup\image,powerup\x,powerup\y) Then
applyPowerup(powerup\mode)
Delete powerup
EndIf
EndIf
Next
End Function
Function applyPowerup(mode)
If mode = 1 Then
player\health = player\health + 50
; The following are placeholders
PlaySound powerupHealthSound
ElseIf mode = 2 Then
player\health = player\health + 50
boostShoot()
PlaySound powerupShootSound
ElseIf mode = 3 Then
player\health = player\health + 50
boostSpeed()
PlaySound powerupSpeedSound
ElseIf mode = 4 Then
player\health = player\health + 50
boostShield()
PlaySound powerupShieldSound
EndIf
End Function
Function boostShoot()
powerupactive = "boostShoot" ; change the mode
powerupTimer = MilliSecs() ;start the timer
End Function
Function boostSpeed()
powerUpActive = "boostSpeed"
powerupTimer = MilliSecs()
End Function
Function boostShield()
powerupActive = "boostShield"
powerupTimer = MilliSecs()
End Function