topical media & game development
graphic-processing-learning-03-example-3-6-example-3-6.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 3-6: Interactive Zoog?
void setup() {
// Set the size of the window
size(200,200);
smooth();
// The frame rate is set to 30 frames per second.
frameRate(30);
}
void draw() {
// Draw a black background
background(255);
// Set ellipses and rects to CENTER mode
ellipseMode(CENTER);
rectMode(CENTER);
// Draw Zoog's body
stroke(0);
fill(175);
rect(mouseX,mouseY,20,100);
// Draw Zoog's head
stroke(0);
fill(255);
ellipse(mouseX,mouseY-30,60,60);
// Draw Zoog's eyes
// The eye color is determined by the mouse location.
fill(mouseX,0,mouseY);
ellipse(mouseX-19,mouseY-30,16,32);
ellipse(mouseX+19,mouseY-30,16,32);
// Draw Zoog's legs
stroke(0);
// The legs are drawn according to the mouse location and the previous mouse location.
line(mouseX-10,mouseY+50,pmouseX-10,pmouseY+60);
line(mouseX+10,mouseY+50,pmouseX+10,pmouseY+60);
}
void mousePressed() {
println("Take me to your leader!");
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.