xxxxxxxxxx
83
/*
Meme project with If
by Gal Ben Baruch
*/
var img1;
var img2;
var img3;
var img4;
var x = 100;
var y = 400;
var st1 = "Me, at max level, strolling around in a low lvl zone:";
var st2 = "An aggressive enemy, when I walk too close to it:";
var st3 = "Me, when the enemy starts running away when it is about to die:";
var img;
var counter = 0;
var sc = 0.5; //scale
var f = 0; //framecounter for scale animation
function mousePressed() {
sc = 0.5;
f = 0;
counter += 1;
if (counter > 2) {
counter = 0;
}
}
function preload() {
img1 = loadImage("max lvl.jpg");
img2 = loadImage("triggered.jpg");
img3 = loadImage("why meme.png");
img4 = loadImage("why head.png");
}
function setup() {
createCanvas(400, 500);
}
function draw() {
background(220);
textSize(24);
stroke("black");
if (counter == 0) {
text(st1, 10, 10, y);
img = img1;
image(img, 0, x, y, height - x);
} else if (counter == 1) {
text(st2, 10, 10, 400);
img = img2;
image(img, 0, x, y, height - x);
x += random(-1, 1);
y += random(-1, 1);
} else if (counter == 2) {
text(st3, 10, 10, y);
img = img1;
push();
translate(208, 162);
scale(sc);
image(img, -208, x - 127, y, height - x);
if (sc > 3) {
f++;
image(img4, -104, -43, 190, 190);
if (f > 60 * 5) {
sc = 0.5;
f = 0;
}
}
if (sc < 3) {
sc += 0.05;
}
pop();
text(st3, 10, 10, y);
} else {
text(st1, 10, 10, y);
img = img1;
image(img, 0, x, y, height - x);
}
}