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.

224 <strong>Learning</strong> <strong>Processing</strong><br />

Exercise 13-10: Develop the beginnings of a Tic-Tac-Toe game. Create a Cell object that<br />

can exist in one of two states: O or nothing. When you click on the cell, its state changes from<br />

nothing <strong>to</strong> “ O ” . Here is a framework <strong>to</strong> get you started.<br />

Cell[][] board;<br />

int cols = 3;<br />

int rows = 3;<br />

void setup() {<br />

}<br />

// FILL IN<br />

void draw() {<br />

}<br />

background(0);<br />

for (int i = 0; i < cols; i + + ) {<br />

}<br />

for (int j = 0; j < rows; j + + ) {<br />

}<br />

board[i][j].display();<br />

void mousePressed() {<br />

}<br />

// FILL IN<br />

// A Cell object<br />

class Cell {<br />

float x,y;<br />

float w,h;<br />

int state;<br />

// Cell Construc<strong>to</strong>r<br />

Cell(float tempX, float tempY, float tempW, float tempH) {<br />

}<br />

// FILL IN<br />

void click(int mx, int my) {<br />

}<br />

// FILL IN

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

Saved successfully!

Ooh no, something went wrong!