To view the global live version example please navigate to --> https://shooting-particles.herokuapp.com/
.
The local version example is instead run by running 'npm start'
in the terminal accessed by --> http://localhost:8080/
- ShootingParticles
- Particle
A class that encompasses the toolbar, canvas including the draw-space.
initGravity
boolean The initial boolean value for the gravity feature. (optional, defaulttrue
)initRandomise
boolean The initial boolean value for the randomise feature. (optional, defaultfalse
)initViscosity
number The initial value for the viscosity. (optional, default0
)initParticleColor
string The initial particle colour. (optional, default'white'
)initMaximumParticles
number The maximum amount of particles allowed in the space at one time. (optional, default200
)
Checks to see if the C key is pressed for clearing the particles.
Clears all particles
The draw function for the ShootingParticles.
Creates the toolbar which includes: the three sliders (colour, viscosity and size) and the two toggle buttons (gravity and randomise).
Positions the toolbar in respect to the current window size. Used when the toolbar is initially setup and when the window is re-sized.
Draws the toolbar text onto the screen.
The function that is called when the gravity button is toggled. Sets the gravity variable to true when false and vice versa. Also changes the gravity button colour when toggled.
The function that is called when the randomise button is toggled. Sets the randomise variable to true when false and vice versa. Also changes the randomise button colour when toggled.
This is called from the draw function to set each of the colour, size & viscosity variables depending on the value on the sliders. If randomise is set to true the value of the colour & size slider is incremented.
Creates a new particle. Called when the mouse is pressed or dragged. A new particle is created as long as the cursor is outside of the toolbar. Also deletes the oldest particle if the particle limit is reached.
Sets the gravity property.
newGravity
boolean The boolean variable to set the gravity on or off.
Returns any nothing
Gets the boolean value of the gravity property.
Returns boolean this._gravity - Returns the boolean value of the gravity property.
Sets the randomise property.
newRandomise
boolean The boolean variable to set the randomise on or off.
Returns any nothing
Gets the boolean value of the randomise property.
Returns boolean this._randomise - Returns the boolean value of the randomise property.
Sets the viscosity property.
newViscosity
number The number variable to set the value of the viscosity.
Returns any nothing
Gets the number value of the viscosity property.
Returns number this._gravity - Returns the number value of the viscosity property.
Sets the particle colour property.
newParticleColor
string The string variable to set the active colour to be displayed.
Returns any nothing
Gets the string value of the particle colour property.
Returns string this._particleColor - Returns the string value of the particle colour property.
Sets the maximum particles property.
newMaximumParticles
number The number variable to set the maximum number of particles active on the canvas.
Returns any nothing
Gets the number value of the maximum particles property.
Returns number this._maximumParticles - Returns the number value of the maximum particles property.
Sets the particles list property.
newParticles
array The array that contains all the particle classes active on the board.
Returns any nothing
Gets the array of the particles property.
Returns array this._particles - Returns the array of the particles property.
A class that represents the Particle component.
x
number The initial x co-ordinate for the particle. (optional, default0
)y
number The initial y co-ordinate for the particle. (optional, default0
)velX
number The initial velocity with respect to the x-axis for the particle. (optional, defaultrandom(-.1,.1)
)velY
number The initial velocity with respect to the y-axis for the particle. (optional, defaultrandom(-.1,.1)
)
Moves the particle depending on it's current position and velocities.
Draws the particle onto the canvas.
Updates the particle velocity depending on the distance to the other particles and if it is in close proximity to the mouse.
Sets the x position property.
newXPos
number The number variable to set the value of the x position.
Returns any nothing
Gets the number value of the x position property.
Returns number this._xPos - Returns the number value of the x position property.
Sets the y position property.
newYPos
number The number variable to set the value of the y position.
Returns any nothing
Gets the number value of the y position property.
Returns number this._yPos - Returns the number value of the y position property.
Sets the x velocity property.
newXVel
number The number variable to set the value of the x velocity.
Returns any nothing
Gets the number value of the x velocity property.
Returns number this._xVel - Returns the number value of the x velocity property.
Sets the y velocity property.
newYVel
number The number variable to set the value of the y velocity.
Returns any nothing
Gets the number value of the y velocity property.
Returns number this._yVel - Returns the number value of the y velocity property.
Sets the mass property.
newMass
number The number variable to set the value of the mass.
Returns any nothing
Gets the number value of the mass property.
Returns number this._mass - Returns the number value of the mass property.
Sets the particle colour property.
newColor
string The string variable to set the colour of the particle.
Returns any nothing
Gets the string value of the particle colour property.
Returns string this._color - Returns the string value of the particle colour property.
Sketch from https://www.openprocessing.org,
Called: Jelly Sim,
Original Sketch By: nebulaeandstars,
Adapted Sketch By: hkxx26
Link: https://www.openprocessing.org/sketch/587065,
Licence: https://creativecommons.org/licenses/by-sa/3.0/
Meta
- license: CC-BY-SA-3.0