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 ofChocoCellobjects 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
joystickvariables to make your desired chocolate box grid layout!!- Change the
sizefunction params if you need a largerboxcompared to default size!! - The program will
auto centeryour box on the screen!
- Change the
-
Use the keyboard ⌨️ & mouse 🖱️ to interact with the chocolates:
Hoveron the desired cell to select it on the grid!- Press
Spaceto toggle visibility. - Press
sto select the next flavor. - Press
ato select the previous flavor. - Press
fto select the next shape. - Press
dto select the previous shape.
-
The
timeManagerrelated 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!
