06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

258 <strong>Learning</strong> <strong>Processing</strong><br />

// Adjust variables <strong>to</strong> create animation<br />

x + = 1.0;<br />

rot + = 0.01;<br />

if (x > width) {<br />

x = 0;<br />

}<br />

}<br />

Exercise 15-2: Rewrite this example in an object-oriented fashion where the data for the<br />

image, location, size, rotation, and so on is contained in a class. Can you have the class swap<br />

images when it hits the edge of the screen?<br />

class Head {<br />

}<br />

________ // A variable for the image file<br />

________ // Variables for image location<br />

________ // A variable for image rotation<br />

Head(String filename, ________, ________) {<br />

}<br />

// Load image, initialize variables<br />

________ = loadImage(________);<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

void display() {<br />

}<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

void move() {<br />

}<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

__________________________________<br />

String is also a class<br />

we get for free and<br />

will be explored<br />

further in Chapter 17.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!