-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasteroids.bb
More file actions
72 lines (61 loc) · 1.75 KB
/
Copy pathasteroids.bb
File metadata and controls
72 lines (61 loc) · 1.75 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
Type asteroid
Field x,y,dx,dy,health
Field image
Field isSmall
End Type
Function spawnAsteroids(count)
For i = 1 To count
newAsteroid.asteroid = New Asteroid
newAsteroid\x = Rand(0,1230)
newAsteroid\y = 0
newAsteroid\dx = Rand(-5,5)
newAsteroid\dy = Rand(1,7)
newAsteroid\image = asteroidImage
newAsteroid\health = 100
newAsteroid\isSmall = False
Next
End Function
Function spawnSmallAsteroids(x,y)
amount = Rand(2,6)
For i = 0 To amount
asteroid1.asteroid = New asteroid
asteroid1\x = x
asteroid1\y = y
asteroid1\dx = Rand(-10,10)
asteroid1\dy = Rand(-10,10)
asteroid1\image = asteroidSmallImage
asteroid1\isSmall = True
Next
;roll the dice to see if we spawn a powerup
If Rand(1,10) = 10 Then
spawnPowerUp(x,y,Rand(0,5),Rand(0,5))
EndIf
End Function
Function updateAsteroids()
; Normal asteroid spawning
If MilliSecs() - astTimer >= 2000 Then
astTimer = MilliSecs()
spawnAsteroids(difficulty)
EndIf
For asteroid.asteroid = Each asteroid
DrawImage asteroid\image,asteroid\x,asteroid\y
asteroid\x = asteroid\x + asteroid\dx
asteroid\y = asteroid\y + asteroid\dy
If(asteroid\x >= 1280 Or asteroid\x <= 0 Or asteroid\y >= 720 Or asteroid\y <= -50) Then
Delete asteroid
ElseIf ImagesOverlap(asteroid\image,asteroid\x,asteroid\y,player\image,player\x,player\y)
If Not asteroid\isSmall Then
spawnSmallAsteroids(asteroid\x,asteroid\y)
If Not powerupactive = "boostShield" Then
player\health = player\health - 20
EndIf
Else
If Not powerupactive = "boostShield" Then
player\health = player\health - 5
EndIf
EndIf
Delete asteroid
PlaySound asteroidExplosion
EndIf
Next
End Function