Computation and Visualization in the Earth Sciences

Small Project 1


My suggestion is to create a cool animation, game, or drawing. Here's a video of my feeble example of a game. It would be better if it were relevant to Earth science concepts in some way.

Watch this video (1:25).

Bouncing Ball Game.
Click to expand to provide a transcript.

Up here I declare a bunch of variables. Then inside setup I make the size of the window and I load a couple fonts and inside draw, I draw the ball and this is how it moves. This chunk here takes care of what to do if the ball hits either one of the sides. It turns around and the stroke color becomes something else. If the ball hits the top, it turns around and the fill color becomes something else and you get a point. And then the points that you have so far are printed down here. If the ball hits the bottom, the game's over. These various things happen like it totals up the points you have. It draws a kind of flattened squashed ball the bottom and no loop tells the program to stop running because we're done. If you press the mouse inside the ball then it speeds up and the ball goes up. So, I'm not good this game or really any video game, but this is what it looks like when it's running. See at the bottom that it's totaling up my points and the ball is changing color just for fun. If I miss the ball, which will happen soon, that it says splat! Tells me that I got 10 points, and we're all done.

E. Richardson.

When it's running, you have to click inside the circle to make the circle go up. It will bounce off the sides and the top. Each time it bounces off the top border, it goes a little faster. If it hits the bottom, the game is over. A better version of this game would involve some kind of screen with directions at the beginning and a button to make it start, and a restart button. Maybe one of you can beef this up or create something a lot better.

Processing code for my example of a game:

// Bouncing ball game.
// Don't let the ball hit the bottom.
// Click inside the ball to make it go up.

color bg = color(220, 220, 200);
float ballsize = 40.0;
float speed = 1.0;
float y = random(ballsize, (height - ballsize));
float x = random(ballsize, (width - ballsize));
float ball_xdirection = 1;
float ball_ydirection = 1;
int points = 0;
PFont font1;
PFont font2;

void setup() P
   size(200, 200);
   font1 = loadFont("BradleyHandITCTT-Bold-48.vlw");
   font2 = loadFont("Garamond-14.vlw");

void draw() {
   ellipse(x, y, ballsize, ballsize);
   x = x + ((.5 * speed) * ball_xdirection);
   y = y + (speed * ball_ydirection);

   if (x > width - (ballsize/2) || x < ballsize/2)) {
      ball_xdirection *= -1;
      int r = int(random(255));
      int g = int(random(255));
      int b = int(random(255));
      stroke(r, g, b);
   if (y < (ballsize/2)) {
      ball_ydirection *= -1;
      int r = int(random(255));
      int g = int(random(255));
      int b = int(random(255));
      fill(r, g, b);
   println("Good work! " + points + " points for you");

   if (y > height - (ballsize/2)) {
      println("GAME OVER");

      text("SPLAT!", width/2, height/2);

      text("Points: " + points, width - 20, 20);
      ellipse(x, y, ballsize, ballsize);
      ellipse(x, y + ballsize/2, ballsize*2, ballsize/2);
   if (mousePressed == true && mouseX <= x + ballsize/2 && mouseX >= x - ballsize/2 && mouseY <= y + ballsize/2 && mouseY >= ballsize) {
      speed = speed + 0.05;
      ball_ydirection = -1;


A still shot from the end of the game:

Image of processing code from above with a window with the word SPLAT written in it.
Screenshot of the example game code with the Splat window.
E. Richardson

Turning in your work

Submit your program to the "small project 1" dropbox. Remember that if your program requires extra files such as fonts or external files then zip the whole thing and submit the zipped file to the dropbox.