Clean game status output on terminal
This commit is contained in:
parent
54c5f78370
commit
bb6d81c99d
21
src/pong.c
21
src/pong.c
@ -125,24 +125,13 @@ Pong_run(Pong *p) {
|
||||
Racket_move(p->racketL);
|
||||
Racket_move(p->racketR);
|
||||
if (Pong_render(p) > 0) quit = true;
|
||||
Pong_score_run(p);
|
||||
Pong_status(p);
|
||||
if (!quit) putc('\r', stdout);
|
||||
}
|
||||
Pong_score_end(p);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Pong_score(const Pong *p, char c) {
|
||||
printf("SCORE: L %i | R %i", p->racketL->score->score, p->racketR->score->score);
|
||||
putc(c, stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Pong_score_run(const Pong *p) {
|
||||
Pong_score(p, '\r');
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Pong_score_end(const Pong *p) {
|
||||
Pong_score(p, '\n');
|
||||
Pong_status(const Pong *p) {
|
||||
printf("[STATUS] SCORE: L %i | R %i", p->racketL->score->score, p->racketR->score->score);
|
||||
}
|
||||
|
@ -25,8 +25,6 @@ void Pong_clear(Pong *p);
|
||||
int Pong_render(Pong *p);
|
||||
void Ball_move(Ball *b, Pong *p);
|
||||
void Pong_run(Pong *p);
|
||||
void Pong_score(const Pong *p, char c);
|
||||
void Pong_score_run(const Pong *p);
|
||||
void Pong_score_end(const Pong *p);
|
||||
void Pong_status(const Pong *p);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user