2022年1月17日 星期一

WEEK11

 還是做期末作業

這次加上圖片

PImage img,monster,hero,pic1,button;

int N=0;

int condition;

float heroX = 100,heroY = 400;

float monsterX = 150,monsterY = 10;

float []arrowX = new float[100];

float []arrowY = new float[100];

float []arrowVX = new float[100];

float []arrowVY = new float[100];

boolean []arrowFlying = new boolean[100];

boolean gamestart = false;

boolean gameover = false;


void setup(){

  size(300,500);

  

  img = loadImage("background.jpg");

  monster = loadImage("mon.jpg");

  hero = loadImage("bow.jpg");

  pic1 = loadImage("pic1.jpg");

  button = loadImage("button.jpg");

  

  

}



void draw(){

  background(255);

  image(img,0,0);

  image(monster,80,10);

  image(hero,heroX,heroY);

  

  if(keyPressed ){

    if(keyCode == LEFT){

      heroX -= 5;

    }

    if(keyCode == RIGHT){

      heroX += 5;

    }

  }

  

 for(int i=0;i<N;i++){

      arrowY[i] += arrowVY[i];

      ellipse(arrowX[i],arrowY[i],10,10);

  }

}


void mouseClicked(){

  N++;

  arrowX[N-1] = heroX;

  arrowY[N-1] = heroY;

  arrowVX[N-1] = 0;

  arrowVY[N-1] = -3;

}

void mousePressed(){

  gamestart = true;

  if(condition==0){

    image(pic1,0,150);

    image(button,100,200);

  }

  if(mouseButton == LEFT&&dist(300,360,mouseX,mouseY)<60){

    condition = 1;

  }

}

背景




主角



怪物








沒有留言:

張貼留言