Week5 Interactive Video


For this week's assignment, i chose to work with my favorite comic when I was young "Calvin and Hobbes". 



Here are the codes I used:

float cx=0;
float cy=270;
float snow=5;
PImage calvin1;
PImage background;
PImage calvin;
float angle = 0;

void setup()
{
  size(650, 400);
  calvin = loadImage("calvin and hobbes.png");
  background = loadImage("snowyfield.jpg");
 }

void draw()
{
  background(255);
  image(background, 0, 0);
  image(calvin, cx+10, cy, 120, 90);
  
//moving Calvin and Hobbes

  if (keyPressed== true){
   if (keyCode==UP){
     cy-=2;
   }else if (keyCode==DOWN){
     cy+=2;
   }
   if (keyCode==LEFT){
     cx-=2;
   }else if (keyCode==RIGHT){
     cx+=2;
   }
  }
  
//Calvin and Hobbes movement limit

if (cx <= 0){
  cx = 0;
 }
if (cx >=500){
  cx = 500;
 }
if (cy <= 220){
  cy = 220;
 }
if (cy >= 300){
  cy = 300;
 }
  
//Quote in the middle

if (keyPressed){
  textSize(15);
  fill(#5D5D5D);
  text("We're so busy watching out for", 195+15, 100);
  text("what's just ahead of us that we", 195+15, 120);
  text("don't take time to enjoy where we are", 170+15, 140);
 }
}

덧글

댓글 입력 영역