Skip to content

Commit

Permalink
release version 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatCoolCoder committed Aug 1, 2021
1 parent c3599c2 commit 2171229
Show file tree
Hide file tree
Showing 10 changed files with 2,468 additions and 31 deletions.
2,069 changes: 2,069 additions & 0 deletions cdn/1.6.0/spnr.js

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions cdn/1.6.0/spnr.min.js

Large diffs are not rendered by default.

80 changes: 75 additions & 5 deletions cdn/latest/spnr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! (exclamation mark preserves comment)
spnr.js v1.5.0
spnr.js v1.6.0
MIT License
Expand Down Expand Up @@ -41,7 +41,7 @@ if (window.spnr !== undefined) {
}
else {
var spnr = {}; // Create an object to be the basis of spnr
spnr.VERSION = 'v1.5.0';
spnr.VERSION = 'v1.6.0';
spnr.consoleLogHeader = ' 🔧🔧 ';
spnr.consoleLogStyling = 'background-color: #9cc8ff; display: block';
window.spnr = spnr; // Make it global
Expand Down Expand Up @@ -1073,6 +1073,7 @@ spnr.GameEngine = class {
static globalScale;

static crntScene;
static crntCanvasSizer;

// Time since last frame in seconds
static deltaTime;
Expand Down Expand Up @@ -1124,6 +1125,10 @@ spnr.GameEngine = class {
this.canvasSize.y * this.globalScale)
}

static selectCanvasSizer(canvasSizer=null) {
this.crntCanvasSizer = canvasSizer;
}

static setGlobalScale(scale) {
this.globalScale = scale;
if (this.pixiApp != undefined) {
Expand Down Expand Up @@ -1242,14 +1247,18 @@ spnr.GameEngine = class {
}

// Main method
// -------------
// -----------

static update() {
this.deltaTime = this.pixiApp.ticker.elapsedMS / 1000;

if (this.crntScene != null) {
this.crntScene.internalUpdate();
}

if (this.crntCanvasSizer != null) {
this.crntCanvasSizer.updateCanvasSize();
}
}
}

Expand Down Expand Up @@ -1917,12 +1926,15 @@ spnr.GameEngine.ParticleEffect = class extends spnr.GameEngine.Entity {

timer = 0;
playing = false;
particlesRemaining = false;
particlesRemaining = 0;
hasPlayed = false;

constructor(name, localPosition, localAngle, emitterData, looping=false) {
constructor(name, localPosition, localAngle, emitterData, looping=false,
deleteWhenFinished=false) {
super(name, localPosition, localAngle);
this.emitterData = emitterData;
this.looping = looping;
this.deleteWhenFinished = deleteWhenFinished;
}

play() {
Expand Down Expand Up @@ -1980,20 +1992,78 @@ spnr.GameEngine.ParticleEffect = class extends spnr.GameEngine.Entity {

update() {
if (this.playing) {
// Everything in here is run in the nominal playing state
if (this.particlesRemaining > 0) {
this.timer -= spnr.GameEngine.deltaTime;
if (this.timer < 0) {
this.addParticle();
this.timer = this.emitterData.interval;
}
}
// Everything in here is run on the frame where playing finishes
else {
this.hasPlayed = true;

// Make it loop
if (this.looping) this.play()
// Otherwise just quit
else this.playing = false;
}
}

// Delete when finished
if (this.deleteWhenFinished && this.children.length == 0
&& this.hasPlayed) {
this.parent.removeChild(this);
}
}
}

spnr.GameEngine.AbstractCanvasSizer = class {
updateCanvasSize() {
throw Error('Method "calcCanvasSize" not overwritten in class ' +
'extending from AbstractCanvasSizer');
}
}

spnr.GameEngine.FixedARCanvasSizer = class extends spnr.GameEngine.AbstractCanvasSizer {
constructor(targetSize, padding, minScale=0, maxScale=Infinity) {
super();
this.targetSize = spnr.v.copy(targetSize);
this.padding = spnr.v.copy(padding);
this.minScale = minScale;
this.maxScale = maxScale;
}

updateCanvasSize() {
var targetAspectRatio = this.targetSize.x / this.targetSize.y;
var availableArea = spnr.v.copySub(spnr.dom.viewportSize(), this.padding);

var availableAspectRatio = availableArea.x / availableArea.y;

// If the target is 'wider' than the window
if (targetAspectRatio > availableAspectRatio) {
var sizeMult = availableArea.x / this.targetSize.x;
}
// If the target is 'taller' than the window
else {
var sizeMult = availableArea.y / this.targetSize.y;
}
spnr.GameEngine.setCanvasSize(this.targetSize);
spnr.GameEngine.setGlobalScale(sizeMult);
}
}

spnr.GameEngine.FillPageCanvasSizer = class extends spnr.GameEngine.AbstractCanvasSizer {
constructor(padding) {
super();
this.padding = spnr.v.copy(padding);
}

updateCanvasSize() {
var size = spnr.v.copySub(spnr.dom.viewportSize(), this.padding);
spnr.GameEngine.setGlobalScale(1);
spnr.GameEngine.setCanvasSize(size);
}
}

24 changes: 17 additions & 7 deletions cdn/latest/spnr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions editorDocumentation/makingRelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ This is a brief overview of how to do these tasks. For more detailed instruction

In a terminal, navigate to the root directory of this project. Run `python3 scripts/compiler.py` followed by `python3 scripts/minifier.py`.

## Step 3: Put in CDN folder
## Step 3: Update and build HTML reference

Follow the instructions [here](aboutReference.md).

## Step 4: Put in CDN folder

Create a new subdirectory in `/cdn/` with the name of the new spnr.js version (do not put a `v` at the start). Copy `spnr.js` and `spnr.min.js` from the `/build/` directory into the new folder. Also copy those two files into `/cdn/latest/` (overwrite the existing files there).

For more detailed info on the CDN folder, see [cdn](#cdn.md).
For more detailed info on the CDN folder, see [cdn](cdn.md).

## Step 4: Commit and push
## Step 5: Commit and push

The previous steps will probably have made some changes to your work tree. You can now commit and push to GitHub.

## Step 5: Make release on GitHub
## Step 6: Make release on GitHub

There should already be a work-in-progress release on GitHub called `[unreleased]`. If there's not a release there, create one from the template below. Document your changes there if you haven't done so already. Set the name and tag to the new version (prefix with `v`). Upload the newly-built `spnr.js` and `spnr.min.js` as attachments. You can now publish the release. Please also create a new `[unreleased]` from the template below.

Expand All @@ -48,6 +52,6 @@ Bugfixes:
None
```

## Step 6: Publish to NPM
## Step 7: Publish to NPM

I don't actually remember how to do this. I think it might just involve running `npm publish`.
Run `npm publish`.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spnr",
"version": "1.5.1",
"version": "1.6.0",
"description": "A multipurpose, flexible, and fast JavaScript library",
"main": "cdn/latest/spnr.min.js",
"scripts": {
Expand Down
8 changes: 2 additions & 6 deletions src/GameEngine/canvasSizers/FillPageCanvasSizer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
spnr.GameEngine.FillPageCanvasSizer = class extends spnr.GameEngine.AbstractCanvasSizer {
constructor(padding, targetScale=null) {
constructor(padding) {
super();
this.padding = spnr.v.copy(padding);
this.targetScale = targetScale;
}

updateCanvasSize() {
var size = spnr.v.copySub(spnr.dom.viewportSize(), this.padding);
if (this.targetScale != null) {
spnr.v.div(size, this.targetScale);
spnr.GameEngine.setGlobalScale(this.targetScale);
}
spnr.GameEngine.setGlobalScale(1);
spnr.GameEngine.setCanvasSize(size);
}
}
4 changes: 2 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! (exclamation mark preserves comment)
spnr.js v1.5.1
spnr.js v1.6.0
MIT License
Expand Down Expand Up @@ -41,7 +41,7 @@ if (window.spnr !== undefined) {
}
else {
var spnr = {}; // Create an object to be the basis of spnr
spnr.VERSION = 'v1.5.1';
spnr.VERSION = 'v1.6.0';
spnr.consoleLogHeader = ' 🔧🔧 ';
spnr.consoleLogStyling = 'background-color: #9cc8ff; display: block';
window.spnr = spnr; // Make it global
Expand Down
4 changes: 2 additions & 2 deletions userReference/htmlContentsTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<body>
<h1>spnr.js Reference Contents</h1>

<h4>Up to date with spnr.js 1.5.1</h4>
<h4>Up to date with spnr.js 1.6.0</h4>

<h4>List of pages: (use browser search page to find a specific one)</h4>
<h4>List of pages: (use your browser's search page feature to find the one you want)</h4>
<div>{}</div>
</body>
</html>
Loading

0 comments on commit 2171229

Please sign in to comment.