From 4d34b0b4b890e957030fbf6e3c8e1d4a02d2a627 Mon Sep 17 00:00:00 2001 From: phat_sumo Date: Fri, 1 Apr 2022 17:49:20 -0600 Subject: [PATCH] update bootstrap, fix flag.js filename, add rock --- src/bootstrap.js | 26 +++++++++++++++++++++++--- src/entities/flag.js | 13 +++++++++++++ src/game.js | 5 +++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/entities/flag.js diff --git a/src/bootstrap.js b/src/bootstrap.js index d18442a..657067c 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -2,8 +2,28 @@ game.bootstrap = (() => { const scripts = [ { src: ['src/render/graphics.js'], id: 'render' }, { src: ['src/components/component.js', 'src/components/position.js', 'src/components/appearence.js'], id: 'components' }, - { src: ['src/entities/entity.js'], id: 'entity' }, - { src: ['src/entities/bigblue.js'], id: 'entities' }, + { src: ['src/entities/entity.js'], id: 'entity' }, + { src: ['src/entities/bigblue.js'], id: 'entities' }, + { src: ['src/entities/flag.js'], id: 'entities' }, + { src: ['src/entities/floor.js'], id: 'entities' }, + { src: ['src/entities/grass.js'], id: 'entities' }, + { src: ['src/entities/hedge.js'], id: 'entities' }, + { src: ['src/entities/liquid.js'], id: 'entities' }, + { src: ['src/entities/rock.js'], id: 'entities' }, + { src: ['src/entities/wall.js'], id: 'entities' }, + { src: ['src/entities/wordBigBlue.js'], id: 'entities' }, + { src: ['src/entities/wordFlag.js'], id: 'entities' }, + { src: ['src/entities/wordIs.js'], id: 'entities' }, + { src: ['src/entities/wordKill.js'], id: 'entities' }, + { src: ['src/entities/wordLava.js'], id: 'entities' }, + { src: ['src/entities/wordPush.js'], id: 'entities' }, + { src: ['src/entities/wordRock.js'], id: 'entities' }, + { src: ['src/entities/wordSink.js'], id: 'entities' }, + { src: ['src/entities/wordStop.js'], id: 'entities' }, + { src: ['src/entities/wordWall.js'], id: 'entities' }, + { src: ['src/entities/wordWater.js'], id: 'entities' }, + { src: ['src/entities/wordWin.js'], id: 'entities' }, + { src: ['src/entities/wordYou.js'], id: 'entities' }, { src: ['src/systems/render.js'], id: 'systems' }, { src: ['src/game.js'], id: 'game' }, ]; @@ -64,4 +84,4 @@ game.bootstrap = (() => { loadAssets().then(() => { loadScripts(() => game.initialize()); }) -})(); \ No newline at end of file +})(); diff --git a/src/entities/flag.js b/src/entities/flag.js new file mode 100644 index 0000000..b7115d2 --- /dev/null +++ b/src/entities/flag.js @@ -0,0 +1,13 @@ +game.createFlag = () => { + const flag = game.Entity(); + flag.addComponent(game.components.Position({x: 0, y: 0})); + flag.addComponent(game.components.Appearance({rot: 0, width: 100, height: 100})); + flag.sprite = game.graphics.Sprite({ + image: game.assets.flag, + spriteHeight: 24, + spriteWidth: 24, + numFrames: 3, + timePerFrame: 100, + }); + return flag; +} diff --git a/src/game.js b/src/game.js index c1b9c05..cd82cc0 100644 --- a/src/game.js +++ b/src/game.js @@ -11,5 +11,10 @@ game.initialize = () => { game.bigBlue2 = game.createBigBlue(); game.bigBlue2.components.position = game.components.Position({x: 200, y: 100}); game.entities[game.bigBlue2.id] = game.bigBlue2; + + game.rock = game.createRock(); + game.rock.components.position = game.components.Position({x: 200, y: 200}); + game.entities[game.rock.id] = game.rock; + requestAnimationFrame(game.loop); }