Hi I am doing Vbugs and im trying to add a bonus screen when i kill a certain amount of bugs but im not sure where i should add it to the Public Sub Main() can someone please help?
Here is the code:
Module GameLogic
Private listBugs As List(Of Bug)
Private level As Integer
Private GameTimer As Timer
Private PeneltyAt As Integer
Public BugsKilled As Integer
Public Score As Integer
Public Time As Integer
Public scorePenalty As Integer
Private bgNumber As Integer
Private bonusScore As Integer
Public Sub Bonus()
Select Case BugsKilled
Case 5
bonusScore = 100
Score = Score + bonusScore
BonusScreen()
Case 10
bonusScore = 500
Score = Score + bonusScore
BonusScreen()
Case 20
bonusScore = 1000
Score = Score + bonusScore
BonusScreen()
Case 30
bonusScore = 1500
Score = Score + bonusScore
BonusScreen()
Case 40
bonusScore = 2000
Score = Score + bonusScore
BonusScreen()
Case 50
bonusScore = 5000
Score = Score + bonusScore
BonusScreen()
End Select
End Sub
Public Sub BonusScreen()
Core.StopTimer(GameTimer)
Audio.PlaySoundEffect(GameSound("bonus"))
For i As Integer = 1 To 25
Graphics.FillRectangle(Color.FromArgb(5, 0, 0, 255), 0, 0, 800, 600)
Text.DrawText(BugsKilled & "Bugs Killed!! ", Color.Black, GameFont("bear"), 50, 200)
Text.DrawText("+ " & bonusScore, Color.Black, GameFont("cat_scratch"), 330, 300)
Core.RefreshScreen(25)
Core.ProcessEvents()
Next
Core.StartTimer(GameTimer)
End Sub
Public Sub Pause()
Audio.PlaySoundEffect(GameSound("pause"))
Core.PauseTimer(GameTimer)
Do
Graphics.FillRectangle(Color.FromArgb(5, 66, 66, 255), 0, 0, 800, 600)
Graphics.DrawBitmap(GameImage("instructions"), 50, 50)
Core.RefreshScreen(25)
Core.ProcessEvents()
Loop Until Input.WasKeyTyped(Keys.VK_P) Or
SwinGame.Core.WindowCloseRequested() = True
Core.ResumeTimer(GameTimer)
End Sub
Public Sub Penalty()
For i As Integer = 1 To 30
Audio.PlaySoundEffect(GameSound("Penalty"))
Text.DrawText("Too Slow!", Color.Green,
GameFont("comic"), 400, 300)
Text.DrawText("-" & scorePenalty, Color.Green,
GameFont("comic"), 400, 320)
Core.RefreshScreen(25)
Core.ProcessEvents()
Next
End Sub
Public Sub DrawLoser()
Audio.PlaySoundEffect(GameSound("gameover"))
Do
Graphics.ClearScreen(Color.White)
Text.DrawText("YOU", Color.Green,
GameFont("bear"), 300, 10)
Text.DrawText("LOOOOSE!", Color.Red,
GameFont("bear_huge"), 95, 125)
Text.DrawText("You Reached Level" & level,
Color.Green, GameFont("cat_scratch"), 245, 340)
Text.DrawText("And Killed " & BugsKilled & " bugs",
Color.Green, GameFont("cat_scratch"), 240, 400)
Text.DrawText("Press SPACE to play again",
Color.Green,
GameFont("cat_scratch"), 190, 480)
Text.DrawText("Score: " & Score, Color.Green,
GameFont("cat_scratch"), 300, 290)
Core.RefreshScreen(25)
Core.ProcessEvents()
Loop Until Input.WasKeyTyped(Keys.VK_SPACE) Or
SwinGame.Core.WindowCloseRequested = True
If Input.WasKeyTyped(Keys.VK_SPACE) Then
Score = 0
level = 1
LevelSetUp()
End If
End Sub
Public Sub DrawLevelIntro()
For i As Integer = 1 To 50
Graphics.ClearScreen(Color.Black)
Text.DrawText("level " & level, Color.Green,
GameFont("bear"), 180, 200)
Text.DrawText("Score: " & Score, Color.Green,
GameFont("cat_scratch"), 320, 300)
Core.RefreshScreen(25)
Core.ProcessEvents()
Next
End Sub
Public Function EndOfLevel() As Boolean
For Each mybug As Bug In listBugs
If mybug.IsAlive Then
Return False
End If
Next
Return True
End Function
Public Sub LevelSetUp()
Core.StopTimer(GameTimer)
For Each Bug As Bug In listBugs
Bug.CleanUp()
Next
listBugs.Clear()
For i As Integer = 1 To level * 2
listBugs.Add(New Bug)
Next
PeneltyAt = 10000 - 500 * (level - 1)
If PeneltyAt < 500 Then
PeneltyAt = 500
End If
Core.StartTimer(GameTimer)
End Sub
Public Sub DrawMouse()
Dim mousePoint As Point2D
'Replace mouse with a target
mousePoint = Input.GetMousePosition()
Graphics.DrawBitmapOnScreen(GameImage("target"), mousePoint.X, mousePoint.Y)
Input.ShowMouse(False)
End Sub
Public Sub ChangeVolume()
'Change volume with arrow keys
If Input.IsKeyPressed(Keys.VK_UP) = True Then
Audio.SetMusicVolume(Audio.MusicVolume + 0.01F)
End If
If Input.IsKeyPressed(Keys.VK_DOWN) = True Then
Audio.SetMusicVolume(Audio.MusicVolume - 0.01F)
End If
End Sub
Public Sub Main()
'Opens a new Graphics Window
Core.OpenGraphicsWindow("Game", 800, 600)
'Open Audio Device
Audio.OpenAudio()
'Load Resources
LoadResources()
Randomize()
listBugs = New List(Of Bug)
'Make levels
GameTimer = Core.CreateTimer()
level = 1
Score = 0
LevelSetUp()
DrawLevelIntro()
'Game Loop
Do
'Clears the Screen to White
SwinGame.Graphics.ClearScreen(Color.White)
Graphics.DrawBitmap(GameImage("background" & bgNumber), 0, 0)
Time = (PeneltyAt - Core.GetTimerTicks(GameTimer)) / 100
If Input.WasKeyTyped(Keys.VK_P) Then
Pause()
End If
For Each Bug As Bug In listBugs
Bug.Draw()
Bug.Update()
Next
If EndOfLevel() = True Then
level = level + 1
If bgNumber > 1 Then
bgNumber = 0
Else
bgNumber = bgNumber + 1
End If
LevelSetUp()
DrawLevelIntro()
End If
ChangeVolume()
DrawMouse()
'Display statuses
Text.DrawText("level: " & level, Color.Green,
GameFont("cat_scratch"), 320, 2)
Text.DrawText("time: " & Time, Color.Red,
GameFont("comic"), 2, 2)
Text.DrawText("bugs killed: " & BugsKilled, Color.Green,
GameFont("comic"), 2, 60)
Text.DrawText("Score : " & Score, Color.Green,
GameFont("comic"), 2, 30)
'Refreshes the Screen and Processes Input Events
Core.RefreshScreen()
Core.ProcessEvents()
If Time = 0 Then
scorePenalty = 100 * level
Score = Score - scorePenalty
Core.StopTimer(GameTimer)
Core.StartTimer(GameTimer)
Penalty()
DrawLoser()
BugsKilled = 0
bgNumber = 1
End If
Loop Until SwinGame.Core.WindowCloseRequested() = True
'Free Resources and Close Audio, to end the program.
FreeResources()
Audio.CloseAudio()
Music.Stop()
End Sub
End Module