Interactive Video | Week 5 assignment


When you click, it can get honey 🐝🍯




Code :


PImage flowers;
PImage bee1;
PImage bee2;
int beeX = 300;
int beeY = 300;
PFont font1;


void setup (){
  
  size(600,600);
  flowers = loadImage("flowers.png");
  bee1 = loadImage("bee1.png");
  bee2 = loadImage("bee2.png");
  font1 = loadFont("kindergarten-48.vlw");
  
}


void draw (){
  
  image(flowers, 0, 0);
  image(bee1, beeX ,beeY);
  
  if (keyPressed) {
    if (keyCode==LEFT) {beeX -= 2; }
    if (keyCode==RIGHT) {beeX += 2; }
    if (keyCode==UP) {beeY -= 2; }
    if (keyCode==DOWN) {beeY += 2; }
      
    if (beeX <= 0 ) { beeX = 0; }
    if (beeX >= 500 ) { beeX = 500; }    
    if (beeY <= 0 ) { beeY = 0; }
    if (beeY >= 520 ) {beeY = 520; }
  }
  
  if (mousePressed) {
    image(bee2, beeX, beeY);
    
    textFont(font1);
    textSize(30);
    fill(random(0,255),random(0,255),0);
    text("YUMMY !", beeX+10, beeY-20);
    
  }
    
}

덧글

댓글 입력 영역