Fractalytic.co.uk - Pong in 25 lines Source Code


Pong Source Code

This is the Blitz Basic source code for single player Pong using just 25 lines without any 'cheating' (each line contains only one command but note that due to screen resolution I have split the lines onto multiple ones here for presentation purposes). The game doesn't include sound but does have a scoring routine, a ball that gets faster as the point progresses, simple AI and real physics (albeit with a random element thrown in so that it isn't too predictable).





To anybody familiar with Blitz Basic there shouldn't be anything above that causes you too much trouble. No external media is required so the code can be compiled and run as is.

The variables used should be fairly self explanatory but if you are unsure the following may help:

  • P1y and P2y are the y co-ordinates corresponding to the top of the player bats.
  • P1score and P2score are the player scores
  • Bx and By are the x and y coordinates of the ball
  • Bangle is the angle that the ball is travelling in measured from the horizontal (in the range -180 to 180)
  • start is the time in milliseconds that the current point started 



< Back to Top >




www.000webhost.com