ok, happens is meant go menu screen once, , not return after have made selection. @ moment, have game programmed it. however, cannot play game because return menu screen, defying if statements put in place. here code, please help.
code: [select]
int maze = 0;
int maze_running = 0;
int counter_loc_x = 10;
int counter_loc_y = 10;
int selector_x = 10;
int selector_y = 10;
int selector = 1;
#include <tft.h> // hardware-specific library
#include <spi.h>
#include <esplora.h>
void setup() {
esploratft.begin();
esploratft.background(255, 0, 0);
delay(250);
esploratft.fill(0, 0, 255);
esploratft.stroke(0, 0, 255);
esploratft.rect(10, 10, 139, 47);
delay(250);
esploratft.rect(10, 67, 139, 47);
delay(250);
esploratft.stroke(255, 255, 255);
esploratft.fill(0, 30, 255);
esploratft.rect(selector_x, selector_y, 139, 47);
delay(250);
esploratft.settextsize(3);
esploratft.stroke(0, 0, 0);
esploratft.text("mouse", 40, 20);
delay(250);
esploratft.text("maze", 40, 80);
}
void loop() {
if (selector = 1) {
if (esplora.readbutton(switch_1) == low) {
selector_y = 67;
esploratft.background(255, 0, 0);
esploratft.stroke(255, 255, 255);
esploratft.fill(0, 30, 255);
esploratft.rect(selector_x, selector_y, 139, 47);
esploratft.stroke(0, 0, 255);
esploratft.fill(0, 0, 255);
esploratft.rect(10, 10, 139, 47);
esploratft.stroke(0, 0, 0);
esploratft.text("mouse", 40, 20);
esploratft.text("maze", 40, 80);
delay(500);
}
if (esplora.readbutton(switch_3) == low) {
selector_y = 10;
esploratft.background(255, 0, 0);
esploratft.stroke(255, 255, 255);
esploratft.fill(0, 30, 255);
esploratft.rect(selector_x, selector_y, 139, 47);
esploratft.stroke(0, 0, 255);
esploratft.fill(0, 0, 255);
esploratft.rect(10, 67, 139, 47);
esploratft.stroke(0, 0, 0);
esploratft.text("mouse", 40, 20);
esploratft.text("maze", 40, 80);
delay(500);
}
if (esplora.readbutton(switch_2) == low) {
maze = 1;
selector = 0;
}
}
if (maze == 1) {
esploratft.background(0,0,0); // clear screen black
delay(1000);
esploratft.stroke(0, 0, 255);
esploratft.fill(0, 0, 255);
esploratft.rect(0, 0, 10, 120);
delay(100);
esploratft.rect(10, 0, 159, 10);
delay(100);
esploratft.rect(10, 110, 159, 120);
delay(100);
esploratft.rect(149, 0, 159, 100);
delay(100);
esploratft.rect(20, 0, 10, 100);
delay(100);
esploratft.rect(40, 20, 10, 120);
delay(100);
esploratft.rect(60, 0, 10, 100);
delay(100);
esploratft.rect(80, 20, 10, 120);
delay(100);
esploratft.rect(100, 0, 10, 100);
delay(100);
esploratft.rect(120, 20, 10, 120);
delay(100);
esploratft.rect(140, 0, 10, 100);
delay(100);
esploratft.stroke(255, 0, 0);
esploratft.fill(255, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, counter_loc_x, counter_loc_y);
maze = 0;
maze_running = 1;
}
if (maze_running = 1) {
if (esplora.readbutton(switch_1) == low) {
esploratft.fill(0, 0, 0);
esploratft.stroke(0, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10 );
counter_loc_y = counter_loc_y + 10;
esploratft.fill(255, 0, 0);
esploratft.stroke(255, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10);
delay(250);
}
if (esplora.readbutton(switch_4) == low) {
esploratft.fill(0, 0, 0);
esploratft.stroke(0, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10 );
counter_loc_x = counter_loc_x + 10;
esploratft.fill(255, 0, 0);
esploratft.stroke(255, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10);
delay(250);
}
if (esplora.readbutton(switch_2) == low) {
esploratft.fill(0, 0, 0);
esploratft.stroke(0, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10 );
counter_loc_x = counter_loc_x - 10;
esploratft.fill(255, 0, 0);
esploratft.stroke(255, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10);
delay(250);
}
if (esplora.readbutton(switch_3) == low) {
esploratft.fill(0, 0, 0);
esploratft.stroke(0, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10 );
counter_loc_y = counter_loc_y - 10;
esploratft.fill(255, 0, 0);
esploratft.stroke(255, 0, 0);
esploratft.rect(counter_loc_x, counter_loc_y, 10, 10);
delay(250);
}
}
}
should ==code: [select]
if (selector = 1) {
if (maze_running = 1) {
Arduino Forum > Using Arduino > Programming Questions > Problem with program
arduino
Comments
Post a Comment