
void setup(){ size (500,500); } void draw(){ ellipse(250,250,480,480); for(float angle=0; angle<PI*2; angle+=PI/3){ for(int r=0;r<=240;r+=20){ noFill(); triangle(250,250,250+r*cos(angle),250+r*sin(angle), 250+r*cos(angle+PI/3),250+r*sin(angle+PI/3)); } } }
void setup(){
size (800,400);
}
void mtriangle(int cx, int cy){
float a=-PI/2;
for(int r=15;r>0;r-=5){
triangle(cx+r*cos(a),cy+r*sin(a),
cx+r*cos(a+2*PI/3),cy+r*sin(a+2*PI/3),
cx+r*cos(a-2*PI/3),cy+r*sin(a-2*PI/3));
}
}
void draw(){
background(255);
for(int cx=20;cx<800;cx+=40){
for(int cy=20;cy<400;cy+=40){
mtriangle(cx,cy);
}
}
}
PImage imgmario;
float marioX=0,marioY=0,marioVX=0.5,marioVY=0,marioAX=0,marioAY=0.1;
void setup(){
size (400,600);
imgmario=loadImage("mario.png");
}
void draw(){
background(255);
image (imgmario,marioX,marioY,100,150);
marioX+=marioVX;
marioVX+=marioAX;
marioY+=marioVY;
marioVY+=marioAY;
}
void keyPressed(){
if(keyCode==UP){marioY-=5;}
if(keyCode==DOWN){marioY+=5;}
if(keyCode==LEFT){marioX-=5;}
if(keyCode==RIGHT){marioX+=5;}
}
PImage imgmario; float marioX=0,marioY=0,marioVX=0.5,marioVY=0,marioAX=0,marioAY=0.1; void setup(){ size (400,600); imgmario=loadImage("mario.png"); } void draw(){ background(255); image (imgmario,marioX,marioY,100,150); marioX+=marioVX; marioVX+=marioAX; marioY+=marioVY; marioVY+=marioAY; if(marioY>600-150)marioVY*=-0.9; if(marioX>400-100)marioVX*=-1; if(marioY<0)marioVY*=-0.9; if(marioY<0)marioVX*=-1; if(marioX<300)marioVX=-marioVX; if(marioX>0)marioVX=-marioVX; } void keyPressed(){ if(keyCode==UP){marioY-=5;} if(keyCode==DOWN){marioY+=5;} if(keyCode==LEFT){marioX-=5;} if(keyCode==RIGHT){marioX+=5;} }
沒有留言:
張貼留言