X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fpong.c;h=3820dc7b5a00ca9255f23b65c8ee97894022a057;hp=aa7c6049eb1e6e9569ce5762b1293c9d9aa8641d;hb=2d04c4f22466851aedb6ed0f2919d148f726b889;hpb=bc7b7a8eb122206d239ec0e693676bcce31be1aa diff --git a/hacks/pong.c b/hacks/pong.c index aa7c6049..3820dc7b 100644 --- a/hacks/pong.c +++ b/hacks/pong.c @@ -1,6 +1,13 @@ /* pong, Copyright (c) 2003 Jeremy English * A pong screen saver * + * Modified by Brian Sawicki to fix a small bug. + * Before this fix after a certain point the paddles would be too + * small for the program to effectively hit the ball. The score would + * then skyrocket as the paddles missed most every time. Added a max + * so that once a paddle gets 10 the entire game restarts. Special + * thanks to Scott Zager for some help on this. + * * Modified by Trevor Blackwell to use analogtv.[ch] display. * Also added gradual acceleration of the ball, shrinking of paddles, and * scorekeeping. @@ -87,6 +94,27 @@ hit_top_bottom(void) by=-by; } +void +new_game(void) +{ + /* Starts a Whole New Game*/ + ball.x = PONG_W/2; + ball.y = PONG_H/2; + bx = m_unit; + by = m_unit; + + l_paddle.wait = 1; + l_paddle.lock = 0; + r_paddle.wait = 0; + r_paddle.lock = 0; + paddle_rate = m_unit-1; + r_paddle.score = 0; + l_paddle.score = 0; + + l_paddle.h = PONG_H/4; + r_paddle.h = PONG_H/4; +} + void start_game(void) { @@ -124,6 +152,9 @@ hit_paddle(void) else { r_paddle.score++; + if (r_paddle.score >=10) + new_game(); + else start_game(); } } @@ -143,6 +174,9 @@ hit_paddle(void) else { l_paddle.score++; + if (l_paddle.score >= 10) + new_game(); + else start_game(); } }