Need some help about key press function
in
Programming Questions
•
1 year ago
- circle c = new circle(100,75,5,5,30);
- void setup() {size(400, 400);
- frameRate(30);
- smooth();
- }
- void draw(){ background(204);
- c.mover();
- c.display();
- fill(35,40,232);
- rect(115,90,195,220); }
- class circle {
- float x,xs,y,ys,r,x1,y1;
- circle (float xpos, float ypos,float xspeed,float yspeed,float radi) {
- x=xpos;
- y=ypos;
- xs=xspeed;
- ys=yspeed;
- r=radi;
- }
- void mover() {if(key == 'a'){
- x+=xs;
- if(x == 325)
- {xs=0; ys=5; y+=ys;}
- if(y == 325)
- {ys=0; xs=-5;}
- if(x == 100)
- {xs = 0; ys = -5; y+=ys;}
- if(y == 75)
- {ys=0; xs=5;}}}
- void display(){
- fill(250,0,205);
- ellipse(x,y,r,r);
- }
- }
1