Post[Snippet]Screen Saver

Posts 1–9 of 9 · Page 1 of 1
[Snippet]Screen Saver
my second TUT this half hour enought for today, enjoy this TUT share resoults with us!



This tutorial will show you how to make a bouncing ball program in Visual basic 2008 / 2010

Add a picture box to the form:

use a transparent picture for this tutorial,

Add this picture to your picture box:

Change also Size Mode to Zoom

Add 4 timers to the form. Change their interval property to 1

Change also the first timer Enabled property to True

Let's add the code to each timer tick event:

Timer1.Tick

[PHP]Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

PictureBox1.Location = New Point(PictureBox1.Location.X + 5, PictureBox1.Location.Y + 5)

If PictureBox1.Location.X + PictureBox1.Width > Me.Width Then

Timer1.Stop()

Timer2.Start()

End If[/PHP]



[PHP] If PictureBox1.Location.Y + PictureBox1.Height > Me.Height Then

Timer1.Stop()

Timer3.Start()

End If

End Sub
[/PHP]
Timer2.Tick



[PHP]Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

PictureBox1.Location = New Point(PictureBox1.Location.X - 5, PictureBox1.Location.Y + 5)

If PictureBox1.Location.Y + PictureBox1.Height > Me.Height Then

Timer2.Stop()

Timer4.Start()

End If

If PictureBox1.Location.X < 0 Then

Timer2.Stop()

Timer1.Start()

End If

End Sub

Timer3.Tick

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick

PictureBox1.Location = New Point(PictureBox1.Location.X + 5, PictureBox1.Location.Y - 5)

If PictureBox1.Location.X + PictureBox1.Width > Me.Width Then

Timer3.Stop()

Timer4.Start()

End If

If (PictureBox1.Location.Y < 0) Then

Timer3.Stop()

Timer1.Start()

End If

End Sub
[/PHP]
Timer4.Tick

[PHP]Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick

PictureBox1.Location = New Point(PictureBox1.Location.X - 5, PictureBox1.Location.Y - 5)

If PictureBox1.Location.X < 0 Then

Timer4.Stop()

Timer3.Start()

End If

If (PictureBox1.Location.Y < 0) Then

Timer4.Stop()

Timer2.Start()

End If

End Sub[/PHP]


Bouncing Ball screen saver, enjoy! m_t_h
Will play with it in free time. And nice comparisons.
Thnx for sharing.
Add some pictures for the optic.
Quote Originally Posted by Blubb1337 View Post
Add some pictures for the optic.
i will try to but, why, my friend, want begginers do that?
It simply looks better xD
Quote Originally Posted by Blubb1337 View Post
It simply looks better xD
awww i will make my next TUTs with picks
PICTURESSSSSSSSSSSSSSSSSS
I agree, Tutorials are lengthy with pics, if you insist on just copying and pasting code into a new topic, I will have to become a little more forceful, keep simplistic mini-tutorials and small code in the snippets vault, if you feel like creating a lengthy tutorial, then feel free to create a whole topic on it
Quote Originally Posted by NextGen1 View Post
I agree, Tutorials are lengthy with pics, if you insist on just copying and pasting code into a new topic, I will have to become a little more forceful, keep simplistic mini-tutorials and small code in the snippets vault, if you feel like creating a lengthy tutorial, then feel free to create a whole topic on it
well nextgen, all my new TUT's will be with pictures or with vids
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us