From 66b29967e1a0c83c09da990fdb50e613a7e6caa0 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Tue, 5 Apr 2022 20:16:22 -0600 Subject: [PATCH] Finish adding all entities --- assets/.DS_Store | Bin 8196 -> 8196 bytes assets/image/.DS_Store | Bin 8196 -> 8196 bytes assets/image/{liquid.png => lava.png} | Bin assets/image/water.png | Bin 0 -> 367 bytes src/bootstrap.js | 8 ++++---- src/entities/lava.js | 15 +++++++++++++++ src/entities/liquid.js | 16 ---------------- src/entities/water.js | 14 ++++++++++++++ src/game.js | 2 +- src/render/sprites.js | 14 ++++++++++++++ src/utils/loadLevel.js | 21 +++++++++++++++++++++ 11 files changed, 69 insertions(+), 21 deletions(-) rename assets/image/{liquid.png => lava.png} (100%) create mode 100644 assets/image/water.png create mode 100644 src/entities/lava.js delete mode 100644 src/entities/liquid.js create mode 100644 src/entities/water.js diff --git a/assets/.DS_Store b/assets/.DS_Store index d6f9c0b665dd49f83db9fa54562c33f88a6dee67..004359a2824d90cfc389696f54781583dd3ecbda 100644 GIT binary patch delta 56 zcmZp1XmQx!FTl8Ma)3Y~zgTs(iH?G0t&T#qp{1eGdUBvU3g2#9Ug67*o+TrbngJh6diGrPoJb^!aX3@-ox diff --git a/assets/image/liquid.png b/assets/image/lava.png similarity index 100% rename from assets/image/liquid.png rename to assets/image/lava.png diff --git a/assets/image/water.png b/assets/image/water.png new file mode 100644 index 0000000000000000000000000000000000000000..6e89b04db0f477c37241b588bc051d9597254737 GIT binary patch literal 367 zcmV-#0g(QQP)VU(h=)gL{tAo5dJQJHyKm>O$e*2Wj6@KAtCr5Lime{YE zkpysUoH9E)soT5%_Xn4)LeKGGa^ zTsN*xIO;dr;!%SL4OExqFW!3 { { src: [ 'src/entities/bigblue.js', 'src/entities/flag.js', 'src/entities/floor.js', 'src/entities/grass.js', 'src/entities/hedge.js', - 'src/entities/liquid.js', 'src/entities/rock.js', 'src/entities/wall.js', 'src/entities/wordBigBlue.js', + 'src/entities/lava.js', 'src/entities/rock.js', 'src/entities/wall.js', 'src/entities/wordBigBlue.js', 'src/entities/wordFlag.js', 'src/entities/wordIs.js', 'src/entities/wordKill.js', 'src/entities/wordLava.js', 'src/entities/wordPush.js', 'src/entities/wordRock.js', 'src/entities/wordSink.js', 'src/entities/wordStop.js', 'src/entities/wordWall.js', 'src/entities/wordWater.js', 'src/entities/wordWin.js', 'src/entities/wordYou.js', - 'src/entities/borderParticles.js' + 'src/entities/borderParticles.js', 'src/entities/water.js' ], id: 'entities' }, @@ -39,10 +39,10 @@ game.bootstrap = (() => { ]; const assets = {}; [ - "bigblue", "flag", "floor", "grass", "hedge", "liquid", "rock", + "bigblue", "flag", "floor", "grass", "hedge", "lava", "rock", "wall", "wordBigBlue", "wordFlag", "wordIs", "wordKill", "wordLava", "wordPush", "wordRock", "wordSink", "wordStop", "wordWall", "wordWater", - "wordWin", "wordYou" + "wordWin", "wordYou", "water" ].map((x) => assets[x] = `assets/image/${x}.png`); [ "background-music", "death", "move", "win" diff --git a/src/entities/lava.js b/src/entities/lava.js new file mode 100644 index 0000000..c0389bc --- /dev/null +++ b/src/entities/lava.js @@ -0,0 +1,15 @@ +game.createLava = () => { + // TODO: Split this into two entities: water and lava + const lava = game.Entity(); + lava.addComponent(game.components.LoadPriority({priority: 5})); + lava.addComponent(game.components.Appearance({rot: 0, width: 100, height: 100})); + lava.addComponent(game.components.Alive()); + lava.sprite = game.graphics.Sprite({ + image: game.assets.lava, + spriteHeight: 24, + spriteWidth: 24, + numFrames: 3, + timePerFrame: 100, + }); + return lava; +} diff --git a/src/entities/liquid.js b/src/entities/liquid.js deleted file mode 100644 index 27026d6..0000000 --- a/src/entities/liquid.js +++ /dev/null @@ -1,16 +0,0 @@ -game.createLiquid = () => { - // TODO: Split this into two entities: water and lava - const liquid = game.Entity(); - liquid.addComponent(game.components.LoadPriority({priority: 5})); - liquid.addComponent(game.components.Position({x: 0, y: 0})); - liquid.addComponent(game.components.Appearance({rot: 0, width: 100, height: 100})); - liquid.addComponent(game.components.Alive()); - liquid.sprite = game.graphics.Sprite({ - image: game.assets.liquid, - spriteHeight: 24, - spriteWidth: 24, - numFrames: 3, - timePerFrame: 100, - }); - return liquid; -} diff --git a/src/entities/water.js b/src/entities/water.js new file mode 100644 index 0000000..abefd3f --- /dev/null +++ b/src/entities/water.js @@ -0,0 +1,14 @@ +game.createWater = () => { + const water = game.Entity(); + water.addComponent(game.components.LoadPriority({priority: 5})); + water.addComponent(game.components.Appearance({rot: 0, width: 100, height: 100})); + water.addComponent(game.components.Alive()); + water.sprite = game.graphics.Sprite({ + image: game.assets.water, + spriteHeight: 24, + spriteWidth: 24, + numFrames: 3, + timePerFrame: 100, + }); + return water; +} diff --git a/src/game.js b/src/game.js index f649ba5..50db687 100644 --- a/src/game.js +++ b/src/game.js @@ -21,7 +21,7 @@ game.loop = (timeStamp) => { } game.initialize = () => { - [game.entities, game.config] = game.loadLevel(game.levels[0]); + [game.entities, game.config] = game.loadLevel(game.levels[4]); // Maintained by gridSystem as a side-effect game.entitiesGrid = Array(game.config.yDim).fill(null).map(() => Array(game.config.xDim).fill(null).map(() => new Map())); diff --git a/src/render/sprites.js b/src/render/sprites.js index 286da4c..d8ae126 100644 --- a/src/render/sprites.js +++ b/src/render/sprites.js @@ -34,6 +34,13 @@ game.sprites = { numFrames: 3, timePerFrame: 100, }), + lava: game.graphics.Sprite({ + image: game.assets.lava, + spriteHeight: 24, + spriteWidth: 24, + numFrames: 3, + timePerFrame: 100, + }), rock: game.graphics.Sprite({ image: game.assets.rock, spriteHeight: 24, @@ -48,6 +55,13 @@ game.sprites = { numFrames: 3, timePerFrame: 100, }), + water: game.graphics.Sprite({ + image: game.assets.water, + spriteHeight: 24, + spriteWidth: 24, + numFrames: 3, + timePerFrame: 100, + }), wordBigBlue: game.graphics.Sprite({ image: game.assets.wordBigBlue, spriteHeight: 24, diff --git a/src/utils/loadLevel.js b/src/utils/loadLevel.js index 4f0c701..3bd86d9 100644 --- a/src/utils/loadLevel.js +++ b/src/utils/loadLevel.js @@ -19,12 +19,33 @@ game.loadLevel = (level) => { case 'f': entity = game.createFlag(); break; + case 'g': + entity = game.createGrass(); + break; case 'l': entity = game.createFloor(); break; case 'w': entity = game.createWall(); break; + case 'a': + entity = game.createWater(); + break; + case 'A': + entity = game.createWordWater(); + break; + case 'N': + entity = game.createWordSink(); + break; + case 'V': + entity = game.createWordLava(); + break; + case 'v': + entity = game.createLava(); + break; + case 'K': + entity = game.createWordKill(); + break; case 'W': entity = game.createWordWall(); break;