diff --git a/Makefile b/Makefile index 88e67c1..c16c086 100755 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: build stat clean build: rm -f muri-src.zip muri.zip src/muri.min.js uglifyjs --compress --mangle --no-dead-code --output src/muri.min.js src/*.js - (cd src/assets/images; for i in `ls *.png`; do pngcrush -brute -reduce_palette -ow $$i; done) + #(cd src/assets/images; for i in `ls *.png`; do pngcrush -brute -reduce_palette -ow $$i; done) (cd src && zip -q -9 ../muri.zip index.html muri.min.js assets/* assets/**/* vendor/*.min.js) (cd src && zip -q -9 ../muri-src.zip ./* ./**/* ./**/**/* ../README) diff --git a/src/assets/images/door_sheet.png b/src/assets/images/door_sheet.png index e519af7..bfec54b 100644 Binary files a/src/assets/images/door_sheet.png and b/src/assets/images/door_sheet.png differ diff --git a/src/assets/images/keycard.png b/src/assets/images/keycard.png new file mode 100644 index 0000000..328afc0 Binary files /dev/null and b/src/assets/images/keycard.png differ diff --git a/src/assets/images/room_engine.png b/src/assets/images/room_engine.png index 4ee2cd1..c017244 100644 Binary files a/src/assets/images/room_engine.png and b/src/assets/images/room_engine.png differ diff --git a/src/assets/images/room_hydro.png b/src/assets/images/room_hydro.png index 5be9bd3..0886c73 100644 Binary files a/src/assets/images/room_hydro.png and b/src/assets/images/room_hydro.png differ diff --git a/src/assets/images/room_lift.png b/src/assets/images/room_lift.png index 1458908..d7116de 100644 Binary files a/src/assets/images/room_lift.png and b/src/assets/images/room_lift.png differ diff --git a/src/assets/images/room_stasis.png b/src/assets/images/room_stasis.png index 72f24c3..40f7967 100644 Binary files a/src/assets/images/room_stasis.png and b/src/assets/images/room_stasis.png differ diff --git a/src/assets/images/room_stasis_dark.png b/src/assets/images/room_stasis_dark.png index cca8fc7..f8c77ef 100644 Binary files a/src/assets/images/room_stasis_dark.png and b/src/assets/images/room_stasis_dark.png differ diff --git a/src/assets/images/toggleSwitch_sheet.png b/src/assets/images/toggleSwitch_sheet.png new file mode 100644 index 0000000..bbe4f33 Binary files /dev/null and b/src/assets/images/toggleSwitch_sheet.png differ diff --git a/src/index_dev.html b/src/index_dev.html index 9ed9e3a..f16cc0d 100644 --- a/src/index_dev.html +++ b/src/index_dev.html @@ -1,5 +1,4 @@ -

murĂ­

a js13kgame by Aaron Fischer (2017)

@@ -16,7 +15,6 @@ - diff --git a/src/muri.js b/src/muri.js index 8cbee96..cb105b1 100644 --- a/src/muri.js +++ b/src/muri.js @@ -98,12 +98,13 @@ var muri = (function() { }); }; - muri.end = function(reason) { + muri.end = function(reason, again) { muri.changeRoom('end'); muri.get('bubble') .talk(reason, [20, 20]) .then(function() { - document.getElementById('tryagain').style.display = 'block'; + if (again) + document.getElementById('tryagain').style.display = 'block'; }); }; @@ -114,6 +115,8 @@ var muri = (function() { 'room_engine.png', 'room_hydro.png', 'door_sheet.png', + 'toggleSwitch_sheet.png', + 'keycard.png', 'laser_sheet.png', 'stasis_lightSwitch.png', 'room_lift.png', @@ -129,7 +132,8 @@ var muri = (function() { kontra.gameLoop({ update: function() { - muri.room(muri.currentRoom).update(); + var r = muri.room(muri.currentRoom); + if (r.update !== undefined) r.update(); muri.modules.forEach(function(m) { if (m.update !== undefined) m.update(); }); @@ -140,7 +144,8 @@ var muri = (function() { } }, render: function() { - muri.room(muri.currentRoom).render(); + var r = muri.room(muri.currentRoom); + if (r.render !== undefined) r.render(); muri.modules.forEach(function(m) { if (m.render !== undefined && m.name !== 'entity') m.render(); diff --git a/src/room_end.js b/src/room_end.js index 6aecb80..d94d3cb 100644 --- a/src/room_end.js +++ b/src/room_end.js @@ -1,12 +1,4 @@ (function() { 'use strict'; - - var end = {}; - - end.init = function() {}; - end.update = function() {}; - end.render = function() {}; - - end.name = 'end'; - muri.rooms.push(end); + muri.rooms.push({name: 'end'}); }()); diff --git a/src/room_engine.js b/src/room_engine.js index c4172df..16eca5c 100644 --- a/src/room_engine.js +++ b/src/room_engine.js @@ -6,7 +6,7 @@ var background, door, lasers = null; var roomState = { firstVisit: true, - engineBroken: true, + engineBroken: false, //true, laserStates: [0, 0, 0] }; @@ -88,13 +88,11 @@ randomSounds(); }; - engine.update = function() { - }; - engine.render = function() { background.render(); }; engine.name = 'engine'; + engine.roomState = roomState; muri.rooms.push(engine); }()); diff --git a/src/room_hydro.js b/src/room_hydro.js index cb0a43d..2e5f4f8 100644 --- a/src/room_hydro.js +++ b/src/room_hydro.js @@ -3,22 +3,29 @@ var hydro = {}; - var background, door = null; - var roomState = { - }; + var background, door, keycard = null; hydro.init = function() { background = muri.bg('hydro'); door = muri.door('hydro', [38, 9]); + keycard = muri.get('entity') + .create('hydro.keycard', kontra.sprite({x: 55, y: 28, image: kontra.assets.images.keycard})) + .addCallback(function() { + muri.get('bubble') + .talk([ + 'Thats interesting ... ', + 'The keycard from the captain.', + 'That can be handy some day.' + ]); + muri.room('lift').roomState.bridgeAccessible = true; + muri.get('entity').get('hydro.keycard').invisible = true; + }); }; hydro.onEnter = function() { door.sprite.playAnimation('close'); }; - hydro.update = function() { - }; - hydro.render = function() { background.render(); }; diff --git a/src/room_lift.js b/src/room_lift.js index d4bcbd5..39c0450 100644 --- a/src/room_lift.js +++ b/src/room_lift.js @@ -10,7 +10,6 @@ hydroDoorBroken: true }; - var createButtonEntity = function(i, room) { var e = muri.get('entity') .create('lift.button'+i, @@ -18,19 +17,33 @@ animations: buttonSheet.animations})) .addCallback(function() { buttons.forEach(function(b) { b.sprite.playAnimation('off'); }); - - if (room === 'bridge' && !roomState.bridgeAccessible) { - muri.get('bubble') - .talk([ - 'The bridge is not accessible.', - 'You have no sufficient permission to do that.']); + if (room === 'bridge') { + if (!roomState.bridgeAccessible) { + muri.get('bubble') + .talk([ + 'The bridge is not accessible.', + 'You have no sufficient permission to do that.']); + } else { + muri.end([ + 'You\'ve made it all the way to the bridge.', + 'The engine is running fine.', + 'You can finally head home and leave this rotten ship.', + '... ', + 'You crank the throttle all the way up.', + '...', + '...', + 'The ship burst apart.', + 'You are lost.', + 'Lost from the very beginning.' + ], false); + } return; } if (room === 'hydro' && roomState.hydroDoorBroken) { muri.get('bubble') .talk([ - 'The hyperlift moved, but to door to the hydro deck does not open.', + 'The hyperlift moved, but the door to the hydro deck does not open.', 'You can\'t access this deck with a broken door.' ]); return; @@ -42,7 +55,7 @@ 'Which is broken on this ship.', 'It takes no more than a second to drag you into space.', 'You are lost ... ....', - '... and die.']); + '... and die.'], true); return; } @@ -94,12 +107,11 @@ muri.get('bubble').talk([welcomeMessage]); }; - lift.update = function() {}; - lift.render = function() { background.render(); }; lift.name = 'lift'; + lift.roomState = roomState; muri.rooms.push(lift); }()); diff --git a/src/room_stasis.js b/src/room_stasis.js index ce11416..691523e 100644 --- a/src/room_stasis.js +++ b/src/room_stasis.js @@ -4,11 +4,61 @@ var stasis = {}; var background, backgroundDark = null; - var door = null; + var door, liftBox = null; var roomState = { isDoorOpen: false, - isLightOn: false, - isIntroRunning: true + isLightOn: true, //false + isIntroRunning: false, //true + hydroDoorBroken: false, // true + liftSwitches: ['off', 'off', 'off', 'off', 'off'] + }; + + var toggleLiftSwitch = function(i) { + if (!roomState.hydroDoorBroken) return; + var state = roomState.liftSwitches[i]; + var newState = state == 'on' ? 'off' : 'on'; + muri.get('entity').get('stasis.liftSwitch'+i).sprite.playAnimation(newState); + roomState.liftSwitches[i] = newState; + }; + + var liftSwitch = function(i) { + var switchAnimation = kontra.spriteSheet({ + image: kontra.assets.images.toggleSwitch_sheet, + frameWidth: 2, frameHeight: 1, + animations: { + 'off': {frames: 0}, + 'on': {frames: 1} + } + }); + var liftSwitch = kontra.sprite({ + x: 95, y: 16+i*2, + animations: switchAnimation.animations + }); + + return muri.get('entity') + .create('stasis.liftSwitch'+i, liftSwitch) + .addCallback(function() { + toggleLiftSwitch(i); + var randomSwitch = Math.floor(Math.random()*roomState.liftSwitches.length); + if (randomSwitch !== i) + toggleLiftSwitch(randomSwitch); + + var solved = true; + console.log(roomState.liftSwitches); + roomState.liftSwitches.forEach(function(s) { + console.log(s); + if (s === 'off') solved = false; + }); + if (solved) { + muri.get('bubble') + .talk([ + 'Once again, the ship shakes like crazy.', + 'Something broke or looses inside the lift and metal scrapes against the hull.', + 'Not sure if this is a good sign ...']); + muri.room('lift').roomState.hydroDoorBroken = false; + roomState.hydroDoorBroken = false; + } + }); }; stasis.init = function() { @@ -66,13 +116,22 @@ ]); }) .invisible = true; - + } + + if (!muri.room('engine').roomState.engineBroken && !liftBox) { + liftBox = kontra.sprite({x: 94, y: 15, width: 4, height: 11, color: '#000'}); + liftSwitch(0); + liftSwitch(1); + liftSwitch(2); + liftSwitch(3); + liftSwitch(4); } }; stasis.render = function() { if (roomState.isLightOn) { background.render(); + if (liftBox) liftBox.render(); } else { backgroundDark.render(); }