Create a functional digital prototype of a board game concept. Departing from the graphic-focused code of the previous two objectives, this objective will focus on text display and variables, in order to test and tweak possible mechanics of an upcoming board game.
Archive for the 'processing' Category
Working with the code used in objective001, add a second object to the space. Program the ball to detect collisions with that object, and react accordingly.
Update: Objective complete.
Notes:
-
The image above does not reflect the final version of the sketch.
Though not stipulated by the original objective, the second object (or “paddle”) is interactive, and can be controlled with the mouse cursor.
Once the applet loads, click it to allow the mouse to interact.
Because of the speed at which the cursor moves the paddle, it was possible for the ball to accidentally pass through the paddle while the paddle was in motion, rather than colliding and bouncing off. To circumvent this issue, I instructed the ball to only interact with the paddle while the paddle was black. Moving the paddle now causes it to turn white, and once the paddle has stopped moving it must “cool down” in order to interact with the ball again. A practical solution, but one that has interesting design potential.
Additionally, the paddle had to be instructed to remain white while the ball was passing through it, to prevent a bug where the ball would bounce in the interior of the paddle.
The background colors are controlled by the position of the paddle, using the same RGB-calculation code written for objective001. This was done to add a little color to the sketch, which was otherwise a bit boring to look at and play with.
Create a space, and a circular object (“ball). Program the ball to move within the space, rebounding off its boundaries when necessary.
Update: Objective complete.
Notes:
-
The x and y positions of the ball determine its RGB values: The x position determines the red value, the y position the green value, and the sum of x and y determines the blue value. Scaling was used to keep values in the range of 0 – 255, and values had to be converted from floating point to integer data types.
The pattern created by the ball’s movement is achieved by never redrawing the background during each frame of animation. Had the background color been declared during the draw() function, each frame would have wiped the background clean, showing only the ball’s current position — practical, but less interesting to look at.

