Make your own free website on Tripod.com

A Simple Animation Program

This is a simple animation program where you can move the picture in any four directions by clicking on the buttons. In this program, you need to insert four timers and make them invisible and set the enabled property to false at start-up. Insert the move_up, move_down, move_left and move_right procedures into the respective timers as shown in the code. Use the move method and the computer  coordinates system Left, Top  to change the positions of the image. This program could be used to create various games later on.

 

 

The codes

Dim x As Integer
Dim y As Integer
Dim v, w As Integer


Static Sub move_right()
v = v + 10
If v < 5350 Then
Image1.Move v, w
Else
Image1.Move 2640, 1560
v = 2640
w = 1560
Timer1.Enabled = False
End If
End Sub

Public Sub Command1_Click(Index As Integer)
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer2.Enabled = True
End Sub

Private Sub Command3_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer4.Enabled = False
Timer3.Enabled = True
End Sub

Private Sub Command4_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = True
End Sub

Private Sub Form_Load()
x = 0
y = 0
v = 2640
w = 1560
End Sub

Private Sub Timer1_Timer()
move_right

End Sub
Static Sub move_down()

w = w + 10

If w < 3670 Then
Image1.Move v, w
Else
Image1.Move 2640, 1560
v = 2640
w = 1560
Timer2.Enabled = False

End If
End Sub

Private Sub Timer2_Timer()
move_down

End Sub
Private Sub move_left()
v = v - 10
If v > 0 Then
Image1.Move v, w
Else
Image1.Move 2640, 1560
v = 2640
w = 1560
Timer3.Enabled = False

End If
End Sub
Private Sub move_up()
w = w - 10

If w > 0 Then
Image1.Move v, w
Else
Image1.Move 2640, 1560
v = 2640
w = 1560
Timer4.Enabled = False
End If

End Sub

Private Sub Timer3_Timer()
move_left

End Sub

Private Sub Timer4_Timer()
move_up
End Sub

 

[Back  to Games Page]