VB小游戏game

VB simple game model

the flying bird

点击查看源网页

Although I can’ t copy the picture, showing the way how to do it is a good way to both understand the game and learn the programming language.

the code

1
2
3
Private Sub Command1_Click()   'press botton
Label1.Top = Label1.Top - 700 '700 is the distance the 'bird' moves for once
End Sub
1
2
3
4
5
6
Private Sub Command2_Click()   'reset botton
Label1.Left = 375 'let the 'bird' get to the original position
Label1.Top = 2280
Timer1.Enabled = True 'reset the timer and the command
Command1.Enabled = True
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Private Sub Timer1_Timer()     'timer
Label1.Top = Label1.Top + 40 '40 is the speed it falls
Label1.Left = Label1.Left + 20 '20 is the speed it moves forward
If Label1.Left > Text1.Left - Label1.Width And Label1.Left < Text1.Left + Text1.Width Then 'when the 'bird' moves into the given area
If Label1.Top < Text1.Height Or Label1.Top > Text2.Top Then 'when the 'bird' touch the wall
Timer1.Enabled = False
Command1.Enabled = False
Print "you lost!" 'stop all, and show that you have lost
End If
End If
If Label1.Left > Text1.Left + Text1.Width + 1000 Then 'when the 'bird' get to the final point
Print "you win!" 'show you win and stop all
Timer1.Enabled = False
Command1.Enabled = False
End If
End Sub

the situation that the ‘bird’ touch the wall:

Ykpgf0.png

the situation that the ‘bird’ get to the final point:

YkCaqg.png

showing as video