int radius = 50, directionX = 1, directionY = 1;
float y = 250, x = 250, speed = 3;
float rotation = .1;
float limits1=0.7, limits2=5.3;
float stop=limits2, start=limits1;
boolean isMove = true;
float up=-4, down=4, left=-4, right=4;
float xDir=0, yDir;
boolean is = false;
int[]array=new int[8];
void setup()
{
size (800, 600);
noStroke();
smooth();
fill(255, 255, 0);
ellipseMode(RADIUS);
// frameRate(20);
}
void draw()
{
background(0);
stop+=rotation;
start-=rotation;
if (stop<=limits2||stop>limits2+0.7) {
rotation *=-1;
}
x+=xDir;
y+=yDir;
if (x>width)x=0;
if (x<0)x=width;
if (y<0)y=height;
if (y>height)y=0;
// if (w && n) {
// //start = 0.7-2*PI/3;
// //stop = 5.3-2*PI/3;
// arc(x, y, radius, radius, start-2*PI/3, stop-2*PI/3);
// }
// else if (w && s) {
// //start = 0.7-2*PI/3-PI/2;
// // stop = 5.3 -2*PI/3-PI/2;
// arc(x, y, radius, radius, start -2*PI/3-PI/2, stop -2*PI/3-PI/2);
// }
// else if (e && s) {
// //start =0.7-2*PI/3-PI;
// //stop = 5.3-2*PI/3-PI;
// arc(x, y, radius, radius, start-2*PI/3-PI, stop-2*PI/3-PI);
// }
// else if (e && n) {
// //stop = 5.3-PI/3+0.5;
// //start = 0.7-PI/3+0.5;
// arc(x, y, radius, radius, start-PI/3+0.5, stop-PI/3+0.5);
// }
if (xDir == -4 && yDir == 0) {
//start = 0.7-PI;
// stop = 5.3-PI;
arc(x, y, radius, radius, start-PI, stop-PI);
}
else if (xDir == 0 && yDir == -4) {
//start=0.7-PI/2;
//stop = 5.3-PI/2;
arc(x, y, radius, radius, start-PI/2+0.1, stop-PI/2+0.1);
}
else if (xDir == 0 && yDir == 4) {
// start=0.7+PI/2+0.1;
// stop =5.3+PI/2+0.1;
arc(x, y, radius, radius, start+PI/2+0.1, stop+PI/2+0.1);
}else if((xDir==0&&yDir==0)||(xDir==4&&yDir==0)){
arc(x, y, radius, radius, start, stop);
}
}
void keyPressed() {
switch(key) {
case'w':
case'W':
yDir=up;
xDir=0;
break;
case'a':
case'A':
xDir=left;
yDir=0;
break;
case's':
case'S':
yDir=down;
xDir=0;
break;
case'd':
case'D':
xDir=right;
yDir=0;
break;
}
}
void keyReleased() {
switch(key) {
case'w':
case'W':
yDir=0;
break;
case'a':
case'A':
xDir=0;
break;
case's':
case'S':
yDir=0;
break;
case'd':
case'D':
xDir=0;
break;
}
}
|