Javascript 2D Game Engine

Physics Sand Box



The Javascript 2D Game Engine (for want of a more exciting name), is more or less just that. It's a 2D engine I've developed, in javascript, with the primary purpose for creating games. It models shapes as rigid bodies, which can collide and be influenced by forces. Runga Kutta 4 is used to produce (fairly) stable integration for springs and and charge.

Now at version 4, the 2D engine now uses HTML 5's canvas tag, and Google's ExplorerCanvas to get it working in IE. The canvas is fairly widespread these days, so it should be supported fairly widely.

Version 4 is currently being developed and aims to add more features (see list below) without increasing CPU usage. This will enable me to make several games I've got planned. Hopefully.

Games using the engine include Planet Wars 1 (in engine v2) + 2 (in engine v3), Breakout, Physics Sandbox Multi-player support was added instead to Planet Wars, and will eventually be finished for PW2.

Engine Features


Currently Supported:
  • Gravity
  • Collision detection between regular and custom polygons, rods and circles.
  • Rigid Body Dynamics for collision response.
  • Static shapes.
  • World borders.
  • Abstracted class structure for easy integration into custom games.
  • Charged particles (Coloumb's law).
  • Springs (Hooke's Law).
  • String (Series of rods connect with springs).
  • Multiple draggable and zoomable viewports.
  • Saving and loading system JSON.

In Development and Planned:
  • Resting contact between shapes - should solve a lot of the more interesting problems.
  • Breakable springs.
  • Optimisiation, especially with reguard to polygon collision detection.

Planet wars makes extensive use of the Coloumb's Law implementation to simulate gravity.

History

  • Version 1
  • Version 2
  • Version 3
  • Version 4


[-]

ShoutBox!

Feel free to leave a comment!


There's a copy of the sandbox here but I'm not sure how up to date it is. Also the saving/loading won't work without a php server
--Luke 27th Jul 10 17:45

Are we able to download the physics sandbox? It looks great!
--Connor 26th Jul 10 14:27

fyi, your awesome divwindows script doesnt work correctly when the window is created in an external script. so I had to fix it to where the window events refer to windows[windownumber] instead of the variable that the window was assigned to. thanks for it though!
--Mega 27th Apr 10 03:11

Graph plotter breaks whenever a term goes to infinity at 0, if you just detected this then plotted at 0.000001 and -0.000001 instead, then it would fix it (and similarly for other infinities)
--Mike 20th Feb 10 16:16

View all posts

Shout!

Favourite Game?
Planet Wars
73%
Chain Reaction
27%
Total Votes = 141

Old Polls