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