import processing.core.*; import processing.xml.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import java.util.regex.*; public class pointerExplode extends PApplet { PImage p2; PImage click; PFont font; boolean go = true; int total = 6; PImage blackcursor; PImage greycursor; PImage[] explodeimages = new PImage[total]; PImage[] poof = new PImage[total]; int timer = 0; float interval = 50; boolean bomb = false; int counter = 0; int counter2 = 10; int frame = 0; public void setup(){ size(120, 120); for ( int i = 0; i< total; i++ ) { poof[i] = loadImage( "Layer-" + i + ".png" ); // make sure images "0.jpg" to "11.jpg" exist explodeimages[i] = loadImage( "exp" + i + ".png" ); // make sure images "0.jpg" to "11.jpg" exist } blackcursor = loadImage("blackcursor.png"); greycursor = loadImage("greycursor.png"); font = loadFont("MyriadPro-Regular-12.vlw"); } public void draw(){ background(255); stroke(100); //rect(10,10, 100, 100); imageMode(CENTER); textAlign(CENTER); float distance = dist(mouseX, mouseY, 55, 54); if (distance > 10){ bomb = false; } if (bomb == false){ frame = 0; image(greycursor, width/2, height/2); textFont(font, 12); fill(1); if (distance <= 2){ image(blackcursor, width/2, height/2); noCursor(); counter ++; if (counter2 == 0){ bomb = true; } text(counter2, width/2, 97); if (counter == 50){ counter2 --; counter = 0; } } else{ cursor(); image(greycursor, width/2, height/2); text("place pointer here", width/2, 97); counter2 = 10; bomb = false; } } if (bomb == true){ if (timer + interval < millis()){ timer = millis(); frame++; // Use % to cycle through frames } if (frame < total){ image(poof[frame], width/2, height/2); image(explodeimages[frame], width/2, height/2); } } } static public void main(String args[]) { PApplet.main(new String[] { "--present", "--bgcolor=#666666", "--stop-color=#cccccc", "pointerExplode" }); } }