Clean game status output on terminal

This commit is contained in:
Pradana AUMARS 2021-06-28 22:36:04 +02:00
parent 54c5f78370
commit bb6d81c99d
2 changed files with 6 additions and 19 deletions

View File

@ -125,24 +125,13 @@ 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_score_run(p); Pong_status(p);
if (!quit) putc('\r', stdout);
} }
Pong_score_end(p); putc('\n', stdout);
} }
void void
Pong_score(const Pong *p, char c) { Pong_status(const Pong *p) {
printf("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);
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');
} }

View File

@ -25,8 +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_score(const Pong *p, char c); void Pong_status(const Pong *p);
void Pong_score_run(const Pong *p);
void Pong_score_end(const Pong *p);
#endif #endif