//Varaibles for images
PImage frankenstein, ghost;
//Variables for walls
wall[] walls;
//circle variables
float x=180;
float y=60;
float start=30;
float stop=30;
color colorOfWall = color(255);
color c;
//Sets the enviroment for the code
void setup() {
//background setup
size(1200, 790);
//calling images from the data file
//frankenstein = loadImage("frankenstein.png");
//ghost = loadImage("ghost.png");
//walls setup
walls=new wall[16];//creates an array(list) for the walls array starts at 0
walls[0]=new wall(150, 30, 10, 730);
walls[1]=new wall(200, 250, 750, 10);
walls[2]=new wall(250, 150, 10, 500);
walls[3]=new wall(200, 250, 10, 300);
walls[4]=new wall(150, 30, 850, 10);
walls[5]=new wall(150, 750, 860, 10);
walls[6]=new wall(300, 450, 10, 300);
walls[7]=new wall(200, 650, 80, 10);
walls[8]=new wall(300, 300, 80, 10);
walls[9]=new wall(370, 250, 10, 300);
walls[10]=new wall(400, 450, 10, 300);
walls[10]=new wall(370, 630, 300, 10);
walls[11]=new wall(370, 700, 300, 10);
walls[12]=new wall(370, 500, 300, 10);
walls[13]=new wall(400, 380, 10, 300);
walls[14]=new wall(1000, 30, 10, 720);
walls[15]=new wall(750, 100, 10, 500);
}
void draw() {
//for background
background (225, 225, 225);//refreshing the background
background(255,116,0);
//image(frankenstein, 1050, 650, 150, 150);
//image(ghost, 20, 20, 120, 120);
textSize(32);
fill(0);
text(millis()/1100, 1100, 30);//sets up a timer in millaseconds so divided by 1000 to get it in seconds
Circle();//cirlce function
//for walls
for (int i = 0; i < walls.length; i++) {
walls[i].draw();
}
}
//creats a class for the walls of the maze
class wall {
float x;
float y;
float w;
float h;
wall(float x1, float y1, float w1, float h1) {
x = x1;
y = y1;
w = w1;
h = h1;
}
//draws the walls
void draw() {
fill(0);
rect(x, y, w, h);
}
}
//user defined function for Circle
void Circle(){
fill(255);
ellipse(x, y, start, stop);
if (keyPressed == true) {
if (keyCode == LEFT || key == 'a') {
x += -2;
}
else if (c==colorOfWall){
x+=0;
}
if (keyCode == RIGHT || key == 'd') {
x += 2;
}
if (keyCode == UP || key == 'w') {
y += -2;
}
if (keyCode == DOWN || key == 's') {
y += 2;
}}}
Trying to get it to detect if it hits the color of the walls (black) the ball will not move.