interactive video_week 5 2019 interactive art

I made the simple interactive animation inspired by the game 'Crazy Arcade'.
You can move Dao by direction keys
and make Dao get into the waterbomb or escape from the waterbomb by mouse.
Dao moves slower when he is in the waterbomb.



code----------------------

PImage ground;
PImage dao;
PImage waterbomb;
float daoX=0;
float daoY=0;
boolean inwaterbomb = false;
boolean okay = true;

void setup(){
  size(500,500);
  ground=loadImage("Asset 1.png");
  dao=loadImage("Asset 6.png");
  waterbomb=loadImage("Asset 8.png");
}

void draw(){
  image(ground,0,0);
  
  if(okay){
    image(dao,daoX,daoY);
  }
  
  if(inwaterbomb){
    image(waterbomb,daoX,daoY);
  }   
}

//dao move
void keyPressed(){
  if(keyPressed == true){
    if(keyCode == UP){
        if(okay == true){
        daoY = daoY-10;
        } else if(inwaterbomb == true){
        daoY = daoY-3; //dao moves slower in waterbomb
        }
    }else if(keyCode == DOWN){
        if(okay == true){
        daoY = daoY+10;
        } else if(inwaterbomb == true){
        daoY = daoY+3; //dao moves slower in waterbomb
        }
    }else if(keyCode == LEFT){
        if(okay == true){
        daoX = daoX-10;
        } else if(inwaterbomb == true){
        daoX = daoX-3; //dao moves slower in waterbomb
        }
    }else if(keyCode == RIGHT){
        if(okay == true){
        daoX = daoX+10;
        } else if(inwaterbomb == true){
        daoX = daoX+3; //dao moves slower in waterbomb
        }
    }
  }
  if(daoX>400){
    daoX = 400;
  } if(daoY>400){
    daoY = 400;
  } if(daoX<0){
    daoX = 0;
  } if(daoY<0){
    daoY = 0;
  } 
}


//dao's status
void mousePressed(){
  if(inwaterbomb == false){
    inwaterbomb = true;
    okay = false;
  } else {
    inwaterbomb = false;
    okay = true;
  }
}

joyerim.zip

덧글

댓글 입력 영역