Results 1 to 5 of 5
  1. #1
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,971
    My Mood
    Happy

    How To Make a Bouncing Ball

    Welcome to my first tutorial.

    You will need:

    Visual basic
    A application
    A timer!

    .................................................. .................

    Add this to the over form1_load like this:

    Code:
    Public Class Form1
        Dim m_Dx As Integer
        Dim m_Dy As Integer
        Dim m_X As Integer
        Dim m_Y As Integer
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    All the Dim is X and Y axis for the ball....

    Then


    And add this code to form1_load.

    Code:
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim rnd As New Random
            m_Dx = rnd.Next(1, 4)
            m_Dy = rnd.Next(1, 4)
            m_X = rnd.Next(0, Me.ClientSize.Width - 50)
            m_Y = rnd.Next(0, Me.ClientSize.Height - 50)
        End Sub
    What that code does is to move the bounching ball to a random move....... Between 1 and 4!

    Then

    Add this code to make a ball.

    Code:
    e.Graphics.Clear(Me.BackColor)
            e.Graphics.FillEllipse(Brushes.Black, m_X, m_Y, 100, 100)
            e.Graphics.DrawEllipse(Pens.Black, m_X, m_Y, 100, 100)
    Then

    Set timer1.interval = 1 and make it enabled.
    this code to the timer!
    Code:
       m_X += m_Dx
            If m_X < 0 Then
                m_Dx = -m_Dx
                Beep()
            ElseIf m_X + 50 > Me.ClientSize.Width Then
                m_Dx = -m_Dx
                Beep()
            End If
            m_Y += m_Dy
            If m_Y < 0 Then
                m_Dy = -m_Dy
                Beep()
            ElseIf m_Y + 50 > Me.ClientSize.Height Then
                m_Dy = -m_Dy
                Beep()
            End If
            Me.Invalidate()
    That code moves the ball and and makes a beep sound when it´s hits the wall.

    Creditz for the code: environmentalnerd53.
    Me for the tutorial and some editing.

    ............................................

    Full code:
    Code:
    Public Class Form1
        Dim m_Dx As Integer
        Dim m_Dy As Integer
        Dim m_X As Integer
        Dim m_Y As Integer
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim rnd As New Random
            m_Dx = rnd.Next(1, 4)
            m_Dy = rnd.Next(1, 4)
            m_X = rnd.Next(0, Me.ClientSize.Width - 50)
            m_Y = rnd.Next(0, Me.ClientSize.Height - 50)
        End Sub
        Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
            e.Graphics.Clear(Me.BackColor)
            e.Graphics.FillEllipse(Brushes.Black, m_X, m_Y, 50, 50)
            e.Graphics.DrawEllipse(Pens.Black, m_X, m_Y, 50, 50)
        End Sub
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            m_X += m_Dx
            If m_X < 0 Then
                m_Dx = -m_Dx
                Beep()
            ElseIf m_X + 50 > Me.ClientSize.Width Then
                m_Dx = -m_Dx
                Beep()
            End If
            m_Y += m_Dy
            If m_Y < 0 Then
                m_Dy = -m_Dy
                Beep()
            ElseIf m_Y + 50 > Me.ClientSize.Height Then
                m_Dy = -m_Dy
                Beep()
            End If
            Me.Invalidate()
        End Sub
    End Class
    ............................................

    Final Resultat:

    -Rest in peace leechers-

    Your PM box is 100% full.

  2. #2
    maarten551's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    255
    Reputation
    10
    Thanks
    75
    My Mood
    Mellow
    wow impressive script i gonna test i tomorrow :P

  3. #3
    Asians's Avatar
    Join Date
    Jul 2009
    Gender
    female
    Location
    Asian world.
    Posts
    1,459
    Reputation
    34
    Thanks
    63
    It works. :'D Funny.

  4. #4
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,971
    My Mood
    Happy
    Quote Originally Posted by Asians View Post
    It works. :'D Funny.
    No problem...
    -Rest in peace leechers-

    Your PM box is 100% full.

  5. #5
    K4GE's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    311
    Reputation
    13
    Thanks
    65
    My Mood
    Inspired
    Lol nice tut

Similar Threads

  1. How to make a game?
    By Dave84311 in forum General
    Replies: 4
    Last Post: 09-12-2006, 12:33 AM
  2. How to make a working NFV Hack
    By System79 in forum Game Hacking Tutorials
    Replies: 1
    Last Post: 09-04-2006, 04:56 AM
  3. How to make the server run
    By wowhaxor in forum Gunz General
    Replies: 3
    Last Post: 05-25-2006, 09:59 PM
  4. How to make a Zombie
    By arunforce in forum Art & Graphic Design
    Replies: 2
    Last Post: 01-27-2006, 08:07 AM
  5. How I make wallhack?
    By RaidenDXX in forum WarRock - International Hacks
    Replies: 6
    Last Post: 01-23-2006, 01:28 PM

Tags for this Thread