-
Notifications
You must be signed in to change notification settings - Fork 0
/
forbetter.c
88 lines (82 loc) · 1.62 KB
/
forbetter.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// =====================================================
// INTERRUPCIONES
// =====================================================
// #region
// Timer1 interrupt
// Game timer. Se encarga de llevar el juego en si.
ISR(TIMER1_COMPA_vect){
if (game1.state == inGame)
{
if (ledInc())
{
ledBar = game1.gameBar.leds;
}
else
{
game1.state = gameover;
game1.gameButton.status = shoot;
}
}
else if (game1.state == gameover)
{
if (winShot())
{
greenOn;
if (won())
{
}
// revisar exactamente como se gana/pierde
}
else if (loseShot())
{
while (1)
{
redOn;
_delay_ms(1000);
redOff;
_delay_ms(1000);
}
game1.score = 0;
game1.player = loser;
}
else
{
game1.chances--;
redOn;
gameReset();
}
}
else
{
gameReset();
}
}
// Int0 interrupt
// Btn. Inicia, dispara y resetea el juego.
ISR(INT0_vect){
char b = pressed();
if (b == start)
{
game1.gameBar.leds = 0;
game1.state = inGame;
greenOff;
redOff;
}
else if (b == shoot)
{
game1.state = gameover;
}
else if (b == reset)
{
game1.state = set;
}
// debounce
_delay_ms(200);
}
// PCINT2 interrupt
// Dip Sw. Setea la difficultad y el modo del juego.
ISR(PCINT2_vect)
{
gameSet();
}
// #endregion