-
Notifications
You must be signed in to change notification settings - Fork 1
Simulation Main Page
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 example, "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.
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.image(beakerSprite, x, y);
}
All constant values used in render, i.e., x and y coordinates, scalars, width and height, should all be defined in constants in RenderConstants2D.js, located in Util. Each constant should have a descriptive name describing where it is used, and should be given a descriptive comment for what it does. This is to prevent magic numbers from existing in rendering methods, and if anything for the render methods needs to change, it can be updated in one place.
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 by ExperimentController2D.