Skip to content

Releases: Moderrek/JSGL

JSGL v1.0.8 - User Input, "Camera", isTouching Update

04 Apr 16:48
246fb6b
Compare
Choose a tag to compare

New

  • Added changelogs
  • Game Events
    • mouseScroll - emits GameMouseEvent
    • keyDown - emits GameKeyEvent
    • keyUp - emits GameKeyEvent
  • "Camera" is more like to view offset. You can find it in game.canvasViewOffset. This property is a Vector2.
  • Added DrawableGameObject.IsTouching(drawGameObj, drawGameObj2) static method and drawableGameObject.isTouching(drawGameObj)
  • Added JSGL.log(content), JSGL.warn(content), JSGL.error(content). Prints message to dev console with format [DATE] [LEVEL] content

Changes

  • Deprecated
    • game.mousePos - Instead use game.input.mouseWorldPosition
    • game.mouseClientPos - Instead use game.input.mouseClientPosition
    • game.mousePrecisePos - Instead use game.input.mousePreciseWorldPosition
    • game.isMousePrimaryButtonDown() - Instead use game.input.isMousePrimaryButtonDown
  • Now GameMouseEvent has properties from game.input. (Only about mouse)

Fixes

  • None.

Presentation of news

Mouse wheel handling

In GameObject

...
Update(event){
    event.game.input.mouseScrollDelta.y; // x is ignored
}
...

Without GameObject

game.on('mouseScroll', (event) => {
    event.mouseScrollDelta.y; // x is ignored
});

How to work with input

In GameObject

...
Update(event){
    event.game.input.isKeyDown('w'); // <-- returns is 'w' pressed down
    event.game.input.isKeyUp('s'); // <-- returns is 's' clicked
}
...

Without GameObject

...
game.on('keyUp' (event) => {
    event.input.isKeyUp('s'); // <-- returns is 's' clicked
});
game.on('keyDown' (event) => {
    event.input.isKeyDown('w'); // <-- returns is 'w' pressed down
});
...

What's Changed

Full Changelog: v1.0.7...v1.0.8

JSGL v1.0.7 - Stable version update

02 Apr 08:59
a3a8410
Compare
Choose a tag to compare

From now the JSGL library will not undergo major changes. (i.e. renaming a function, etc.)

New

  • Added DOM detection and possibility to manually assign the document.
  • Added OnMouseHoverStart OnMouseHoverEnd OnMouseDown OnMouseUp event function in ClickableGameObject.
  • Reworked Vector2.
  • Reworked Transform.
  • Reworked Game start.
  • New function Renderer.fill(color | draw settings | image).

Changes

  • By default Game.Update() is invoked every frame. To change this set drawAlways=true in GameSettings
  • Removed JSGL.version constant.
  • Corrected documentation. https://jsglreference.pl
  • GameObject
    • GameObject.OnStart(event) -> GameObject.Start(event)
    • GameObject.OnDestroy(event) -> GameObject.Destroy(event)

Fixes

  • None.

Presentation of news

GameObject Update

From

class Object extends JSGL.GameObject {
    OnStart(event){}
    OnDestroy(event){}
}

To

class Object extends JSGL.GameObject {
    Start(event){}
    Destroy(event){}
}

TickEvent Update

  • New property Game.timeScale. Represents scale of time.
  • Now deltaTime is scaled by Game.timeScale.
  • New event value unscaledDeltaTime is deltaTime without Game.timeScale multiplication.
  • New event value unscaledTime. This value represents time from game start in seconds.

Vector2 ReWork

  • New static method Lerp(Vector2, Vector2, decimal midpoint)
  • New static method Max(Vector2, Vector2)
  • New static method Min(Vector2, Vector2)
  • New static property Vector2.zero = (0, 0)
  • New static property Vector2.one = (1, 1)
  • New static property Vector2.up = (0, 1)
  • New static property Vector2.down = (0, -1)
  • New static property Vector2.right = (1, 0)
  • New static property Vector2.left = (-1, 0)
  • New method set(Vector2) | set(x, y)
  • New method add(Vector2) | add(x, y)
  • New method subtract(Vector2) | subtract(x, y)
  • New method multiply(Vector2) | multiply(scalar)
  • New method divide(Vector2) | divide(scalar)
  • New method distance(Vector2) | distance(x, y)
  • New method floor()

Transform ReWork

  • New property angles. Gets/sets rotation in radians.
  • New property eulerAngles. Gets/sets rotation in degrees.
  • New property positionCenter.
  • New property forward. Gets Vector2 value in direction.
  • New property backward. Gets Vector2 value opposite to direction.
  • New method ifOnEdgeBounce(grid)
  • New method set(Vector2) | set(x, y)
  • New method setX(Vector2) | setX(x)
  • New method setY(Vector2) | setY(y)
  • New method translate(Vector2) | translate(x, y)
  • New method translateX(Vector2) | translateX(x)
  • New method translateY(Vector2) | translateY(x)

Better Game Starting

game.LoadGameAndStart().then((gameStartEvent) => {
    console.log("Game sucessfully loaded!");
}).catch((error) => {
    console.error("Encountered error @ game loading/after loading!", error);
}).finally(() => {
    console.log("After success/error");
});

ClickableGameObject Update

  • New property ignoreRaycast set to true if you want to ignore mouse events.
class MouseTest extends JSGL.ClickableGameObject {
    OnMouseClick = (e) => console.log('mouse click');
    OnMouseDown = (e) => console.log('mouse down');
    OnMouseUp = (e) => console.log('mouse up');
    OnMouseHoverStart = (e) => console.log('mouse hover start');
    OnMouseHoverEnd = (e) => console.log('mouse hover end');
}

What's Changed

Full Changelog: v1.0.6...v1.0.7

JSGL v1.0.6 - Simplify Update

29 Mar 17:49
ca70d27
Compare
Choose a tag to compare

JSGL - Simplify Update 1.0.6

New

  • Added SimpleShape and SimpleSprite
  • Added DefaultGame class
  • Added 6 examples to GitHub repository

Fixes

  • Fixed not working destroying game object by reference.

DefaultGame

Old solution

JSGL.ExampleHTML.Render({ backgroundColor: 'black'});
const grid = new JSGL.Vector2(10, 10);
const game = new JSGL.Game({
    canvas: document.getElementById("gameCanvas"),
    grid: grid,
});
game.RescaleCanvasToParentElement(1);

New solution

const game = JSGL.DefaultGame.Create({ grid: new JSGL.Vector2(10, 10)}, { backgroundColor: 'black' }, 1);

SimpleShape & Sprite

Check "/examples/" directory for examples.

What's Changed

Full Changelog: v1.0.4...v1.0.6

JSGL v1.0.4 - GameObject, Bouncing update

28 Mar 15:17
26a175e
Compare
Choose a tag to compare

Mini Update

Fixed game start without loading resources.
Added DrawableGameObject
Added ClickableGameObject
Added JSGL.floor(a)
Added rotation style
BETA bounce game object on edge
Corrected docs JSGL REFERENCE

What's Changed

Full Changelog: v1.0.3...v1.0.4

JSGL v1.0.3

28 Mar 06:03
94de2b7
Compare
Choose a tag to compare

https://jsglreference.pl

What's Changed

Full Changelog: v1.0.1...v1.0.3

JSGL v1.0.1

27 Mar 20:07
2501870
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.0.0-pre2...v1.0.1

1.0.0-pre2

25 Mar 17:09
93363b7
Compare
Choose a tag to compare
1.0.0-pre2 Pre-release
Pre-release

What's Changed

New Contributors

Full Changelog: v1.0.0-pre1...v1.0.0-pre2

v1.0.0-pre1

23 Mar 17:26
Compare
Choose a tag to compare
v1.0.0-pre1 Pre-release
Pre-release

Prerelease number 1, testing library.

Full Changelog: https://github.com/Moderrek/JSGL/commits/v1.0.0-pre1