期中/期末作業主題
Flappy Bird
PImage bg;
PImage bg2;
PImage icon;
PImage start;
PImage score;
PImage[] img_bird;
int index;
void setup()
{
size(500,650);
bg = loadImage("bg.jpg");
bg2 = loadImage("bg3.png");
icon = loadImage("flappybird.png");
start = loadImage("start.png");
score = loadImage("score.png");
img_bird = new PImage[4];
for(int i=0; i<img_bird.length; i++)
{
String str = "bird" + i + ".png";
img_bird[i] = loadImage(str);
}
index = 0;
}
int stage = 0;
int x = 0;
int y1 = 0;
void draw()
{
if(stage == 0)
{
if(x > -1000)
{
x = x - 2;
}
else
{
x = 0;
}
image(bg, 0, 0, 700, 700);
image(bg2, x, -970);
image(icon, -130, -100, 700, 500);
image(start, -200, 250, 700, 500);
image(score, 0, 245, 700, 500);
if(frameCount%4 == 0)index ++;
if(index>img_bird.length-1)index = 0;
image(img_bird[index], 35, -110, 700, 500);
}
}

沒有留言:
張貼留言