-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore.c
65 lines (56 loc) · 1.37 KB
/
score.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "nano/console.h"
#include "nano/io.h"
#include "score.h"
#define LEVEL_UP 20 //
/* ------------------------------------------------------------------------ */
void score_init(score_t *self, int x, int y)
{
self->left = x;
self->top = y;
self->visible =
self->score =
self->lines =
self->figures =
self->level = 0;
self->start_time = io_now();
}
/* ------------------------------------------------------------------------ */
void score_start(score_t *self)
{
self->score =
self->lines =
self->figures =
self->level = 0;
self->start_time = io_now();
}
/* ------------------------------------------------------------------------ */
int score_level(score_t *self)
{
return self->level = self->figures / LEVEL_UP;
}
/* ------------------------------------------------------------------------ */
void score_draw(score_t *self)
{
con_color(green);
if (!self->visible) {
con_box(self->left, self->top, green, "\
Lines:\n\
Figures:\n\
Level:\n\
Score:\n");
self->visible = 1;
}
con_xy(self->left + 10, self->top);
con_bold();
con_put("%4d", self->lines); con_lf();
con_put("%4d", self->figures); con_lf();
con_put("%4d", self->level + 1); con_lf();
con_put("%4d", self->score);
con_uncol();
}
/* ------------------------------------------------------------------------ */
void score_refresh(score_t *self)
{
self->visible = 0;
score_draw(self);
}