Welcome to the Chocolate Box Simulation in Processing! 🍫 This interactive sketch lets you play with virtual chocolates by changing their flavors, shapes, and visibility.
-
If you're a TA👨🏫 then checking my code from this link will be much more comfortable for you!
-
I didn't explain the mathematical functions in depth! But i commented out what those functions are computing!
-
Because explaining mathematical concepts in depth is not my responsibility here as I am not a math teacher!
The code is organized into two main classes: ChocoBox
and ChocoCell
. Here's a breakdown of the structure:
The ChocoBox
class represents the chocolate box and is responsible for creating the grid of chocolate cells. It includes:
box
: An array ofChocoCell
objects representing the individual chocolate cells.rows
: Number of rows in the grid.cols
: Number of columns in the grid.cellSize
: Size of each cell.flavors
: An array of colors representing chocolate flavors.shapes
: An array of strings representing chocolate shapes.
The ChocoCell
class represents an individual chocolate cell and manages its properties and behavior. It includes:
x
,y
: Coordinates of the cell.size
: Size of the cell.flavorId
: Index representing the flavor of chocolate in cell in respect of flavors!.shapeId
: Index representing the shape of chocolate in cell in respect of shapes!.visible
: Whether the chocolate inside the cell is visible.flavors
: Array of flavors shared across all cells.shapes
: Array of shapes shared across all cells.
-
Change the
joystick
variables to make your desired chocolate box grid layout!!- Change the
size
function params if you need a largerbox
compared to default size!! - The program will
auto center
your box on the screen!
- Change the
-
Use the keyboard ⌨️ & mouse 🖱️ to interact with the chocolates:
Hover
on the desired cell to select it on the grid!- Press
Space
to toggle visibility. - Press
s
to select the next flavor. - Press
a
to select the previous flavor. - Press
f
to select the next shape. - Press
d
to select the previous shape.
-
The
timeManager
related functions handles the timing for these interactions to prevent rapid changes.
- I don't think there is more optimization possible for this super-optimized code!
- I don't be buggy in small software like this!
Enjoy the chocolatey experience! 🍬🎉
Give a star⭐️ for this project if you liked it!