Pinball with Processing
This Processing sketch was done by me (Dan Runningen) in conjunction with Sarah Boelter as the first major project in CSCI 5611 - Animation and Planning in Games. This class is offered by the University of Minnesota as an elective graduate-level course designed to teach students the fundamentals of simulated realistic motion. This project in particular was designed to introduce basic collision detection and energy transfer.
Project Features
There was some freedom given for which features needed to be implemented. Below is a breakdown of the specific items we chose to include for this project and some timestamps to view some specific features.
-
[Whole Video] Basic Pinball Dynamics (30pts) - Ball reacts to gravity, reacts with objects naturally.
-
[0:40] Multiple Balls Interacting (20pts) - Balls bounce off each other by reflecting their velocities along the line of collision. The main code for this is in the
Ball.pde
file which contains a class to deal with the pinball objects. There are plenty of opportunities in the video to see this, but the example at the 0:40 timestamp shows a couple interactions by the Jack-o-lantern in the bottom left of the screen. -
[Whole Video] Circular Obstacles (10pts) - Several circular obstacles are placed in the board, each of which balls bounce off of, again reflecting the ball's velocity along the line of collision.
-
[0:12] Line Segment Obstacles (10pts) - Line segment obstacles have also been placed throughout the boards, including along the outer border of the frame to keep all balls inside the game. The only exception is when balls fall through the bottom of the board where they are deleted to help keep track of when the game should end. These can be seen thought the video (since they are reactive and tend to flash) but an example can be seen at the 0:12 timestamp where several balls fall on the center arrow shape.
-
[Whole Video] Textured Background (5pts) - Background is pictures featuring Sarah's cats.
-
[Whole Video] Textured Obstacles (5pts) - Circles in each simulation are textured with clip-art images retrieved from clipart-library.com.
-
[2:08] Reactive Obstacles (5pts) - Obstacles will change their outline color randomly when hit.
-
[2:25] Particle System (10 pts) - Square on right side of screen will produce a pre-determined amount of extra pinballs if rolled over. This allows the player to continuously produce more pinballs if any are lost below the flippers.
- [Whole Video] Score Display (5pts) - Score display is on obstacle on the bottom right corner. Score increments points based on number on obstacle that pinball hits.
- [1:35] Loading Scenes from file (10pts) - Scenes are loaded from a file, can toggle between them on welcome screen. Themes include:
- Christmas theme with Sarah's cat eyeing an ornament to knock down with textured ornament obstacles imposed over the actual tree ornaments.
- Spooky theme with spooky black cat background and different spooky obstacles with spooky colors.
- [2:07] Two working flippers - Flippers move up and down and provide necessary angular velocity to move the ball across the machine.
Code Pack
For grading purposes, a zip file has been made available to review source code.
Tools and Libraries Used
- Background pictures of Sarah's cats were sourced locally and organically.
- Pictures of ornaments and spooky items were sourced from clipart-library.com.
- Very basic functionalities for arrays from
java.utils
. - The
Vec2.pde
file is code wholely unchanged from Professor Guy's examples and many of the code pieces were taken from class pseudo-code.
Closing Remarks
We had some difficulties initially with what platform we were using. Originally, we had considered using TypeScript but there were several issues getting everything sorted and getting simulation to render properly. Eventually we decided to switch to Processing due to the amount of examples available from class. After that it became relatively straightforward implementing different aspects of the project to meet project milestones.
Future improvements for this project would include adding more objects, such as flipper and particle emitter placement, into the files that are read-in. Additionally we would have liked to add a more dynamic animation to some of the obstacles when they were hit, and to simulate them "pushing" against the balls when struck.
Art Submission
As part of the assignment, students were also encouraged to submit images for an "art contest" for some possible points. We have selected our Christmas layout for this submission.
- Java
- Processing
- Simulated Physics