**1**

###
#2
Crossbones+ - Reputation: **8152**

Posted 18 October 2012 - 07:56 PM

You can predict the ball's destination by intersecting its velocity vector with the paddle axis (and if the velocity vector is normalized, the distance of the intersection along that vector also happens to give the time to intersection).

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

- *Pessimal Algorithms and Simplexity Analysis*

###
#6
Crossbones+ - Reputation: **777**

Posted 20 October 2012 - 09:16 PM

here is the code I am using

if(right_paddle>=-220) { right_paddle=-right_paddle_vel; } if(right_paddle<=220) { right_paddle+=right_paddle_vel; }

Your paddle appears to be doing the following:

If your paddle position is greater than -220, it's position will be set to -right_paddle_vel. I'm going to assume right_paddle_vel is less than 220, so it seems as if it will be stuck there.

Otherwise, we will keep moving it at a speed of right_paddle_vel.

Maybe you want to do this.

if(paddle_y > ball_y){ paddle_y -= vel; } else if(paddle_y < ball_y){ paddle_y += vel; }

where vel is some positive number.

**Edited by incertia, 20 October 2012 - 09:18 PM.**

###
#7
Crossbones+ - Reputation: **1976**

Posted 20 October 2012 - 10:02 PM

All you need is two points, the starting position (x1 + y1) and the ending position (x2 + y2). However, it's pretty easy if you know the velocity to find another point, put it in here, and then use either y = mx + b or y1 - y = m(x1 -x) To find anothe point. Just use some basic math to calculate the ending position of the ball, then move your computer paddle at a predetermined speed to find it (Preferably slower than velx, or else you'll end up having a never ending A.I.)

I'm a game programmer and computer science ninja !

Here's Breakout:

Breakout!

Want to ask about Python and / or Pygame? What about HTML5 / CSS3 / JavaScript? What about C++ and / or SFML 2 (and 1.6)? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

Superman3275@Gmail.com

or Personal-Message me on here !

###
#9
Members - Reputation: **767**

Posted 23 October 2012 - 08:44 PM

if(right_paddle > screenHeight || right_paddle < -screenHeight) { right_paddle+=right_paddle; } right_paddle+=5;