2010年7月14日水曜日

minigame



//十字キーで操作。ぐるぐるにタッチでゴール。星をとったら大きくなるよ。
//敵を避けてゴールをねらって!
PFont font;

PImage img,img2,img3,img4,img5;
int x;
int y;
int direction;
float speedx =3.2;
float speedy =4.6;
int s=30;
int s2=30;
float x2=100.0;
float y2=100.0;
int x3=180;
int y3=80;
float m,n;
float xoff=0.0;
float yoff=0.0;
float xincrement = 0.02;
float yincrement = 0.01;
void setup(){
size(300,300);
font =loadFont("AharoniBold-48.vlw");
img=loadImage("sakana.png");
img2=loadImage("hoshi.png");
img3=loadImage("tako.png");
img4=loadImage("ika.png");
img5=loadImage("goal.png");
imageMode(CENTER);
rectMode(CENTER);
}

void draw(){
background(173,214,255);

textFont(font);
fill(0);

if(key==CODED){
if(keyCode==LEFT){
x--;

}
if(keyCode==RIGHT){
x++;
}
if(keyCode==UP){
y--;
}
if(keyCode==DOWN){
y++;
}
}
if((x>x2-30)&&(xy2-30)&&(y s--;
if(s==10){
background(0);
fill(255);
text("game over",0,40);
noLoop();
}
}
if((x>width-35)&&(xheight-35)&&(y background(255,0,0);
fill(255);
text("clear",0,40);
noLoop();
}
if((x>x3-s/2)&&(xy3-s/2)&&(y s=40;
s2=0;
}
if((x>m-30)&&(xn-30)&&(y s--;
if(s==10){
background(0);
fill(255);
text("game over",0,40);
noLoop();
}
}
x2+=speedx;
y2+=speedy;
if((x2>width)||(x2<0)){
speedx=-speedx;
}
if((y2>height)||(y2<0)){
speedy=-speedy;
}

m = noise(xoff)*width;
n = noise(yoff)*height;
xoff+= xincrement;
yoff+= yincrement;


image(img2,x3,y3,s2,s2);
image(img3,x2,y2);
image(img4,m,n);
image(img5,width-20,height-20);
image(img,x,y,s,s);
}