Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmLevel1
- Dim isJumping As Boolean = False
- Dim gravitySpeed As Integer = 0
- Dim moveSpeed As Integer = 10
- Dim points As Integer
- Dim pause As Boolean
- Public deathCount As Integer
- Private Sub frmLevel1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- My.Settings.continuePlaying = Me
- End Sub
- Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
- Select Case e.KeyCode
- Case Keys.Up
- For Each p As Control In Me.Controls
- If TypeOf p Is PictureBox Then
- If p.Tag = "vine" Then
- If picPlayer.Bounds.IntersectsWith(p.Bounds) Then
- My.Computer.Audio.Play(My.Resources.jumpPad, AudioPlayMode.Background)
- tmrUp.Start()
- isJumping = False
- tmrGravity.Stop()
- End If
- End If
- End If
- Next
- Case Keys.Right
- tmrRight.Start()
- Case Keys.Left
- tmrLeft.Start()
- End Select
- End Sub
- Private Sub tmrUp_Tick(sender As System.Object, e As System.EventArgs) Handles tmrUp.Tick
- picPlayer.Top -= moveSpeed
- isJumping = True
- End Sub
- Private Sub tmrLeft_Tick(sender As System.Object, e As System.EventArgs) Handles tmrLeft.Tick
- picPlayer.Left -= moveSpeed
- End Sub
- Private Sub tmrRight_Tick(sender As System.Object, e As System.EventArgs) Handles tmrRight.Tick
- picPlayer.Left += moveSpeed
- End Sub
- Private Sub tmrGameLoop_Tick(sender As System.Object, e As System.EventArgs) Handles tmrGameLoop.Tick
- If picPlayer.Bounds.IntersectsWith(picAir.Bounds) Then
- If isJumping = False Then
- tmrGravity.Start()
- End If
- ElseIf picPlayer.Bounds.IntersectsWith(picGround.Bounds) Then
- tmrGravity.Stop()
- ElseIf picPlayer.Bounds.Top < 0 Then
- tmrGravity.Start()
- isJumping = False
- End If
- For Each p As Control In Me.Controls
- If TypeOf p Is PictureBox Then
- If p.Tag = "platform" Then
- If picPlayer.Bounds.IntersectsWith(p.Bounds) Then
- tmrGravity.Stop()
- End If
- ElseIf p.Tag = "invisBound" Then
- If picPlayer.Bounds.IntersectsWith(p.Bounds) Then
- tmrGravity.Start()
- picCoin1.Location = New Point(291, 86)
- picCoin2.Location = New Point(452, 86)
- picCoint3.Location = New Point(1055, 86)
- picPlayer.Location = New Point(841, 567)
- picFinish.BackColor = Color.Lime
- points = 0
- deathCount += 1
- Me.Text = "Level 1 (Keys: 0)"
- isJumping = False
- End If
- ElseIf p.Tag = "checkPoint" Then
- If picPlayer.Bounds.IntersectsWith(p.Bounds) Then
- If points = 3 Then
- My.Computer.Audio.Play(My.Resources.levelUp, AudioPlayMode.Background)
- frmLevel2.Show()
- Me.Close()
- Else
- My.Computer.Audio.Play(My.Resources.deniedAccess, AudioPlayMode.Background)
- picFinish.BackColor = Color.Red
- End If
- End If
- ElseIf p.Tag = "coin" Then
- If picPlayer.Bounds.IntersectsWith(p.Bounds) Then
- points += 1
- Me.Text = "Level 1 (Keys: " & points & ")"
- p.Location = New Point(132132, 3213)
- My.Computer.Audio.Play(My.Resources.coinSound, AudioPlayMode.Background)
- End If
- End If
- End If
- Next
- End Sub
- Private Sub tmrGravity_Tick(sender As System.Object, e As System.EventArgs) Handles tmrGravity.Tick
- gravitySpeed = 15
- picPlayer.Top += gravitySpeed
- End Sub
- Private Sub Form1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
- Select Case e.KeyCode
- Case Keys.Up
- isJumping = False
- tmrUp.Stop()
- Case Keys.Right
- tmrRight.Stop()
- Case Keys.Left
- tmrLeft.Stop()
- End Select
- End Sub
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- lblResume.Hide()
- tmrGameLoop.Start()
- End Sub
- Private Sub lblSettings_Click(sender As System.Object, e As System.EventArgs) Handles lblSettings.Click
- lblResume.Show()
- tmrPause.Start()
- frmSettings.Show()
- End Sub
- Private Sub lblResume_Click(sender As System.Object, e As System.EventArgs) Handles lblResume.Click
- tmrGameLoop.Start()
- tmrGravity.Start()
- tmrPause.Stop()
- picPlayer.Top -= 15
- lblResume.Hide()
- End Sub
- Private Sub lblResume_MouseEnter(sender As Object, e As System.EventArgs) Handles lblResume.MouseEnter
- lblResume.BackColor = Color.DarkTurquoise
- End Sub
- Private Sub lblResume_MouseLeave(sender As Object, e As System.EventArgs) Handles lblResume.MouseLeave
- lblResume.BackColor = Color.Cyan
- End Sub
- Private Sub tmrPause_Tick(sender As System.Object, e As System.EventArgs) Handles tmrPause.Tick
- tmrGameLoop.Stop()
- tmrGravity.Stop()
- tmrUp.Stop()
- tmrLeft.Stop()
- tmrRight.Stop()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement