// I See...
// ... said the blind man... no bugs.
// Carly Salindong
// DESMA 28 . Project 3
// 11.22.04
int begin; // Time the event/game begins
boolean active; // Flag for event/game status
boolean done; // Flag for "game over"
PImage beginImage; // Start with this image
PImage endImage; // End with this image
PImage img;
PImage img1;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
float x = 0;
float speed = 2;
float fr;
int imgnumber;
void setup()
{
size(600, 300);
active = false; // Don't begin with action
done = false; // The event/game has not finished
beginImage = loadImage("screen1.jpg");
endImage = loadImage("end.jpg");
img = loadImage("img-event.jpg");
fr = img.width/10/speed;
framerate(fr);
}
void draw()
{
background(204);
if(active == true) {
eventGame(); // Run the event/game
timer(); // Time the event/game
} else {
if(done == true) {
endScreen(); // Show the "end" screen
} else {
beginScreen(); // Show the "first" screen
}
}
}
void eventGame()
// Write your event or game here...
{
if (x >= -img.width + width) {
x -= speed;
}
image(img, x, 0);
noFill();
stroke(0);
line(mouseX-55, mouseY-25, mouseX-55, mouseY-50);
line(mouseX-55, mouseY-50, mouseX-25, mouseY-50);
line(mouseX+55, mouseY-25, mouseX+55, mouseY-50);
line(mouseX+55, mouseY-50, mouseX+25, mouseY-50);
line(mouseX-55, mouseY+25, mouseX-55, mouseY+50);
line(mouseX-55, mouseY+50, mouseX-25, mouseY+50);
line(mouseX+55, mouseY+25, mouseX+55, mouseY+50);
line(mouseX+55, mouseY+50, mouseX+25, mouseY+50);
}
void mousePressed()
{
// Begin the event/game when the mouse is clicked
// and the event/game is not already happening
if(active == false) {
active = true;
begin = millis();
}
else{
if(imgnumber==1){
img1=img.get (mouseX-50-int(x), mouseY-50, 110, 100);
}
if(imgnumber==2){
img2=img.get (mouseX-50-int(x), mouseY-50, 110, 100);
}
if(imgnumber==3){
img3=img.get (mouseX-50-int(x), mouseY-50, 110, 100);
}
if(imgnumber==4){
img4=img.get (mouseX-50-int(x), mouseY-50, 110, 100);
}
if(imgnumber==5){
img5=img.get (mouseX-50-int(x), mouseY-50, 110, 100);
}
imgnumber++;
}
if(mousePressed){
fill(255);
rect(0,0,600,300);
noFill();
}
}
void timer()
{
int curTime = millis();
if(curTime > begin + 10000) {
active = false;
done = true;
}
noStroke();
fill(255);
rect(0, height-5, width, 5);
fill(0);
rect(0, height-5, (curTime-begin)/16.667, 5);
}
// Displays when the game/event begins
void beginScreen() {
image(beginImage, 0, 0);
}
// Displays when the 10 seconds are over
void endScreen() {
image(endImage, 0, 0);
if (img1!=null) image(img1, 5, 50);
if (img2!=null) image(img2, 125, 50);
if (img3!=null) image(img3, 245, 50);
if (img4!=null) image(img4, 365, 50);
if (img5!=null) image(img5, 485, 50);
imgnumber=1;
x=0;
}