Skip to content

Ralej86/GravBall

Repository files navigation

GravBall

Live Site

Description

GravBall is an interactive animation that demonstrates the effects of gravitational attraction on floating particles, or otherwise simulate the effects of a black hole.
game

Project Design

GravBall was designed over a 5 day period in June, 2018. Prior to being created a list of minimum viable products (MVPs) was formed to demonstrate a planning process before development began. These implementation of these MVPs was used to ensure I was staying on track to meet the project deadline.

Key Features

Gravitational attraction of every single gravity ball on free floating particles

attract

  • Particles move towards a gravity ball based each object's position, the total distance between them, and the size of the gravity ball.
  • Used Pythagorean theorem to determine distance.

Gravity balls can collapse on each other

collapse

  • N squared iteration of the gravityBalls array to create the attraction between each gravity ball.
  • To combine them into one larger ball, simply remove from array depending on each gravity ball's size, and increase radius of the surviving ball.
  • A variation of collision detection was implemented to check whether two different gravity balls would collapse on each other.

Single click versus double click functionality

double

  • double click invokes removeGravityBall() to remove a gravity ball on cursor position

single

  • Single click was more problematic in terms of keeping it bug free due to the double click feature and added GUI.
  • Specified the event target such that using the slider would not produce an additional unwanted gravity ball
  • Required the use of the setTimeout function to determine whether there was a second click.

Technologies

  • JavaScript
  • HTML 5 Canvas
  • Webpack

Sources: JavaScript, Canvas, WebPack

Future Plans

  • Vectors
    • Implement a vector class to exert better control over particle attraction
  • More GUI content
    • Interactive sliders for particle start size
    • Additional color sets
  • Additional styling
    • Adjust colors
    • Particle and gravity ball shape/coloring

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages