Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chem

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chem - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

3

index.js

@@ -10,7 +10,6 @@ var resources = require('./lib/resources');

Batch: require('./lib/batch'),
resources: resources,
onReady: resources.onReady,
animations: resources.animations,
spritesheet: resources.spritesheet,
};
resources.bootstrap();

@@ -12,3 +12,2 @@ var vec2d = require('vec2d');

module.exports = Engine;
Engine.getImage = getImage;

@@ -26,14 +25,2 @@ var targetFps = 60;

function getImage(name, frameIndex){
if (frameIndex == null) frameIndex = 0;
var anim = resources.animations[name];
var buffer = document.createElement('canvas');
var frame = anim.frames[frameIndex];
buffer.width = frame.size.x;
buffer.height = frame.size.y;
var context = buffer.getContext('2d');
context.drawImage(resources.spritesheet, frame.pos.x, frame.pos.y, frame.size.x, frame.size.y, 0, 0, frame.size.x, frame.size.y);
return buffer;
}
util.inherits(Engine, EventEmitter);

@@ -40,0 +27,0 @@ function Engine(canvas) {

@@ -9,2 +9,3 @@ var vec2d = require('vec2d');

var animationsJsonDone = false;
var alreadyStarted = false;

@@ -16,2 +17,3 @@ exports.bootstrap = bootstrap;

exports.useSpritesheet = true;
exports.getImage = getImage;

@@ -27,2 +29,6 @@ function onReady(cb) {

function bootstrap(){
// don't bootstrap twice
if (alreadyStarted) return;
alreadyStarted = true;
// give the app a chance to skip spritesheet loading

@@ -79,1 +85,18 @@ setTimeout(loadSpritesheet);

}
function getImage(name, frameIndex){
if (frameIndex == null) frameIndex = 0;
var anim = exports.animations[name];
var buffer = document.createElement('canvas');
var frame = anim.frames[frameIndex];
buffer.width = frame.size.x;
buffer.height = frame.size.y;
var context = buffer.getContext('2d');
context.drawImage(exports.spritesheet,
frame.pos.x, frame.pos.y,
frame.size.x, frame.size.y,
0, 0,
frame.size.x, frame.size.y);
return buffer;
}

@@ -5,3 +5,3 @@ {

"author": "Andrew Kelley <superjoe30@gmail.com>",
"version": "0.4.0",
"version": "0.4.1",
"main": "index.js",

@@ -8,0 +8,0 @@ "license": "MIT",

@@ -587,2 +587,9 @@ chem - html5 game engine optimized for rapid development

### 0.4.1
* `chem.getImage` moved to `chem.resources.getImage`
* `chem.animations` moved to `chem.resources.animations`
* `chem.spritesheet` moved to `chem.resources.spritesheet`
* fix double bootstrap bug
### 0.4.0

@@ -589,0 +596,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc