All Projects → MTrajK → Bouncing Balls

MTrajK / Bouncing Balls

Licence: mit
Bouncing balls simulation using plain JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bouncing Balls

Icon Machine
Web application for randomly generating pixel art icons.
Stars: ✭ 73 (-23.96%)
Mutual labels:  game-development, canvas
Html5 Canvas Game Boilerplate
Provides a set of default code that makes getting up and running with an HTML5 canvas game very easy.
Stars: ✭ 182 (+89.58%)
Mutual labels:  game-development, canvas
Mir2
Javascript+Easycanvas+Node实现热血传奇(Mir2)游戏,还原了人物&装备&刷怪&战斗&背包等功能,支持联机,详情见wiki。
Stars: ✭ 147 (+53.13%)
Mutual labels:  game-development, canvas
Game
⚔️ An online JavaScript 2D Medieval RPG.
Stars: ✭ 388 (+304.17%)
Mutual labels:  game-development, canvas
Html5 Animation
Foundation HTML5 Animation with JavaScript example code and book exercises.
Stars: ✭ 667 (+594.79%)
Mutual labels:  game-development, canvas
Planck.js
2D JavaScript Physics Engine
Stars: ✭ 4,149 (+4221.88%)
Mutual labels:  game-development, canvas
Melonjs
a fresh & lightweight javascript game engine
Stars: ✭ 3,721 (+3776.04%)
Mutual labels:  game-development, canvas
Phaser
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
Stars: ✭ 30,918 (+32106.25%)
Mutual labels:  game-development, canvas
Physics Visual
Visualization/Simulation of 2D physics concepts
Stars: ✭ 75 (-21.87%)
Mutual labels:  physics-simulation, canvas
The Debuginator
A juicy feature-packed debug menu intended for games.
Stars: ✭ 91 (-5.21%)
Mutual labels:  game-development
Sunwell
Canvas-based high quality Hearthstone card renderer
Stars: ✭ 93 (-3.12%)
Mutual labels:  canvas
Vega
A visualization grammar.
Stars: ✭ 9,554 (+9852.08%)
Mutual labels:  canvas
Nimue4
Nim language integration for Unreal Engine 4
Stars: ✭ 90 (-6.25%)
Mutual labels:  game-development
My Animate
使用 HTML5 / Canvas / CSS3 制作各种动画效果
Stars: ✭ 93 (-3.12%)
Mutual labels:  canvas
Bright Souls
An indie "Dark Souls" clone in Unity with Adaptive Game Technology.
Stars: ✭ 91 (-5.21%)
Mutual labels:  game-development
Fe Daily Record
📚前端书籍汇集点 + 每日好文推荐 + 公开课学习资料 + 各种大会资料
Stars: ✭ 94 (-2.08%)
Mutual labels:  canvas
Fun Photo Combine
一个有趣的图片合成工具(生成的图片在QQ缩略图与大图表现不同)
Stars: ✭ 90 (-6.25%)
Mutual labels:  canvas
Nanoleaf Desktop
A modern desktop application for the Nanoleaf Aurora and Canvas
Stars: ✭ 90 (-6.25%)
Mutual labels:  canvas
Airinggo
🐈 基于 JS 的五子棋 AI 实现
Stars: ✭ 95 (-1.04%)
Mutual labels:  canvas
Is Engine
SFML C++ game engine that allows to create games on Web (HTML 5 - CSS 3), Android and PC
Stars: ✭ 94 (-2.08%)
Mutual labels:  game-development

Bouncing Balls

Simple bouncing balls simulation using plain JavaScript. Drawing in HTML Canvas, also plain CSS is used. (without third-part frameworks/code)

Try it here

Description

  • With a mouse click on the canvas a new ball is created, aim with holding the mouse down and moving it (drag the mouse further from the start point for greater speed), shoot the new ball with releasing the mouse button. (also touch screens/devices are supported, the same rules are used for touch events)
  • The canvas is updated (redrawn) 60 times in 1 second. (60 fps)
  • The canvas is responsive, with help from CSS media queries.
  • Because of that, the whole physics engine (all maths and logics inside) works with local coordinates/units. The local width is always 100 local units, and the height is always 66.6667 local units. (because the canvas ratio is 3:2)
  • The simulation is not a 100% real-world simulation, because there are many more factors for moving/colliding in the real world like the ball spinning, the softness of balls, the type of walls, even the weather, and sound waves have influence in the real world.
  • More description of the physics you can find inside the code, for example, when the balls collide these formulas are used, link.
  • Known issue: In "vertical" space/direction when the bottom is full with balls (when there is no space for a new ball) adding a new ball will make all balls go crazy (jumping randomly). This is because the balls will always collide and won't lose energy from colliding (at this moment I'm not sure how to solve this).

Repo structure

  • images - several gifs from the simulations
  • test - unit tests, Mocha framework is used for unit testing.This is how to run these tests using Mocha:
    • install NodeJS
    • install mocha in this project npm install mocha
    • run the tests from this project npm test
  • src - the source code of the application
    • index.html - a simple HTML page, JS and CSS files are imported and the choices and canvas are defined here
    • css/styles.css - used to define media queries (for responsiveness), and other very simple CSS rules
    • js/choice.js - used to initialize and stop the simulation (using the values from the choices)
    • js/bouncing-balls.js - handles the screen interaction (mouse and touch events) and draws in the canvas (some kind of mini game engine)
    • js/balls.js - balls collision and movement logics/physics
    • js/vector2d.js - 2 dimensional vector class, all vector related things are located here

License

This project is licensed under the MIT - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].