Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

PONG (physics)

May 17, 2008 at 7:39:20 PM
Jero (1)
avatar
(Jeroen ) < El Ripper >
Posts: 1106 - Joined: 03/02/2008
Netherlands
Profile
As some of you know im working on a pong game. (totally seperate from nerdy nights)
anyway I need some of the ball and paddle gameplay mechanics. Anywhere I could find these?

May 18, 2008 at 1:50:34 PM
dangevin (219)
avatar
(Dan Langevin) < Wiz's Mom >
Posts: 12131 - Joined: 08/17/2006
Pennsylvania
Profile
some general pseudocode:

where x = horizontal motion, start at 1 y = vertical motion, start at 1 b = ball's screen position, start at left middle

ball loop b = x + y if then y = (-y) if then x = (-x) end loop

---

You can get fancier by "segmenting" each paddle and modifying x and y by more than 1 when it hits "extremes" of the paddle. If you start the ball motion variables out at 2 and 2, you can do this

if then if then x = (-x) else if then x = (-x) and y = (-y) and else if then x = (-x) and

----

Where "near edge" and "far edge" pertains to whether the motion of the ball is coming from the top or the bottom. This way the ball's vertical motion can keep getting faster depending on where you hit it. Also, you can reverse the motion of the ball and slow it a bit by hitting it with the facing edge of your paddle, "throw a curve" so to speak.

-------------------------