Results 1 to 7 of 7

Thread: pong physics

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    pong physics

    How can I make the ball bounce in pong? I want to be able to bounce the ball of the wall and have it go in the relative direction. It's no fun when the ball bounces straight back and forth...

    Thanx for any help.
    <removed by admin>

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Here's a little demo I just made to teach someone a bit programming...

    Have fun
    Attached Files Attached Files

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Thanks. That's pretty cool, but it's not really what I need, unless I can figure out how to change the code to make the code automatic. I need the ball to bounce around without having to press buttons. You should know what I'm talking about, everyone has played pong before...
    <removed by admin>

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    mmm... I thought this would not be a problem and you just need the code for collision or movement erm..

    Well you can simply set the speed variables to a value each time

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Easy!

    When it collides with the right/left wall, use this:
    Code:
    XSpeed = -XSpeed 'where xspeed is the movement of the ball on the x-axis in pixels, in game seconds
    And when it hits the top/bottom wall...
    Code:
    YSpeed = -YSpeed 'where yspeed is the movement of the ball on the y-axis in pixels, in game seconds
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    If I understand you right you really want to know the basics
    so what you need to do for the ball to move automatically is increase the X and Y of the ball by Xspeed and Yspeed. Sastraxi described how to change the X- and Y-speed on collision with the walls.
    But that still would not make the ball move in different angles. So what you should do is if the ball hits the paddle further at the left you should decrease the xspeed value and if you hit it further on the right increase the xspeed value.
    I hope this was kind of understandable.

    Just ask if there are more questions. ( I can look for some old Pong games I wrote long time ago)
    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I finished my pong game, but I didn't do it the way your mentioned. I'll upload it to ths post.
    Attached Files Attached Files
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width