hey ive been working on it and i fianally got it pretty much working
you need to put 1 button on called start 1 picturebox called picturebox1 and that it here's the code
CODE
Public Class form1
' Move a paddle by the mouse
' With a bouncing ball
' module variables -- these variables exist across Subs
Dim px, py As Integer
' establish a variable called paper of type Graphics
Dim paper As Graphics
' ball position variables
Dim bx, by, bdx, bdy, n As Integer
' horizontal mouse position
Dim mousex, oldmx As Integer
' maximum of picture box
Dim xmax, ymax As Integer
Const paddleheight As Integer = 10
Const paddlewidth As Integer = 40
Private Sub start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles start.Click
' set paper = to the existing picture box
' (which we named picBox in the form)
paper = PictureBox1.CreateGraphics()
' make the picture box all white
paper.Clear(Color.White)
' top left coordinates of paddle
' horiz is center - 20
px = PictureBox1.Width / 2 - 20
' vertical is
py = PictureBox1.Height - 40
paper.FillRectangle(Brushes.Green, px, py, paddlewidth, paddleheight)
' initial values for ball
bx = 35 ' x,y is coordinates of top left corner
by = 3
bdx = 2 ' change in x each tick
bdy = 1 ' change in y each tick
' initial horizontal value for mouse
oldmx = Control.MousePosition.X
' right and bottom sides of picturebox
xmax = PictureBox1.Width
ymax = PictureBox1.Height
' display the ball
paper.FillEllipse(Brushes.Blue, bx, by, 20, 20)
' hide the Start button
start.Visible = False
' Set timer to tick every 10 milliseconds
Timer1.Interval = 10
' start timer
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' update ball
' erase the previous circle
paper.FillEllipse(Brushes.White, bx, by, 20, 20)
' change the position
bx = bx + bdx
by = by + bdy
'see if the ball is hitting the paddle
If bx <= px + paddlewidth And bx > px Then
If (by + 20) >= py Then
by = by - 2 * bdy
bdy = -bdy
End If
End If
' check for boundaries
If (bx + 20) > xmax Then
bx = bx - 2 * bdx
bdx = -bdx
ElseIf bx < 0 Then
bx = -bx
bdx = -bdx
End If
If (by + 20) > ymax Then
by = by - 2 * bdy
bdy = -bdy
ElseIf by < 0 Then
by = -by
bdy = -bdy
End If
' now draw the circle again
paper.FillEllipse(Brushes.Blue, bx, by, 20, 20)
' now handle the paddle
' get current horizontal location of mouse pointer
mousex = Control.MousePosition.X
If mousex < oldmx And px > 0 Then
' erase paddle
paper.FillRectangle(Brushes.White, px, py, paddlewidth, paddleheight)
' move paddle left
px = px - 5
' draw new paddle
paper.FillRectangle(Brushes.Green, px, py, paddlewidth, paddleheight)
ElseIf mousex > oldmx And px < xmax - paddlewidth Then
' erase paddle
paper.FillRectangle(Brushes.White, px, py, paddlewidth, paddleheight)
' move paddle right
px = px + 5
' draw new paddle
paper.FillRectangle(Brushes.Green, px, py, paddlewidth, paddleheight)
End If
' save location of mouse pointer for comparison
oldmx = mousex
End Sub
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
there are a few glitches and if i were you i'd make it so when it hit the bottom it was game over but its ure game so any way here u go