Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim WithEvents t As New Timer
- Dim stp As Integer = 2
- Dim fps As Integer = 25
- Dim ax, ay, bx, by As Integer
- Dim imgpath As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "elephant.png")
- Dim img As Image = Image.FromFile(imgpath)
- Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
- Dim g As Graphics = e.Graphics
- g.DrawImage(img, ax, ay)
- g.DrawImage(img, bx, by)
- End Sub
- Private Sub PaintNextFrame()
- ax = ax + 2 * stp
- bx = bx + stp
- Me.Invalidate()
- End Sub
- Private Sub tick(ByVal o As Object, ByVal e As EventArgs) Handles t.Tick
- PaintNextFrame()
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- t.Interval = 1000 / fps
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- t.Start()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- t.Stop()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- t.Stop()
- ax = 0
- bx = 0
- ay = 0
- by = 0
- Me.Invalidate()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement