This commit is contained in:
2022-08-06 19:09:23 -04:00
parent 0125f5b7ab
commit 4b55f4799e
12 changed files with 166 additions and 18 deletions

View File

@@ -1,4 +1,34 @@
/*
This file is imported by index.html, you can put any code you want to run afer
page load, here.
*/
const {FRAME_RATE} = require('./dist/constants.js');
const {UnitController} = require('./dist/unit-controller.js');
const {StaticSprite} = require('./dist/sprites.js');
const {sleep} = require('./dist/utils.js');
const canvas = <HTMLCanvasElement>document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const screenHeight = window.innerHeight;
const screenWidth = window.innerWidth;
canvas.width = screenWidth;
canvas.height = screenHeight;
function clearScreen() { ctx.clearRect(0, 0, screenWidth, screenHeight); }
const file = new StaticSprite(ctx, './assets/files.png', [1, 0], 0.5);
const sprite = new UnitController(ctx, {
spritesheetSrc: './assets/shadow_dog.png',
spriteAnimations: ['idle'],
spriteScale: 0.5,
spriteWidth: 575,
spriteHeight: 523,
spriteFrames: 7,
});
(async () => {
sprite.vel = [20, 0];
while(true) {
clearScreen();
file.render(25, 25);
sprite.tick();
await sleep(1000 / FRAME_RATE);
}
})();