xxxxxxxxxx
int x;
int y;
int w;
int speed;
int eX;
int eY;
int eWidth;
PFont font;
int linex;
int linex2;
boolean bgChange=false;
boolean shiftTyped=false;
void setup() {
size(400, 400);
eX=width/2;
eY=height/2;
eWidth=200;
x=150;
y= 30;
w= 30;
speed= -5;
linex= width/4;
linex2= width*3/4;
}
void draw() {
background(0, 0, 255);
ellipse (x, y, w, w);
line (linex, 0, linex, height);
line (linex2, 0, linex2, height);
x = x+ speed;
if (( x > 400) || (x < 10)) {
speed = 5;
// move to the left
//speed= -5;
}
//if (x<linex) {
//move right
//speed=5;
if ((x> width) || (x<0)) {
speed=speed*-1;
}
if (bgChange ==true) {
background (255, 0, 0);
ellipse (x, y, w, w);
} else {
background (0, 255, 255);
fill (0, 0, 0);
ellipse (eX, eY, eWidth+100, eWidth+100);
font = loadFont("OratorStd-48.vlw");
fill (255, 255, 255);
textFont (font, 20); // draws the font + gives it a size
text ("Click or Press:SHIFT", 100, height/2);
}
if (shiftTyped==true) {
background(255, 0, 0);
fill (0, 0, 0);
ellipse (x, y+120, w+70, w+70);
fill (255, 255, 255);
ellipse (x, y+120, w+20, w+20);
}
}
void keyPressed() {
if (keyCode==SHIFT) {
shiftTyped=true;
}
}
void keyReleased() {
if (keyCode==SHIFT) {
shiftTyped=false;
}
}
void mouseClicked () {
if (dist (eX, eY, mouseX, mouseY)<eWidth/2) {
}
if (bgChange ==true) {
bgChange= false;
} else {
bgChange= true;
}
}