|
|
|
@ -17,7 +17,7 @@ void xy2rc(float x, float y, int *r, int *c) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float lerp(float from, float to, float t) {
|
|
|
|
|
return from + t * (to-from);
|
|
|
|
|
return from + t * (to - from);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float ball_x = 0.0;
|
|
|
|
@ -36,7 +36,7 @@ void paint_ball() {
|
|
|
|
|
|
|
|
|
|
void paint_paddles() {
|
|
|
|
|
int r, c;
|
|
|
|
|
xy2rc( 0, pad_l, &r, &c);
|
|
|
|
|
xy2rc(0, pad_l, &r, &c);
|
|
|
|
|
mvaddch(r, c, ACS_VLINE);
|
|
|
|
|
|
|
|
|
|
xy2rc(MAX_X, pad_r, &r, &c);
|
|
|
|
@ -56,14 +56,14 @@ int main() {
|
|
|
|
|
initscr(); /* Start curses mode */
|
|
|
|
|
curs_set(0); /* Disable cursor */
|
|
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
|
while (true) {
|
|
|
|
|
ball_x += dir_x;
|
|
|
|
|
ball_y += dir_y;
|
|
|
|
|
|
|
|
|
|
if (ball_x>MAX_X || ball_x<0) {
|
|
|
|
|
if (ball_x > MAX_X || ball_x < 0) {
|
|
|
|
|
dir_x = -dir_x;
|
|
|
|
|
}
|
|
|
|
|
if (ball_y>MAX_Y || ball_y<0) {
|
|
|
|
|
if (ball_y > MAX_Y || ball_y < 0) {
|
|
|
|
|
dir_y = -dir_y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|