-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode_8_bonus.ino
168 lines (154 loc) · 3.52 KB
/
mode_8_bonus.ino
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// ___ _ _ _ _
// | _ ) ___ _ _ _ _ ___ | || |__ _ _ _ __| | |___ _ _
// | _ \/ _ \ ' \ || (_-< | __ / _` | ' \/ _` | / -_) '_|
// |___/\___/_||_\_,_/__/ |_||_\__,_|_||_\__,_|_\___|_|
//
//----------------------------------------
//define includes
//----------------------------------------
//----------------------------------------
//----------------------------------------
//define global variables
//----------------------------------------
static byte bonus_count[max_players];
static byte bonus_mult[max_players];
void bonus_inc()
{
if (bonus_count[active_player_id] < 10)
{ // Was 55
bonus_count[active_player_id] += 1;
Serial.print(F("Increase bonus to: "));
Serial.println(String(bonus_count[active_player_id]));
update_bonus_lamps(bonus_count[active_player_id]);
}
}
void bonus_mult_inc()
{
if (bonus_mult[active_player_id] < 15)
{
bonus_mult[active_player_id] += 1;
Serial.print(F("Increase bonus multipler to: "));
Serial.println(String(bonus_mult[active_player_id]));
update_bonus_mult_lamps(bonus_mult[active_player_id]);
}
}
void reset_bonus_lamps()
{
lamp_bonus1K.off();
lamp_bonus2K.off();
lamp_bonus3K.off();
lamp_bonus4K.off();
lamp_bonus5K.off();
lamp_bonus6K.off();
lamp_bonus7K.off();
lamp_bonus8K.off();
lamp_bonus9K.off();
lamp_bonus10K.off();
}
void update_bonus_lamps(byte countback)
{
reset_bonus_lamps();
if (countback >= 10)
{
lamp_bonus10K.on(0);
countback -= 10;
}
if (countback >= 9)
{
lamp_bonus9K.on(0);
countback -= 9;
}
if (countback >= 8)
{
lamp_bonus8K.on(0);
countback -= 8;
}
if (countback >= 7)
{
lamp_bonus7K.on(0);
countback -= 7;
}
if (countback >= 6)
{
lamp_bonus6K.on(0);
countback -= 6;
}
if (countback >= 5)
{
lamp_bonus5K.on(0);
countback -= 5;
}
if (countback >= 4)
{
lamp_bonus4K.on(0);
countback -= 4;
}
if (countback >= 3)
{
lamp_bonus3K.on(0);
countback -= 3;
}
if (countback >= 2)
{
lamp_bonus2K.on(0);
countback -= 2;
}
if (countback >= 1)
{
lamp_bonus1K.on(0);
countback -= 1;
}
}
void reset_bonus_mult_lamps()
{
lamp_mult1X.off();
lamp_mult2X.off();
lamp_mult3X.off();
lamp_mult4X.off();
lamp_mult5X.off();
}
void update_bonus_mult_lamps(byte countback)
{
reset_bonus_mult_lamps();
if (countback >= 5)
{
lamp_mult5X.on(0);
countback -= 5;
}
if (countback >= 4)
{
lamp_mult4X.on(0);
countback -= 4;
}
if (countback >= 3)
{
lamp_mult3X.on(0);
countback -= 3;
}
if (countback >= 2)
{
lamp_mult2X.on(0);
countback -= 2;
}
if (countback >= 1)
{
lamp_mult1X.on(0);
countback -= 1;
}
}
void count_bonus()
{
int between_delay = 200;
for (byte mult = bonus_mult[active_player_id]; mult > 0; mult--)
{
update_bonus_mult_lamps(mult);
for (byte count = bonus_count[active_player_id]; count > 0; count--)
{
sound_channel1.play(17);
update_bonus_lamps(count);
update_score(active_player_id, 1000);
delay(max(between_delay, 50));
}
between_delay -= 50;
}
}