- Here’s a possible skeleton for your program:
void setup() {
size(500, 500);
}
void draw() {
// Insert code to draw a new random line each frame.
}
- Here’s a possible skeleton for your program:
// Number of targets you need to hit
int GOAL = 10;
// Location of current circle
int circleX, circleY;
// Number of circles hit
int hits;
// Starting time
int startTime;
void setup() {
size(500, 500);
circleX = random(width);
circleY = random(height);
hits = 0;
startTime = millis();
}
void draw() {
background(255);
// Draw target circle
ellipse( ... );
}
void mouseClicked() {
// Check if circle was clicked
if ( circle clicked ... ) {
// Check if game is over
if ( ... ) {
// Calculate and print final score
} else {
// Update hit count
hits = ...;
// Set new circle location
circleX = ...;
circleY = ...;
}
}
}
- Here’s a possible skeleton for your program:
int ROWS = 8;
int COLS = 8;
void setup() {
size(500, 500);
// Determine the width and height of each square
// ...
for ( ... ) {
// Draw each row
for ( ... ) {
// Draw each column in given row.
// Need to determine whether the square is black or white ...
fill( ... ); // Set color
rect( ... ); // Draw a square at the correct location
}
}
}
void draw() {
// Nothing is needed here if you do all the work in setup().
// You could instead do all the drawing here.
}
void mouseClicked() {
// Draw a circle in the square where you click.
// To work with this skeleton, you'll need to draw the checkerboard
// in setup() rather than draw(), since if you draw the checkerboard
// in draw() it will overwrite any circles you draw here.
}