Comparing version 0.6.2 to 0.6.3
{ | ||
"name": "squishjs", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "squish & unsquish stuff", | ||
@@ -5,0 +5,0 @@ "scripts": { |
``` | ||
> const { GameNode, Shapes, Colors, ShapeUtils, squish, unsquish } = require('squishjs'); | ||
> | ||
> const redSquare = new GameNode.Shape({ | ||
coordinates2d: ShapeUtils.rectangle(40, 40, 20, 20), | ||
fill: Colors.COLORS.RED, | ||
shapeType: Shapes.POLYGON | ||
}); | ||
> const squished = squish(redSquare); | ||
... fill: Colors.COLORS.RED, | ||
... coordinates2d: ShapeUtils.rectangle(20, 20, 60, 60), | ||
... shapeType: Shapes.POLYGON | ||
... }); | ||
> | ||
> const squished = squish(redSquare.node); | ||
> const unsquished = unsquish(squished); | ||
> | ||
> squished | ||
[ 3, 5, 43, 3, 0 ] | ||
[ | ||
3, 35, 43, 3, 0, | ||
44, 2, 52, 22, 20, | ||
0, 20, 0, 80, 0, | ||
20, 0, 80, 0, 80, | ||
0, 20, 0, 80, 0, | ||
20, 0, 20, 0, 53, | ||
6, 255, 0, 0, 255 | ||
] | ||
> | ||
> unsquished | ||
InternalGameNode { | ||
id: 0, | ||
children: [], | ||
color: undefined, | ||
handleClick: undefined, | ||
coordinates2d: [ | ||
20, 20, 80, | ||
20, 80, 80, | ||
20, 80, 20, | ||
20 | ||
], | ||
border: undefined, | ||
fill: [ 255, 0, 0, 255 ], | ||
text: undefined, | ||
asset: undefined, | ||
effects: null, | ||
input: null, | ||
listeners: Set {}, | ||
playerIds: [] | ||
} | ||
``` |
@@ -6,2 +6,4 @@ class Game { | ||
this.root = null; | ||
this.intervals = []; | ||
this.timeouts = []; | ||
} | ||
@@ -28,2 +30,26 @@ | ||
} | ||
setInterval(fun, interval) { | ||
const ticker = setInterval(fun, interval); | ||
this.intervals.push(ticker); | ||
return ticker; | ||
} | ||
setTimeout(fun, time) { | ||
const timeout = setTimeout(fun, time); | ||
this.timeouts.push(timeout); | ||
return timeout; | ||
} | ||
close() { | ||
for (const i in this.timeouts) { | ||
const timeout = this.timeouts[i]; | ||
clearTimeout(timeout); | ||
} | ||
for (const i in this.intervals) { | ||
const interval = this.intervals[i]; | ||
clearInterval(interval); | ||
} | ||
} | ||
} | ||
@@ -30,0 +56,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36163
991
46