# Pong Tutorial

Page 1 of 1

## 5 Replies - 3623 Views - Last Post: 22 November 2010 - 10:39 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=201485&amp;s=aa14ce50f723713a3b0f38c202cd0607&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 hifistyle

Reputation: 0
• Posts: 20
• Joined: 11-October 10

# Pong Tutorial

Posted 22 November 2010 - 09:56 AM

Hi,
I'm coding the game timer, but am noticing that the gameBall is undeclared and don't see it in the tutorial. Can anyone tell me why?
``` Private Sub gameTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gameTimer.Tick

'Set the computer player to move according to the ball's position."
If gameBall.Location.Y > 5 And gameBall.Location.Y < Me.Height - 40 _

' Move the game ball.
gameBall.Location = New Point(gameBall.Location.X + xVel, gameBall.Location.Y + yVel)

' Check for top wall.
If gameBall.Location.Y < 0 Then
gameBall.Location = New Point(gameBall.Location.X, 0)
yVel = -yVel
End If

' Check for bottom wall.
If gameBall.Location.Y > Me.Height - gameBall.Size.Height - 45 Then
gameBall.Location = New Point(gameBall.Location.X, Me.Height - gameBall.Size.Height - 45)
yVel = -yVel
End If

gameBall.Location = New Point(paddlePlayer.Location.X - gameBall.Size.Width, _
gameBall.Location.Y)
xVel = -xVel
End If

```

This post has been edited by macosxnerd101: 22 November 2010 - 10:00 AM
Reason for edit:: Fixed end code tag and moved to VB.NET

Is This A Good Question/Topic? 0

## Replies To: Pong Tutorial

### #2 hlx

Reputation: 31
• Posts: 135
• Joined: 13-November 10

## Re: Pong Tutorial

Posted 22 November 2010 - 10:05 AM

In the context of this tutorial, I think the gameball is a picturebox. Need to see the whole thing to be sure though.

Yes, if you are referring to the "Create a fully-functional pong game" tutorial, the gameball is a picturebox.

Quote

Now, whats a room without furniture? We need to add some controls now, so add three PictureBox controls to the form. Set the Name properties to paddleComputer, paddlePlayer and gameBall. For both paddlePlayer and paddleComputer, set the Size property to 16x128. For gameBall, set the Size property to 20x20. Select all three controls, and set the BackColor to a color of your preference; I chose LimeGreen.

Cited from: http://www.dreaminco...onal-pong-game/

This post has been edited by hlx: 22 November 2010 - 10:15 AM

### #3 CharlieMay

• This space intentionally left blank

Reputation: 1729
• Posts: 5,708
• Joined: 25-September 09

## Re: Pong Tutorial

Posted 22 November 2010 - 10:14 AM

Yes, hlx is correct,
This is directly out of the tutorial:

Quote

Now, whats a room without furniture? We need to add some controls now, so add three PictureBox controls to the form. Set the Name properties to paddleComputer, paddlePlayer and gameBall. For both paddlePlayer and paddleComputer, set the Size property to 16x128. For gameBall, set the Size property to 20x20. Select all three controls, and set the BackColor to a color of your preference; I chose LimeGreen.

### #4 hifistyle

Reputation: 0
• Posts: 20
• Joined: 11-October 10

## Re: Pong Tutorial

Posted 22 November 2010 - 10:21 AM

CharlieMay, on 22 November 2010 - 09:14 AM, said:

Yes, hlx is correct,
This is directly out of the tutorial:

Quote

Now, whats a room without furniture? We need to add some controls now, so add three PictureBox controls to the form. Set the Name properties to paddleComputer, paddlePlayer and gameBall. For both paddlePlayer and paddleComputer, set the Size property to 16x128. For gameBall, set the Size property to 20x20. Select all three controls, and set the BackColor to a color of your preference; I chose LimeGreen.

Interesting. I do have a picturebox control for the ball. But, it's still underlined in blue as being undeclared. Admitting that this is the most advanced coding for me to date.

Thanks!

### #5 hlx

Reputation: 31
• Posts: 135
• Joined: 13-November 10

## Re: Pong Tutorial

Posted 22 November 2010 - 10:26 AM

hifistyle, on 22 November 2010 - 09:21 AM, said:

CharlieMay, on 22 November 2010 - 09:14 AM, said:

Yes, hlx is correct,
This is directly out of the tutorial:

Quote

Now, whats a room without furniture? We need to add some controls now, so add three PictureBox controls to the form. Set the Name properties to paddleComputer, paddlePlayer and gameBall. For both paddlePlayer and paddleComputer, set the Size property to 16x128. For gameBall, set the Size property to 20x20. Select all three controls, and set the BackColor to a color of your preference; I chose LimeGreen.

Interesting. I do have a picturebox control for the ball. But, it's still underlined in blue as being undeclared. Admitting that this is the most advanced coding for me to date.

Thanks!

Did you ensure that the name property of your game ball picturebox was set to gameBall?

This post has been edited by hlx: 22 November 2010 - 10:26 AM

### #6 hifistyle

Reputation: 0
• Posts: 20
• Joined: 11-October 10

## Re: Pong Tutorial

Posted 22 November 2010 - 10:39 AM

hlx, on 22 November 2010 - 09:26 AM, said:

hifistyle, on 22 November 2010 - 09:21 AM, said:

CharlieMay, on 22 November 2010 - 09:14 AM, said:

Yes, hlx is correct,
This is directly out of the tutorial:

Quote

Now, whats a room without furniture? We need to add some controls now, so add three PictureBox controls to the form. Set the Name properties to paddleComputer, paddlePlayer and gameBall. For both paddlePlayer and paddleComputer, set the Size property to 16x128. For gameBall, set the Size property to 20x20. Select all three controls, and set the BackColor to a color of your preference; I chose LimeGreen.

Interesting. I do have a picturebox control for the ball. But, it's still underlined in blue as being undeclared. Admitting that this is the most advanced coding for me to date.

Thanks!

Did you ensure that the name property of your game ball picturebox was set to gameBall?

Thanks!

John

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }