Skip to content

Instantly share code, notes, and snippets.

@indefinit
Created November 24, 2015 19:51
Show Gist options
  • Save indefinit/894080ca56bdd86dc291 to your computer and use it in GitHub Desktop.
Save indefinit/894080ca56bdd86dc291 to your computer and use it in GitHub Desktop.
Tall-short-example
//code by:
// https://github.com/Jared-Sprague
var spriteSheet;
var tall = 220;;
var short = 260;
var plantPosX = tall;//our plant position defaults to our tall position
function setup() {
createCanvas(600, 600);
background(200);
spriteSheet = loadImage('image/sprite_sheet.jpg');
}
function draw() {
image(spriteSheet, plantPosX, 20, 40, 110, spriteSheet.width + 60, 200, 40, 100);
}
function mousePressed () {
if(plantPosX === tall){
plantPosX = short;
} else {
plantPosX = tall;
}
print("tall is ", tall);
print("short is ", short);
println("plantPosX is ", plantPosX);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment