Add life sprite
This commit is contained in:
parent
896347025c
commit
d3ddaafce9
2 changed files with 35 additions and 4 deletions
|
@ -235,7 +235,7 @@ export class Game {
|
|||
* Handel the live generation
|
||||
*/
|
||||
lifeGenerator() {
|
||||
if (!this.world.find(v => v === tiles.LIFE)) {
|
||||
if (!this.world.find(v => v === tiles.LIFE) && !this.world.find(v => v === tiles.ORANGE)) {
|
||||
if (this.lifeCooldown <= 0) {
|
||||
if (this.lives < 3 && Math.random() < 0.15) {
|
||||
let pos = this.randCoords();
|
||||
|
@ -252,7 +252,7 @@ export class Game {
|
|||
* Handel the orange generation
|
||||
*/
|
||||
orangeGenerator() {
|
||||
if (!this.world.find(v => v === tiles.ORANGE)) {
|
||||
if (!this.world.find(v => v === tiles.ORANGE) && !this.world.find(v => v === tiles.LIFE)) {
|
||||
if (this.orangeCooldown <= 0) {
|
||||
if (Math.random() < 0.05) {
|
||||
let pos = this.randCoords();
|
||||
|
|
|
@ -187,8 +187,39 @@ export class Tile {
|
|||
}
|
||||
break;
|
||||
case tiles.LIFE:
|
||||
this.game.ctx.fillStyle = "#e400ff";
|
||||
this.game.ctx.fillRect(...canvasPos, ...size);
|
||||
if (!pxsize) {
|
||||
this.game.ctx.fillStyle = "#e400ff";
|
||||
this.game.ctx.fillRect(...canvasPos, ...size);
|
||||
} else {
|
||||
this.game.ctx.fillStyle = "#ff0000";
|
||||
|
||||
this.game.ctx.fillRect(width+pxsize, height+3*pxsize, 10*pxsize, 4*pxsize);
|
||||
this.game.ctx.fillRect(width+3*pxsize, height+7*pxsize, 6*pxsize, 2*pxsize);
|
||||
this.game.ctx.fillRect(width+2*pxsize, height+2*pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+8*pxsize, height+2*pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+5*pxsize, height+9*pxsize, 2*pxsize, pxsize);
|
||||
|
||||
this.game.ctx.fillStyle = "#000000";
|
||||
|
||||
this.game.ctx.fillRect(width, height+3*pxsize, pxsize, 3*pxsize);
|
||||
this.game.ctx.fillRect(width+11*pxsize, height+3*pxsize, pxsize, 3*pxsize);
|
||||
this.game.ctx.fillRect(width+10*pxsize, height+2*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+pxsize, height+2*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+2*pxsize, height+pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+4*pxsize, height+2*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+5*pxsize, height+3*pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+7*pxsize, height+2*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+8*pxsize, height+pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+pxsize, height+6*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+2*pxsize, height+7*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+3*pxsize, height+8*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+4*pxsize, height+9*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+5*pxsize, height+10*pxsize, 2*pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+7*pxsize, height+9*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+8*pxsize, height+8*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+9*pxsize, height+7*pxsize, pxsize, pxsize);
|
||||
this.game.ctx.fillRect(width+10*pxsize, height+6*pxsize, pxsize, pxsize);
|
||||
}
|
||||
break;
|
||||
case tiles.ORANGE:
|
||||
this.game.ctx.fillStyle = "#ff7500";
|
||||
|
|
Reference in a new issue