// Project 3 Template
// The individuals presented in Turkle's text all used games as a way to
// escape and/or alter their self-perception. Develop an event/game which
// lasts 10 seconds and explores your personal fantasy for escape.
// Begin with a screen explaining the event/game. Click the screen to begin.
// At the end of 10 seconds, display a status screen and give the player the
// option to re-experience the event/game again.
// I've provided this template to use as a starting point, but you are
// free to write your own template following the sequence stated above.
// Be prepared to show sketches of at least five strong concepts in class
// on Wednesday.
// Due 22 November 2004
int begin; // Time the event/game begins
boolean active; // Flag for event/game status
boolean done; // Flag for "game over"
// Default images to begin and end the event/game.
// Make your own images to fit your concept.
PImage beginImage; // Start with this image
PImage endImage; // End with this image
void setup()
{
size(600, 300);
active = false; // Don't begin with action
done = false; // The event/game has not finished
beginImage = loadImage("begin.gif");
endImage = loadImage("end.gif");
}
// Control the series of events.
// You shouldn't need to modify anything in draw().
// Make all changes in eventGame() and mouse functions.
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...
ellipse(mouseX, mouseY, 100, 100);
}
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 {
// Write your mouse events here...
}
}
void mouseReleased()
{
// Write your mouse events here...
}
void mouseDragged()
{
// Write your mouse events here...
}
void mouseMoved()
{
// Write your mouse events here...
}
void keyPressed()
{
// Write your key events here...
}
void keyReleased()
{
// Write your key events here...
}
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);
}