topical media & game development
graphic-processing-learning-17-example-17-6-Letter.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 17-6: Text breaking up
// A class to describe a single Letter
class Letter {
char letter;
// The object knows its original " home " location
float homex,homey;
// As well as its current location
float x,y;
Letter(float x_, float y_, char letter_) {
homex = x = x_;
homey = y = y_;
letter = letter_;
}
// Display the letter
void display() {
fill(0);
textAlign(LEFT);
text(letter,x,y);
}
// Move the letter randomly
void shake() {
x += random(-2,2);
y += random(-2,2);
}
// At any point, the current location can be set back to the home location by calling the home() function.
void home() {
x = homex;
y = homey;
}
}
(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.