Skip to content

Simulation Main Page

Zachary-Ronayne edited this page Oct 15, 2020 · 14 revisions

Simulation Core

The Simulation is stored and processed as an Experiment. Experiments hold all of the information, and process all of the systems for simulating Experiments.

The core of the code is split into two class types, the model, and the controller. The model is simply the name of the object, for example the class "Beaker" is the beaker model. The controller is the name of the model, along with Controller, for "BeakerController". Controllers also act on certain dimensions, meaning they are also marked with 2D, for the full name "BeakerController2D". For now, all controllers are 2D, and any new controllers should be labeled as such.

Rendering

All rendering is done via P5.js, a very intuitive and easy to use graphics library. Methods to draw in an Experiment should contain a parameter for a graphics object, and all rendering should take place on this graphics object. For example, a method call might look like this.

function drawBeaker(graphics){ graphics.drawImage(x, y, beakerSprite); }

Input

All input for Experiments should be done through P5.js built in methods for mouse and keyboard input. These methods are automatically called by P5.js when a key or mouse event occurs, and are set up to call methods in ExperimentController2D. Generally, only ExperimentController2D directly interacts with mouse and keyboard input, all other classes that react based on input will be handled my ExperimentController2D.