Skip to content

Instantly share code, notes, and snippets.

@sabotai
Created September 8, 2016 20:40
Show Gist options
  • Select an option

  • Save sabotai/0550a4c023418b1eacacdd9010f50c40 to your computer and use it in GitHub Desktop.

Select an option

Save sabotai/0550a4c023418b1eacacdd9010f50c40 to your computer and use it in GitHub Desktop.
GD105 Fall 2016 Week 3
PImage beyonce;
PImage bg;
int bW, bH;
int bX, bY;
void setup(){
size(1280,720);
//load each of the images from the data folder
//make sure the filenames are exact, otherwise they wont load
beyonce = loadImage("beyonce.png");
bg = loadImage("godzilla.jpg");
//assign the initial values for beyonce's x, y, width and height
bX = 0;
bY = height;
bW = beyonce.width /5;
bH = beyonce.height /5;
}
void draw(){
//we need to set the imageMode to corner at the beginning
//of each frame for easily setting the background
imageMode(CORNER);
image(bg, 0,0, width, height);
//draw beyonce from the center
imageMode(CENTER);
//each frame, increase these values
bX += 1;
bY *= 1.0055;
bW *= 1.012;
bH *= 1.01;
//i set a temporary variable to use for the y position
float tempBY = height + (sin(second()) * 10);
image(beyonce, bX, tempBY, bW, bH);
println("the y value is... " + tempBY);
//image(beyonce, bX, bY, bW, bH);
//set the text size to be drawn
textSize(bX);
//display the string "ygg" at this position
text("ygg", 0, height/2);
}
//this function runs every time the mouse is pressed
void mousePressed(){
//i just took all the original assignments from the setup and copy-pasted them
bX = 0;
bY = height;
bW = beyonce.width /5;
bH = beyonce.height /5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment