3 Replies - 382 Views - Last Post: 16 May 2013 - 09:47 AM Rate Topic: -----

#1 ownage112  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-May 13

Help with this pong game?

Posted 15 May 2013 - 07:55 AM

using this code : http://www.vbforums....551-VB-Net-Pong

How would i make it so that everytime the ball goes of the screen and respawns, another one spawns too, and so on. so theres many balls on the screen at the same time??

Thanks!!!
Is This A Good Question/Topic? 0
  • +

Replies To: Help with this pong game?

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1606
  • View blog
  • Posts: 5,163
  • Joined: 25-September 09

Re: Help with this pong game?

Posted 15 May 2013 - 08:00 AM

it appears that the ball is a panel.

You would need to set the location of the current ball that went off the screen to its respawn location and instantiate a new ball with its spawn location.
Was This Post Helpful? 0
  • +
  • -

#3 ownage112  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-May 13

Re: Help with this pong game?

Posted 15 May 2013 - 08:06 AM

how would i do that? Im still new at coding, Sorry
Was This Post Helpful? 0
  • +
  • -

#4 dday9  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 86
  • Joined: 17-April 13

Re: Help with this pong game?

Posted 16 May 2013 - 09:47 AM

Hey hey! That's my project! I feel awesome that somebody's actually using it. Anyways... Going off of Charlie's suggestion, create a general list(of <t>) where the <t> is a panel. From there add the panels to the list, and the form:

This is how you declare the list, and add the original ball:
Dim ballList As New List(Of Panel)
ballList.Add(ball)



This is how you add more balls:
Dim newBall As New Ball
With newBall
   .BackColor = Color.Black
   .BorderStyle = BorderStyle.FixedSingle
   .Size = New Size(10, 10)
   .Location = New Point(CInt(Me.Width / 2 - newBall.Width / 2), CInt(Me.Height / 2 - newBall.Height / 2))
   Me.Controls.Add(newBall)
   ballList.Add(newBall)
End With



the only issue you'd have is generating where all the other balls go in the Collision sub. Right now I only handled, and anticipated, only one ball. You'll have to either:
A- Use a timer for each ball
B- Use a managed game loop

B is the better choice, it's just a little more difficult to get going.

This post has been edited by dday9: 16 May 2013 - 09:48 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1