Hi,
I wrote some code but for some reason i cant get the buttons to do anything even though I dont see anything wrong in the code. I know that my buttons work. All that my code is supposed to do so far is jump from the menu to the main game when i press A and stop drawing the speaker icon in the menu when I press B. Neither of these things happen.
Thanks in advance.
#include "Arduboy.h"
Arduboy arduboy;
boolean sound = true;
int screen = 0;
void setup() {
arduboy.begin();
arduboy.setFrameRate(60);
arduboy.clear();
drawStartMenu();
arduboy.display();
}
void loop() {
//if (!(arduboy.nextFrame()))
//return;
while (screen = 0) {
drawStartMenu();
if (arduboy.pressed(B_BUTTON)) {
sound = false;
}
if (arduboy.pressed(A_BUTTON)) {
screen = 1;
}
}
while (screen = 1) {
drawRoom();
}
}
void drawRoom() {
arduboy.drawFastHLine(0, 0, 128, 1);
arduboy.drawFastHLine(0, 63, 128, 1);
arduboy.drawFastVLine(0, 0, 64, 1);
arduboy.drawFastVLine(127, 0, 64, 1);
arduboy.drawFastVLine(56, 0, 8, 1);
arduboy.drawFastVLine(71, 0, 8, 1);
arduboy.drawFastVLine(56, 56, 8, 1);
arduboy.drawFastVLine(71, 56, 8, 1);
arduboy.drawFastHLine(0, 24, 8, 1);
arduboy.drawFastHLine(0, 39, 8, 1);
arduboy.drawFastHLine(120, 24, 8, 1);
arduboy.drawFastHLine(120, 39, 8, 1);
}
void drawDoors(bool dn,bool de,bool ds,bool dw) {
if (dn) {
arduboy.drawFastHLine(56, 7, 16, 1);
}
if (de) {
arduboy.drawFastVLine(120, 24, 16, 1);
}
if (ds) {
arduboy.drawFastHLine(56, 56, 16, 1);
}
if (dw) {
arduboy.drawFastVLine(7, 24, 16, 1);
}
}
void drawStartMenu() {
arduboy.setCursor(0, 4);
arduboy.print("A to Start...");
arduboy.setCursor(0, 20);
arduboy.print("B to toggle Sound");
arduboy.drawCircle(56, 52, 8, 1);
arduboy.drawCircle(72, 41, 8, 1);
arduboy.setCursor(54, 49);
arduboy.print ("B");
arduboy.setCursor(70, 38);
arduboy.print ("A");
arduboy.drawTriangle(114, 20, 114, 28, 106, 24, 1);
if (sound) {
arduboy.drawFastVLine(116, 23, 3, 1);
arduboy.drawFastVLine(118, 22, 5, 1);
arduboy.drawFastVLine(120, 21, 7, 1);
}
}