Program 1: Ball Pit


Statement

Ball Pit is a fun, playful program. I can sit and play with simple games such as this for a little too long. I find it incredibly unwinding to click my mouse repeatedly, especially when I know there is no limit to the amount of times I can click it and have something happen. I become relaxed as I watch the balls bounce up and down the screen and I enjoy the anticipation of what the next ball will look like and how it will add to the colourful array of what’s onscreen already.

Ironically, the experience of creating program was quite the opposite. I find programming to be something that requires my full concentration. It’s not something I feel relaxed while doing by any means.

I like that the product of this hard work is something that almost counteracts the stress created by programming it. It’s a virtuous cycle!


Creative Process

This sketch was inspired by the Gravity Ball Objects exercise in the Learning Processing textbook.

I started out with something quite similar to that sketch – a Ball class that was called in the draw() to animate. I then created an array out of Ball objects, called Balls. I added the mousePressed() function, so that when a user clicks it adds a new instance of Ball to the array. This is drawn at the current mouse location – with a random colour and alpha within the specified boundaries. The append function is used to add a new element to the end of the array. This was the most difficult part of the process for me, as it wasn’t something I recalled learning in class. After research, I was able to learn about this function and how it is used.

In the draw, the Balls are updated and displayed as per the functions within the class. The display function specifies that the ball will be a random colour, with no stroke, at xPos, yPos with d as the diameter. Update is where the animation occurs – it includes some “gravity” calculation code, which Learning Processing Exercise 8-5 helped with. It also includes an ‘if statement’ which reverses the speed once the ball reaches the bottom of the screen.

I chose to make the background black, so as to not distract from the balls which are the most important thing in the sketch. I experimented with a textured image background, however it made the sketch far too slow. I see program efficiency is a very important part of the program, so I chose to scrap the background and keep it simple. I also experimented with various random colour parameters. I liked this mix of these colours the most.

Another feature of the program is the ability to save the frame when s or S is pressed. This is something that we learnt how to do in class, and I thought it was a worthy feature to include, as some of the patterns made by the balls are quite beautiful.

ballpit1
ballpit1
ballpit1

Reflection

All up, Ball Pit was an enjoyable program to make. If I could keep working on it, I’d love to alter it so that balls could be released at different angles, based on the user clicking and dragging. In making this program I feel I have displayed a good overview of the techniques I have learnt in Processing this semester.


Back

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Source code: As3_1 Ball

Built with Processing