//import processing.opengl.*; void setup() { size(600, 600); PFont metaBold = loadFont("ArialMT-48.vlw"); textFont(metaBold, 22); } int speed = 4; int delta = 1; int deltaY = 0; int speedY = 2; int position = 0; int positionY = 0; int changes = 1; int lastChanges = 1; int lives = 10; int barPosition = 100; void draw() { if (lives <= 0) return; background(0); ellipse(position, positionY, 50, 50); if ( (position >= 500 - 25) && (position <= 500 - 5 ) && (positionY >= mouseY - 25) && (positionY <= mouseY + 25) ) { delta *= -1; changes++; } if ((changes > lastChanges) && ((changes % 5) == 0)) { speed += 2; lastChanges = changes; } position += (delta * speed); // position = position + delta; positionY += (deltaY * speedY); if (position >= width) { delta = -1; lives--; // speed = speed + 2; } else if (position <= 0) { delta = 1; // speed = speed + 2; } if (positionY >= height) { deltaY = -1; } else if (positionY <= 0) { deltaY = 1; } fill(0, 100, 255); rect(500, mouseY - 25, 10, 50); fill(255, 255, 0); text("" + lives + " lives left", 10, 40); text("current speed " + speed, 10, 70); text("current score " + changes, 10, 100); if (lives <= 0) { text("You are dead. Good luck next time.", 20, 300); } fill(255, 0, 0); noStroke(); //directionalLight(255, 0, 0, 5, 0, 0); //lights(); // translate(position, positionY, 0); // sphere(28); }