/
controls.ino
86 lines (83 loc) · 1.97 KB
/
controls.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
//GAME CONTROL
void controls(){
bool wall;
/* ------- BUTTON 1 - LEFT ------- */
if(arduboy.pressed(LEFT_BUTTON)){
//generateMaze();
if(posx-1>=0){
wall=readPixel(posx-1,posy);
if(!wall){
--posx;
tunes.tone(2200,5);
}else{
tunes.tone(1000,50);
}
}else{
tunes.tone(1000,50);
}
delay(30);
}
/* ------- BUTTON 2 - RIGHT ------- */
if(arduboy.pressed(RIGHT_BUTTON)){
if(posx+1<=MAZEHEIGHT+1){
wall=readPixel(posx+1,posy);
if(!wall){
++posx;
tunes.tone(2200,5);
}else{
tunes.tone(1000,50);
}
}else{
tunes.tone(1000,50);
}
delay(30);
}
/* ------- BUTTON 3 - UP ------- */
if(arduboy.pressed(UP_BUTTON)){
if(posy-1>=2){
wall=readPixel(posx,posy-1);
if(!wall){
--posy;
tunes.tone(2200,5);
}else{
tunes.tone(1000,50);
}
}else{
tunes.tone(1000,50);
}
delay(30);
}
/* ------- BUTTON 4 - DOWN ------- */
if(arduboy.pressed(DOWN_BUTTON)){
if(posy+1<=MAZEWIDTH){
wall=readPixel(posx,posy+1);
if(!wall){
++posy;
tunes.tone(2200,5);
}else{
tunes.tone(1000,50);
}
}else{
tunes.tone(1000,50);
}
delay(30);
}
/*
if(arduboy.pressed(A_BUTTON)){//A
//arduboy.fillCircle(20,30,5,WHITE);
tunes.tone(2400,5);
delay(60);
}
if(arduboy.pressed(A_BUTTON | B_BUTTON)){//B
//arduboy.fillCircle(50,30,5,WHITE);
tunes.tone(2400,5);
delay(60);
}*/
if (arduboy.pressed(B_BUTTON)){//MENU
//arduboy.fillCircle(80,30,5,WHITE);
gamePaused=true;
tunes.tone(2400,5);
delay(200);
//button7State = digitalRead(button7Pin);
}
}