added progress bar

This commit is contained in:
Nathan DECHER
2020-03-24 13:01:24 +01:00
parent bd6d9f3399
commit daef55781e
8 changed files with 148 additions and 5 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
const Assets=require('assets');
const assets=require('assets');
const [EMPTY, FOOD, WALL, SNAKE]=Array(4).keys();
@@ -47,7 +47,7 @@ class SnekGame {
const offsetY=(this.canvas.height-cellSize*this.dimensions[1])/2;
// draw our walls
const wall=Assets.get('wall');
const wall=assets.get('wall');
for(let x=0; x<this.dimensions[0]; x++) {
for(let y=0; x<this.dimensions[1]; y++) {
switch(this.world[x][y]) {
@@ -65,7 +65,7 @@ class SnekGame {
}
// draw our snake
const snake=Assets.get('snake');
const snake=assets.get('snake');
this.ctx.fillStyle=snake.color;
this.ctx.strokeStyle=snake.color;
this.ctx.lineCap=snake.cap;
@@ -96,7 +96,7 @@ class SnekGame {
// our fruit has a nice animation to it between .8 and 1.2 scale
const ms=Date.now();
const fruitScale=Math.sin(ms/1000*Math.PI)*.2+1
const fruit=Assets.get('fruit');
const fruit=assets.get('fruit');
this.fruits.forEach(([x, y]) => {
this.ctx.drawImage(
fruit,