/* pong, Copyright (c) 2003 Jeremy English <jenglish@myself.com>
* A pong screen saver
*
+ * Modified by Brian Sawicki <sawicki@imsa.edu> 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 <tlb@tlb.org> to use analogtv.[ch] display.
* Also added gradual acceleration of the ball, shrinking of paddles, and
* scorekeeping.
int h;
} Ball;
-static int delay;
Paddle l_paddle;
Paddle r_paddle;
Ball ball;
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)
{
else
{
r_paddle.score++;
+ if (r_paddle.score >=10)
+ new_game();
+ else
start_game();
}
}
else
{
l_paddle.score++;
+ if (l_paddle.score >= 10)
+ new_game();
+ else
start_game();
}
}
}
#endif
- delay = get_integer_resource ("delay", "Integer");
- if (delay < 0) delay = 0;
-
/*Init the paddles*/
l_paddle.x = 8;
l_paddle.y = 100;
char *defaults [] = {
".background: black",
".foreground: white",
- "*delay: 10000",
"*speed: 6",
ANALOGTV_DEFAULTS
"*TVContrast: 150",
};
XrmOptionDescRec options [] = {
- { "-delay", ".delay", XrmoptionSepArg, 0 },
{ "-percent", ".percent", XrmoptionSepArg, 0 },
{ "-speed", ".speed", XrmoptionSepArg, 0 },
ANALOGTV_OPTIONS