Minor rewrite of Pong_status
This commit is contained in:
parent
bb6d81c99d
commit
46e9265365
12
src/pong.c
12
src/pong.c
@ -125,13 +125,17 @@ Pong_run(Pong *p) {
|
|||||||
Racket_move(p->racketL);
|
Racket_move(p->racketL);
|
||||||
Racket_move(p->racketR);
|
Racket_move(p->racketR);
|
||||||
if (Pong_render(p) > 0) quit = true;
|
if (Pong_render(p) > 0) quit = true;
|
||||||
Pong_status(p);
|
Pong_status(p, quit);
|
||||||
if (!quit) putc('\r', stdout);
|
|
||||||
}
|
}
|
||||||
putc('\n', stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Pong_status(const Pong *p) {
|
Pong_status(const Pong *p, int quit) {
|
||||||
printf("[STATUS] SCORE: L %i | R %i", p->racketL->score->score, p->racketR->score->score);
|
printf("[STATUS] SCORE: L %i | R %i", p->racketL->score->score, p->racketR->score->score);
|
||||||
|
if (quit) {
|
||||||
|
putc('\n', stdout);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
putc('\r', stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ void Pong_clear(Pong *p);
|
|||||||
int Pong_render(Pong *p);
|
int Pong_render(Pong *p);
|
||||||
void Ball_move(Ball *b, Pong *p);
|
void Ball_move(Ball *b, Pong *p);
|
||||||
void Pong_run(Pong *p);
|
void Pong_run(Pong *p);
|
||||||
void Pong_status(const Pong *p);
|
void Pong_status(const Pong *p, int quit);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user