Finish ... kind of ... now some space reduction

This commit is contained in:
Aaron Fischer 2017-09-13 11:16:39 +02:00
parent 3df5f0d766
commit 62149c058f
16 changed files with 112 additions and 41 deletions

View file

@ -5,7 +5,7 @@ all: build stat clean
build: build:
rm -f muri-src.zip muri.zip src/muri.min.js rm -f muri-src.zip muri.zip src/muri.min.js
uglifyjs --compress --mangle --no-dead-code --output src/muri.min.js src/*.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.zip index.html muri.min.js assets/* assets/**/* vendor/*.min.js)
(cd src && zip -q -9 ../muri-src.zip ./* ./**/* ./**/**/* ../README) (cd src && zip -q -9 ../muri-src.zip ./* ./**/* ./**/**/* ../README)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 507 B

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

View file

@ -1,5 +1,4 @@
<link rel="stylesheet" href="assets/styles.css"></link> <link rel="stylesheet" href="assets/styles.css"></link>
<h1>murí</h1>
<p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p> <p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p>
<div id="content"> <div id="content">
@ -16,7 +15,6 @@
<script src="entity.js"></script> <script src="entity.js"></script>
<script src="bubble.js"></script> <script src="bubble.js"></script>
<script src="mouse.js"></script> <script src="mouse.js"></script>
<script src="room_bridge.js"></script>
<script src="room_engine.js"></script> <script src="room_engine.js"></script>
<script src="room_hydro.js"></script> <script src="room_hydro.js"></script>
<script src="room_lift.js"></script> <script src="room_lift.js"></script>

View file

@ -98,11 +98,12 @@ var muri = (function() {
}); });
}; };
muri.end = function(reason) { muri.end = function(reason, again) {
muri.changeRoom('end'); muri.changeRoom('end');
muri.get('bubble') muri.get('bubble')
.talk(reason, [20, 20]) .talk(reason, [20, 20])
.then(function() { .then(function() {
if (again)
document.getElementById('tryagain').style.display = 'block'; document.getElementById('tryagain').style.display = 'block';
}); });
}; };
@ -114,6 +115,8 @@ var muri = (function() {
'room_engine.png', 'room_engine.png',
'room_hydro.png', 'room_hydro.png',
'door_sheet.png', 'door_sheet.png',
'toggleSwitch_sheet.png',
'keycard.png',
'laser_sheet.png', 'laser_sheet.png',
'stasis_lightSwitch.png', 'stasis_lightSwitch.png',
'room_lift.png', 'room_lift.png',
@ -129,7 +132,8 @@ var muri = (function() {
kontra.gameLoop({ kontra.gameLoop({
update: function() { update: function() {
muri.room(muri.currentRoom).update(); var r = muri.room(muri.currentRoom);
if (r.update !== undefined) r.update();
muri.modules.forEach(function(m) { muri.modules.forEach(function(m) {
if (m.update !== undefined) m.update(); if (m.update !== undefined) m.update();
}); });
@ -140,7 +144,8 @@ var muri = (function() {
} }
}, },
render: 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) { muri.modules.forEach(function(m) {
if (m.render !== undefined && m.name !== 'entity') if (m.render !== undefined && m.name !== 'entity')
m.render(); m.render();

View file

@ -1,12 +1,4 @@
(function() { (function() {
'use strict'; 'use strict';
muri.rooms.push({name: 'end'});
var end = {};
end.init = function() {};
end.update = function() {};
end.render = function() {};
end.name = 'end';
muri.rooms.push(end);
}()); }());

View file

@ -6,7 +6,7 @@
var background, door, lasers = null; var background, door, lasers = null;
var roomState = { var roomState = {
firstVisit: true, firstVisit: true,
engineBroken: true, engineBroken: false, //true,
laserStates: [0, 0, 0] laserStates: [0, 0, 0]
}; };
@ -88,13 +88,11 @@
randomSounds(); randomSounds();
}; };
engine.update = function() {
};
engine.render = function() { engine.render = function() {
background.render(); background.render();
}; };
engine.name = 'engine'; engine.name = 'engine';
engine.roomState = roomState;
muri.rooms.push(engine); muri.rooms.push(engine);
}()); }());

View file

@ -3,22 +3,29 @@
var hydro = {}; var hydro = {};
var background, door = null; var background, door, keycard = null;
var roomState = {
};
hydro.init = function() { hydro.init = function() {
background = muri.bg('hydro'); background = muri.bg('hydro');
door = muri.door('hydro', [38, 9]); 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() { hydro.onEnter = function() {
door.sprite.playAnimation('close'); door.sprite.playAnimation('close');
}; };
hydro.update = function() {
};
hydro.render = function() { hydro.render = function() {
background.render(); background.render();
}; };

View file

@ -10,7 +10,6 @@
hydroDoorBroken: true hydroDoorBroken: true
}; };
var createButtonEntity = function(i, room) { var createButtonEntity = function(i, room) {
var e = muri.get('entity') var e = muri.get('entity')
.create('lift.button'+i, .create('lift.button'+i,
@ -18,19 +17,33 @@
animations: buttonSheet.animations})) animations: buttonSheet.animations}))
.addCallback(function() { .addCallback(function() {
buttons.forEach(function(b) { b.sprite.playAnimation('off'); }); buttons.forEach(function(b) { b.sprite.playAnimation('off'); });
if (room === 'bridge') {
if (room === 'bridge' && !roomState.bridgeAccessible) { if (!roomState.bridgeAccessible) {
muri.get('bubble') muri.get('bubble')
.talk([ .talk([
'The bridge is not accessible.', 'The bridge is not accessible.',
'You have no sufficient permission to do that.']); '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; return;
} }
if (room === 'hydro' && roomState.hydroDoorBroken) { if (room === 'hydro' && roomState.hydroDoorBroken) {
muri.get('bubble') muri.get('bubble')
.talk([ .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.' 'You can\'t access this deck with a broken door.'
]); ]);
return; return;
@ -42,7 +55,7 @@
'Which is broken on this ship.', 'Which is broken on this ship.',
'It takes no more than a second to drag you into space.', 'It takes no more than a second to drag you into space.',
'You are lost ... ....', 'You are lost ... ....',
'... and die.']); '... and die.'], true);
return; return;
} }
@ -94,12 +107,11 @@
muri.get('bubble').talk([welcomeMessage]); muri.get('bubble').talk([welcomeMessage]);
}; };
lift.update = function() {};
lift.render = function() { lift.render = function() {
background.render(); background.render();
}; };
lift.name = 'lift'; lift.name = 'lift';
lift.roomState = roomState;
muri.rooms.push(lift); muri.rooms.push(lift);
}()); }());

View file

@ -4,11 +4,61 @@
var stasis = {}; var stasis = {};
var background, backgroundDark = null; var background, backgroundDark = null;
var door = null; var door, liftBox = null;
var roomState = { var roomState = {
isDoorOpen: false, isDoorOpen: false,
isLightOn: false, isLightOn: true, //false
isIntroRunning: true 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() { stasis.init = function() {
@ -66,13 +116,22 @@
]); ]);
}) })
.invisible = true; .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() { stasis.render = function() {
if (roomState.isLightOn) { if (roomState.isLightOn) {
background.render(); background.render();
if (liftBox) liftBox.render();
} else { } else {
backgroundDark.render(); backgroundDark.render();
} }