Public Class frmFlappyBird
Dim intT As Integer = 0 'bird goinig faster #see tmrBird
Dim intP As Integer = 0 'points
Dim space As Boolean
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
'Pause
If e.KeyCode = Keys.P Then
tmrPipeL1.Stop()
tmrPipeL2.Stop()
tmrPipe1Move.Stop()
tmrPipe2Move.Stop()
tmrControle.Stop()
tmrBirdDown.Stop()
lblPPause.Visible = False
lblPause.Visible = True
lblSA.Visible = True
End If
'Start after pause
If lblPause.Visible = True And
e.KeyCode = Keys.S Then
tmrPipeL1.Start()
tmrPipeL2.Start()
tmrPipe1Move.Start()
tmrPipe2Move.Start()
tmrControle.Start()
tmrBirdDown.Start()
lblPPause.Visible = True
lblPause.Visible = False
lblSA.Visible = False
End If
'Bird UP
If picBird.Top > picTop.Top And
picBird.Bottom < picGround.Top And
lblPause.Visible = False And
e.KeyCode = Keys.Space Then
My.Computer.Audio.Play(My.Resources.JumpSound, AudioPlayMode.Background)
Dim B1, B2, B3, B4 As New Point
tmrBirdDown.Stop()
Dim intY1 As Integer
intY1 = picBird.Location.Y
B1.X = picBird.Location.X
B1.Y = intY1 - 50
intY1 = B1.Y - 50
picBird.Location = B1
intT = 0
tmrBirdDown.Start()
End If
'Start game with Spacebar
If lblSpace.Visible = True And
e.KeyCode = Keys.Space Then
picPipeDown2.Visible = False
picPipeUp2.Visible = False
intP = 0
intT = 0
lblPunten.Text = CStr(intP)
picGameOver.Visible = False
Dim B1 As New Point
B1.X = picBird.Location.X
B1.Y = 190
picBird.Location = B1
Dim rndU1 As New Random
Dim intU1, intD1 As Integer
intU1 = rndU1.Next(-310, 1)
intD1 = intU1 + 440
Dim pipeU1 As New Point(460, intU1)
Dim pipeD1 As New Point(460, intD1)
picPipeUp1.Location = pipeU1
picPipeDown1.Location = pipeD1
Dim rndU2 As New Random
Dim intU2, intD2 As Integer
intU2 = rndU2.Next(-320, 1)
intD2 = intU2 + 440
Dim pipeU2 As New Point(460, intU2)
Dim pipeD2 As New Point(460, intD2)
tmrPipeL1.Start()
tmrBirdDown.Start()
tmrControle.Start()
'Lbl's visible = False except PAUSE
lblSpace.Visible = False
lblPPause.Visible = True
End If
End Sub
Private Sub tmrBirdDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrBirdDown.Tick
'This is intT for birdspeeddown increment
intT = intT + 1
Dim Bird1 As New Point
'Position of picBird (y)
Dim intY1 As Integer
'Bird down
intY1 = picBird.Location.Y
Bird1.X = picBird.Location.X
Bird1.Y = intY1 + 1
intY1 = Bird1.Y + 1
picBird.Location = Bird1
'Here the birdspeedfalldown increase
If intT > 50 Then
intY1 = picBird.Location.Y
Bird1.X = picBird.Location.X
Bird1.Y = intY1 + 3
intY1 = Bird1.Y + 3
picBird.Location = Bird1
End If
'If bird touch ground process if tmrControle is not in process
If picBird.Bottom >= picGround.Top And
tmrControle.Enabled = True Then
tmrControle.Stop()
tmrPipeL1.Stop()
tmrPipeL2.Stop()
tmrPipe1Move.Stop()
tmrPipe2Move.Stop()
picGameOver.Visible = True
MessageBox.Show("Game over" & vbNewLine & "Your score: " & intP, "Game over")
picGameOver.Visible = False
lblSpace.Visible = True
' If bird touch ground proccess if tmrControle is in proccess
ElseIf picBird.Bottom >= picGround.Top And
tmrControle.Enabled = False Then
tmrControle.Stop()
tmrBirdDown.Stop()
End If
If picGameOver.Visible = True Then
Me.BackColor = Color.Red
My.Computer.Audio.Play(My.Resources.DieSound, AudioPlayMode.Background)
Else : Me.BackColor = Color.LightSkyBlue
End If
End Sub
Private Sub tmrControle_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrControle.Tick
If picBird.Left = picPipeUp1.Right Or
picBird.Left = picPipeUp2.Right Then
intP += 1
My.Computer.Audio.Play(My.Resources.PointSound, AudioPlayMode.Background)
End If
lblPunten.Text = CStr(intP)
End Sub
Private Sub tmrPipeL1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPipeL1.Tick
Dim pipeU1, pipeD1 As New Point
Dim rndU1 As New Random
Dim intU1, intD1 As Integer
intU1 = rndU1.Next(-310, 1)
intD1 = intU1 + 440
pipeU1.X = 460
pipeU1.Y = intU1
pipeD1.X = 460
pipeD1.Y = intD1
Private Sub tmrPipe1Move_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPipe1Move.Tick
tmrPipeL1.Stop()
Dim pipe1, pipe2 As New Point
pipe1.X = picPipeUp1.Location.X
pipe1.Y = picPipeUp1.Location.Y
pipe1.X -= 2
picPipeUp1.Location = pipe1
pipe2.X = picPipeDown1.Location.X
pipe2.Y = picPipeDown1.Location.Y
pipe2.X -= 2
picPipeDown1.Location = pipe2
If pipe1.X = 230 Then
picPipeDown2.Show()
picPipeUp2.Show()
tmrPipeL2.Start()
End If
If picPipeDown1.Location.X = 0 Then
tmrPipeL1.Start()
End If
End Sub
Private Sub tmrPipe2Move_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPipe2Move.Tick
tmrPipeL2.Stop()
Dim pipe2, pipe3 As New Point
pipe2.X = picPipeUp2.Location.X
pipe2.Y = picPipeUp2.Location.Y
pipe2.X -= 2
picPipeUp2.Location = pipe2
pipe3.X = picPipeDown2.Location.X
pipe3.Y = picPipeDown2.Location.Y
pipe3.X -= 2
picPipeDown2.Location = pipe3
If picPipeDown2.Location.X = 0 Then
tmrPipeL2.Start()
End If
End Sub
Private Sub tmrPipeL2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPipeL2.Tick
Dim pipeU2, pipeD2 As New Point
Dim rndU2 As New Random
Dim intU2, intD2 As Integer
intU2 = rndU2.Next(-320, 1)
intD2 = intU2 + 440
pipeU2.X = 460
pipeU2.Y = intU2
pipeD2.X = 460
pipeD2.Y = intD2
picPipeUp2.Location = pipeU2
picPipeDown2.Location = pipeD2
tmrPipe2Move.Start()
End Sub
Private Sub MadeBy()
'Made by Bram
'Belgium
End Sub
End Class
* 플래피 버드는 베트남의 게임 개발자 응우옌하동이 2013년 개발한 모바일 게임이다. 2013년 5월 24일 정식으로 공개되었으나, 2014년 2월 10일 개발자의 요청으로 삭제되었다. 개발자는 자신의 게임이 몇분정도 즐길 수 있게 하는 목적이었으나 많은사람들이 몇시간씩 중독되어서 삭제되었다고 한다. - 위키백과
1. 전역변수로 List 객체 선언
Dim myPoint AS New List(Of Point)
2. 마우스 클릭 이벤트에서 리스트에 Point 객체 추가
myPoint.Add(new Point(e.X, e.Y))
3. Draw 버튼 클릭 시 그리기
mtGraphic.DrawPolygon(myPen, myPoint.ToArray())
4. 지우기 버튼에서 List 객체 비우기
myPoint.Clear()
참고로 Graphic 객체는 사용 후 꼭 Dispose 함수를 호출해 주는것이 좋습니다.
mtGraphic.Dispose()
이 댓글을