Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Created July 29, 2015 15:49
Show Gist options
  • Save clauswitt/44849a56e93cf95e3964 to your computer and use it in GitHub Desktop.
Save clauswitt/44849a56e93cf95e3964 to your computer and use it in GitHub Desktop.
import { CanvasContext } from './CanvasContext';
import { Sprite } from './Sprite';
import { Sprites } from './GameSprites/Factory';
var context = new CanvasContext(document.getElementById('game'));
var sprites = [
new Sprite(100, 100,'assets/spritesheet.png', 24, 24, 0, 376, 16),
new Sprites.red(32, 0),
new Sprites.purple(74, 52),
new Sprites.gold(114, 32),
new Sprites.gold(164, 32),
new Sprites.red(210, 32)
]
sprites[0].setTicksPerFrame(16);
sprites.forEach(function(sprite) {
sprite.loadImage();
});
function renderLoop() {
context.clear();
sprites.forEach(function(sprite) {
context.renderShape(sprite);
});
requestAnimationFrame(renderLoop);
}
renderLoop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment