xxxxxxxxxx
int rx = 101;
int ry = 475;
int z = 750;
void setup () {
size (1500, 950);
fill (90);
rect (0, 0, width, height);// background
fill (0);
rect (0, 0, width, 100); //top limit
rect (0, 0, 100, height);//left limit
rect (width - 100, 0, 100, height);//right limit
rect (0, height - 100, width, 100);//bottom limit
fill (255);
}
void draw() {
fill (90);
rect (0, 0, width, height);// background
fill (0);
rect (0, 0, width, 100); //top limit
rect (0, 0, 100, height);//left limit
rect (width - 100, 0, 100, height);//right limit
rect (0, height - 100, width, 100);//bottom limit
fill (255);
// //float d = map(x, y, width-1, 100, 200);
// //ellipse(width/2, height/2, d, d); // breathing circle
fill (0, 255, 178);
rect (rx, ry, 100, 100); //player
if (rx >= 400 && mousePressed){
rx = 101;
}
//Constrain
if (rx <= 101){
rx = 101;
}
else if (rx >= width - 200){
rx = width - 200;
}
if (ry <= 101){
ry = 101;
}
else if (ry >= height - 200){
ry = height - 200;
}
print( "the value of rx is" + rx);
}
void keyPressed() {
if (key == 'd'){ // right
rx = rx + 3;
}
else if (key == 'a') { //left
rx = rx - 3;
}
else if (key == 'w') { //up
ry = ry - 3;
}
else if (key == 's') {//down
ry = ry + 3;
}
}