# Processing, Pong, and Kinetic Theory

I’ve been playing around with using Processing as a way to quickly get my Calculus students doing some programming. One of my experiments was in using what I’ve learned over the past couple months about object oriented programming to make the game have multiple balls in play at once.

Once I saw how well this worked, it turned rapidly into an attempt to max out my processor. The balls have random initial locations, and ‘speeds’ distributed uniformly between -2 and 2 pixels/frame.

The pong program keeps track of the bounces off of the left and right walls, and uses this as a basic way to calculate a score. When I saw this, it looked just like a kinetic theory simulation for ideal gases, though the particles are only bouncing off of the walls, not each other. That bounce variable keeps track of the collisions with the walls – can anything cool that can be calculated just from the picture alone and the number of collisions?

Processing sketch can be found here.

## 2 thoughts on “Processing, Pong, and Kinetic Theory”

1. Evan,
Processing is awesome. I’ve only played with it a bit, but I’m really impressed with how easily it lets you create stuff like this. Where were languages like python and processing when I was growing up?

This might be a fun way for kids to “discover” KMTâ€”once you find the total impulse on the wall over a certain time, you could find average force and pressure easily.

1. Wow – the discovery idea for that would be crazy cool. I wouldn’t have known how to attempt that before learning some OOP, but I think I can see how that might be put together without too much struggle.

I remember my dad bringing home a copy of Borland Turbo C++ compiler for us to experiment with. I think I tried writing a one-line program and ran into a syntax error, and couldn’t figure out what I was doing wrong, so I stopped. I had a bit more success with Visual Basic/VBA, but got annoyed with it being tied to windows & office programs.

The entry cost of getting started with programming is so low now with languages like Python and Processing that it’s easy to get excited about getting them into the hands of students. The trick is in making sure their first programming experience is smooth enough and interesting enough that they want to come back.