All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Serialization to and from JSON.
- Networking using JamJar relay protocol.
v0.10.0 - 2021-02-25
CanvasResizeSystem
to handle automatic resizing of the canvas to fit a wrapper/the screen while maintaining the requested aspect ratio and within maximum resolution constraints.CanvasResize
utility functions to allow manual canvas resizing and providing best estimate aspect ratios.- Global variables to allow flexiblity in hosting environment.
window.JamJar.CanvasID
- The ID of the canvas to render to.window.JamJar.CanvasWrapperID
- The ID of the wrapper around the canvas, used to handle automatic resizes.window.JamJar.RootPath
- The 'root path' that the game was loaded from to handle resolving paths to assets.
- Ability to stop games, using the
window.JamJar.StopGames()
global function, allows host sites to stop a running game. - Object pooling, allows reusing objects in memory to avoid the garbage collection churn of create -> delete -> create. This can help prevent stuttering due to minor and major garbage collection occurring between frames by reducing the volume of objects that need garbage collected.
Vector
object is now poolable, with helper static functions added toVector
New
-> provisions aVector
from the object pool if available, if not it creates a new instance.Free
-> releases aVector
back into the object pool if available.Init
-> initializes theVector
object pool to a specified size.
Renderable
object is now poolable, with similar helper static functions asVector
.DispatchUntilEmpty
method added toMessageBus
, allows repeated dispatching until the message queue is empty.StatefulSystem
abstract definition for tracking entities and components, handles listening for registration and deregistration.ArraySystem
for tracking entities and components in an array, good for iteration.MapSystem
for tracking entities and components in a map, good for lookups.
- In
Polygon
->RectangleByDimensions
,QuadByDimensions
, andEllipseEstimation
all now represent center/origin using two X and Y numbers rather than a vector object to avoid unneeded object creation. - In
Ellipse
->Circle
represnts center using two X and Y numbers rather than a vector object to avoid unneeded object creation. Component
implementsIFreeable
, allowing component values to be freed upon removal/entity destruction. This must be implemented on a perComponent
basis by overriding this function.- The game loop now ensures all game logic messages are processed using
DispatchUntilEmpty
before executing any render logic. AABBAlgorithm
more efficient algorithm involving sweeping horizontal then vertical.AABB
methodFarthestPointInDirection
faster and using lessVector
objects.- Pointer, pointer move, and wheel events synced up and dispatched within the engine update loop.
Polygon
usesFloat32Array
internally.Polygon
can now be initialised with aFloat32Array
.- Frustum culling moved to preprocessing and removed from render pipeline.
- Replaced in-house Vector and Matrix code with the
gl-matrix
library. - Shapes'
Transform
method is now mutable, it affects the object it is being applied to. Message
objects are now poolable.Color
now internally uses a typed array.System
now stateless, does not track any entities/components, instead use aStatefulSystem
.
v0.9.0 - 2020-09-05
Polygon
has a new static methodEllipseEstimation
for creating aPolygon
that estimates an ellipse.Polygon
objects can now be initialised to be wrapped.- New
index
links all exported types, allows for easier imports.- Instead of
import x from "jamjar/lib/path";
it is nowimport { x } from "jamjar";
- Instead of
HTTPAudioSystem
for loading audio assets over HTTP.AudioSourceSystem
for interpretingAudioSource
components and using them to play audio.- Audio can be played by adding an
AudioSource
to an entity and configuring it.
- Audio can be played by adding an
- Scripting system.
HTTPScriptSystem
loads scripts over HTTP.ScriptTriggerSystem
handles standalone scripts that can be triggered on events, currently only event supported isUpdate
.ScriptEngineSystem
handles executing scripts and provides an interface between the game engine and the script.Collider
now has an optionalscript
string, which allows triggering a script on collision.- Scripts can be manually triggered by sending a
ScriptTriggerRequest
as a message.
AABB
shape, Axis-Aligned Bounding Box - ignores rotation, good for faster collision detection than fully defined Polygons.AABBAlgorithm
for detecting collisions between AABBs, can take any shape, only does checks in 4 directions.Matrix3D
andMatrix4D
have newSet
function for settings Matrix values.
- Game loop now relies on more accurate timing method, using
requestAnimationFrame
overDate.now()
. - Entry point changed from
game.js
toindex.js
. Vector
changed to use Float32Array behind the scenes.Matrix3D
andMatrix4D
changed to use Float32Array behind the scenes.Matrix3D
andMatrix4D
operations now return a reference to themselves.Matrix3D
andMatrix4D
can no longer be value initialised through constructor.- Collision events now set to be on collision enter and exit only, not every update that the collision is occurring for.
- Scripts can now be set to be trigged on collision enter or exit in the
Collider
component. Scripts no longer can be triggered on every update for the duration of a collision. - Collision algorithms now take as input an array of
IShape
to check, rather than simply twoIShape
, and returns a list ofCollisionInfo
, rather than a singleCollisionInfo
or undefined. - Renamed
CalculateCollision
->CalculateCollisions
inICollisionAlgorithm
GJKAlgorithm
updated to match newICollisionAlgorithm
interface.AlwaysCollideAlgorithm
renamedAllCollideAlgorithm
.NeverCollideAlgorithm
renamedNoneCollideAlgorithm
.- All
Vector
methods are now mutable, no longer immutable to try and reduce number of JS objects created.
- The zOrder is now correctly interpreted in
WebGLSystem
rather than being in order of renderable creation. Rotate
andRotateDeg
now calculating correctly.
Matrix3D
andMatrix4D
Identity()
function removed.Polygon
GetArray()
function removed.
v0.8.0 - 2020-05-28
- Ability to configure how textures are configured with
ITextureOptions
.- Can specify x and y wrap.
- Repeat.
- Repeat mirror.
- Clamp to edge.
- Can specify magnification and minification filters.
- Nearest neighbour.
- Bilinear.
- Trilinear.
- Can specify generating mipmaps.
- Can specify x and y wrap.
- Primitive rendering, can now render primitive shapes by adding a
Primitive
component - can render lines, polygons, and points; allows specifying draw mode.- Allows more low level control over rendering, rather than
Sprite
, which has a fixed draw mode and is further processed by theSpriteSystem
.
- Allows more low level control over rendering, rather than
Material
propertycolor
added, if there is a texture the texture will be mixed with this color, if there is no texture the color will be used directly.- Simple
tags
option for entities, an array of string tags that can be used to discriminate between entities without requiring an entirely new component. - Simple
layers
option for entities, an array of string layers, intended for grouping entities and treating them differently. CollisionSystem
now takes an optionalcollisionLayerPairs
parameter, if this is provided it allows for filtering collisions by layers - with only specified layers allowed to collide. If nocollisionLayerPairs
provided, no filtering is applied.- New option for loading textures,
mirror
- allows loading textures in a mirrored mode (flip horizontally and vertically). - New static quad functions in
Polygon
,QuadByPoints
andQuadByDimensions
to generate quads easily. - Sprite Animation through the
SpriteAnimator
components andSpriteAnimatorSystem
.- Can make animations with a
SpriteAnimation
, allows switching between animation states. SpriteAnimation
allows specifying animation frame rate.SpriteAnimation
defined as an array ofSpriteKeyFrame
, which contain information such as the material to render with, the duration of the keyframe etc.
- Can make animations with a
- New
GenerateSpritesheetIndex
static function forTexture
, allows creation of an indexed sprite sheet for ease of use with a texture.
- Images now loaded with a new
ImageRequest
rather than anImageAsset
-ImageAsset
used internally.- Message for loading images moved from
ImageAsset
toImageRequest
.
- Message for loading images moved from
- Optional font options specified by a
IFontOptions
interface, allows overriding default font options such ascharacters
,buffer
,cutoff
etc. Material
options specified by newIMaterialOptions
, a collection of optional arguments that override material defaults, such astexture
,color
andshaders
.Material
propertytexture
now optional, if none provided it will render only using thecolor
.TRIANGLES
draw mode now used instead ofTRIANGLES_FAN
for sprites.- Sprites and text now rendered exclusively using quads, sprite shape can no longer be specified.
- Z order bug where an error was thrown if there were gaps between z orders,
e.g.
0, 1, 3
would error because2
was missing - caused due to internal representation of z order with an array; changed to use a map. - Dispatches in the message bus could be skipped if a subscriber unsubscribed from the message, causing the order to be confused and subscribers to be skipped. Fixed by cloning the dispatch queue before dispatching.
- Cannot draw with
TRIANGLES_FAN
draw mode.
v0.7.0 - 2020-05-04
- Frustum Culling separated out, can choose a collision algorithm to use for culling.
Apply4D
added toPolygon
to apply 4D matrices.Center
added toPolygon
to get center of shape.Center
added toIShape
.- Wheel support, can now listen for
wheel
events, which are published with throttledWheelEvent
messages.
- Collision algorithms now abstracted as
ICollisionAlgorithm
, can be swapped out inCollisionSystem
andFrustumCulling
.- Collision algorithms take two shapes as input and output a
CollisionInfo
object, or undefined if there is no collision.
- Collision algorithms take two shapes as input and output a
- GJK refactored to work as a
ICollisionAlgorithm
.
v0.6.1 - 2020-04-04
Text
position correctly calculated forUI
entities.
v0.6.0 - 2020-04-04
RectangleByPoints
function inPolygon
, creates a newPolygon
rectangle between the two provided points.- Frustum culling, only rendering what is on screen to improve performance.
- Text rendering with the
TextSystem
,FontAsset
andText
Component.- Supports any font loaded through the browser.
- Specify font size, weight, family, and other tuning options through
FontAsset
for a font. - Specify z order, alignment, spacing, color, offset and shaders through
Text
component for a specific piece of text. - New fragment shader for rendering text,
default_text_fragment
.
Renderable
can now have additional information attached to them by pre-rendering systems, which can be accessed by shaders.Material
represents shaders and a texture to apply. Can be applied to entities, allowing custom shaders.- Can now load custom shaders using a
ShaderAsset
.
- Merged
SpriteSystem
andUISystem
into a single system -SpriteSystem
. Rectangle
function inPolygon
renamedRectangleByDimensions
.RectangleByDimensions
takes an optional origin point, default0,0
.- All sprites require a
Texture
now, no longer optional. ImageSystem
renamed toHTTPImageSystem
.- Group by texture for WebGL rendering to reduce texture switching and improve performance.
Polygon.PointInside
does not mistakenly predict point to the right of the polygon are inside.
v0.5.0 - 2020-03-22
zOrder
field to sprites, to determine which sprites should be rendered infront of which.
System
and descendants ofSystem
now use optional parameters rather than an object containing multiple parameters.Pointer
events are now published immediately and do not wait for the next update.
PointerCameraInfo.withinBounds
now correctly calculated.
v0.4.1 - 2020-03-20
worldPosition
now correctly calculated; correctly handles new coordinate space.
v0.4.0 - 2020-03-20
- New
UISystem
for creating HUDs and UIs, position and scale relative to camera view rather than world space.
- Changed coordinate systems from
(-0.5, -0.5) -> (0.5, 0.5)
to(-1, -1) -> (1, 1)
to be more intuitive.Camera
fieldviewportPosition
changed.PointerCameraInfo
fieldcameraPosition
changed.Pointer
fieldelementPosition
changed.- For
UI
enabled entities, theTransform
fieldposition
changed.
v0.3.0 - 2020-03-05
- Added
FullscreenSystem
to handle fullscreen events and pointer lock. PointerSystem
supports pointer lock through theFullscreenSystem
.PointInside
function for shapes (Polygon
andEllipse
), determines if a point is inside the polygon.
KeyboardSystem
messages emitted use JSKeyboardEvent.code
(physical keyboard) rather thanKeyboardEvent.key
(input character).System
to storeSystemEntities
as a map rather than as an array, for easier random access.
GetSystemEntity
- no longer needed asSystemEntities
stored as map.
v0.2.0 - 2020-02-24
KeyboardSystem
to manage keyboard input.PointerSystem
to manage pointer input (mouse, touch).- Separate Rendering into stages, with
pre-render
,render
andpost-render
. - Sprites now processed in
pre-render
. - WebGL rendering system added.
ImageSystem
to handle loading image assets.- Rendering system now supports rendering textures.
0.1.0 - 2019-10-27
- Entity-Component-System architecture.
- Composition based entities and components.
- Regular game loop.
- Sprites and rendering.
- Collision detection.
- Scene management.
- Camera systems.
- Basic physics for velocities/acceleration/rotation.