PImage labirinto; int x,y; void setup() { size(406,206); // Tamanho da tela labirinto = loadImage("labirinto.png"); // Carrega o labirinto x = 10; // Posição inicial y = 10; // Posição inicial } void draw() { image(labirinto,0,0); // Exibe a imagem if(get(x,y)==color(0)) { // Se bater em uma parede (cor preta) reinicia x = 10; y = 10; } fill(0, 255, 0); // Desenha o objeto rect(x,y, 4, 4); // Desenha o objeto } void keyPressed() { // Tratamento das teclas pressionadas if(key==CODED) { if(keyCode==UP) { y = y - 1; } if(keyCode==DOWN) { y = y + 1; } if(keyCode==LEFT) { x = x - 1; } if(keyCode==RIGHT) { x = x + 1; } } }