一个小飞机游戏(源码)(懒了点)
Public Class Form1Dim x, q, w, f As Integer
Dim aa As Integer = 0
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Select Case Asc(e.KeyChar)
Case 87 : PictureBox1.Top = PictureBox1.Top - 5
Case 83 : PictureBox1.Top = PictureBox1.Top + 5
Case 65 : PictureBox1.Left = PictureBox1.Left - 5
Case 68 : PictureBox1.Left = PictureBox1.Left + 5
Case 13 : po(PictureBox21)
End Select
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
f = 0
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub hei(ByVal pic)
Randomize()
x = Rnd() * 1500 + 50
w = Rnd() * 15 + 1
pic.Visible = True
pic.Top = pic.Top + w
If pic.Top >= PictureBox1.Top - 20 And pic.Left >= PictureBox1.Left - 20 And pic.left <= PictureBox1.Left + 80 Then
If aa = 0 Then
f = f + 1
If f = 1 Then
MessageBox.Show("您应该挂了")
End If
End If
End If
If pic.Top >= PictureBox21.Top And pic.Left >= PictureBox21.Left - 20 And pic.left <= PictureBox21.Left + 18 Then
pic.Top = 0
pic.Left = x
End If
If pic.Top >= 800 Then
pic.Top = 0
pic.Left = x
End If
End Sub
Private Sub hong(ByVal pic)
Randomize()
x = Rnd() * 1500 + 50
q = Rnd() * 15 + 1
pic.Visible = True
pic.Top = pic.Top + q
If pic.Top >= PictureBox1.Top - 20 And pic.Left >= PictureBox1.Left - 20 And pic.left <= PictureBox1.Left + 80 Then
aa = aa + 1
Select aa
Case 1 : PictureBox26.Visible = True
Case 2 : PictureBox27.Visible = True
Case 3 : PictureBox25.Visible = True
End Select
pic.Top = 0
pic.Left = x
End If
If pic.Top >= 800 Then
pic.Top = 0
pic.Left = x
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static i As Integer
i = (i + 1) Mod 3
If i = 0 Then
Timer1.Interval = 1 * 100
PictureBox1.Image = PictureBox3.Image
ElseIf i = 1 Then
Timer1.Interval = 2 * 100
PictureBox1.Image = PictureBox2.Image
Else
End If
'敌机碰撞
hei(PictureBox4)
hei(PictureBox5)
hei(PictureBox7)
hei(PictureBox9)
hei(PictureBox11)
hei(PictureBox12)
hei(PictureBox14)
hei(PictureBox15)
hei(PictureBox16)
hei(PictureBox17)
hei(PictureBox6)
hei(PictureBox8)
hei(PictureBox10)
hei(PictureBox13)
hei(PictureBox20)
hei(PictureBox18)
'奖励
hong(PictureBox19)
'子弹动
dong(PictureBox21)
End Sub
Private Sub po(ByVal pic)
pic.top = PictureBox1.Top
pic.left = PictureBox1.Left + 22
pic.Visible = True
End Sub
Private Sub dong(ByVal pic)
pic.top = pic.top - 40
End Sub
End Class