more images (dead miner, winning miner), fix bug with beard growth

This commit is contained in:
Stefan Bühler 2012-07-15 12:36:12 +02:00
parent 1d44821af8
commit 1a69b4673a
10 changed files with 78 additions and 27 deletions

View File

@ -16,7 +16,7 @@ maps.js: FORCE
SPRITES=earth.png empty.png lambda.png lift.png openlift.png miner.png rock.png bricks.png
SPRITES+=$(wildcard trampoline?.png)
SPRITES+=$(wildcard target?.png)
SPRITES+=beard.png razor.png
SPRITES+=beard.png razor.png deadminer.png minerlift.png
sprites.png: $(SPRITES)
convert -background "#000000" -append $(SPRITES) tmp_sprites.png

BIN
js/deadminer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

View File

@ -1,4 +1,4 @@
var mineGui_mine = false, mineGui_curmap, mineGui_curndx, mineGui_moves = "";
var mineGui_mine = false, mineGui_curmap, mineGui_curndx, mineGui_moves = "", mineGui_mapname = '';
var mineGui_movesBackup = [];
var mineGui_customNdx = 1;
var mineGui_canvas = true;
@ -20,6 +20,34 @@ var mineGui_spriteOffset = {
'W':26,
'!':27
};
var mineGui_spriteOffset_Lost = {
'R': 28,
'#': 7,
'*': 6,
'\\': 2,
'L': 3,
'O': 4,
'.': 0,
' ': 1,
'A': 8,'B': 9,'C':10,'D':11,'E':12,'F':13,'G':14,'H':15,'I':16,
'1':17,'2':18,'3':19,'4':20,'5':21,'6':22,'7':23,'8':24,'9':25,
'W':26,
'!':27
};
var mineGui_spriteOffset_Won = {
'R': 29,
'#': 7,
'*': 6,
'\\': 2,
'L': 3,
'O': 29,
'.': 0,
' ': 1,
'A': 8,'B': 9,'C':10,'D':11,'E':12,'F':13,'G':14,'H':15,'I':16,
'1':17,'2':18,'3':19,'4':20,'5':21,'6':22,'7':23,'8':24,'9':25,
'W':26,
'!':27
};
var mineGui_images = {};
var mineGui_imagesNeed = 0;
@ -46,7 +74,7 @@ function mineGui_start() {
document.getElementById("mineGui_addData").onclick = mineGui_addCustomMap;
selMap.onchange = function() {
var k = selMap.options[selMap.selectedIndex].text;
mineGui_setMap(mineMaps[k], selMap.selectedIndex);
mineGui_setMap(k, selMap.selectedIndex);
selMap.blur();
};
var inpValidate = function() {
@ -129,16 +157,30 @@ function mineGui_start() {
mineGui_loadImg(k, mineGui_imgSources[k]);
}
}
var fragment = window.location.hash.slice(1).split(';');
var searchMap = fragment[0];
var loadMoves = '';
var selectIndex = 0;
for (k in mineMaps) {
if (mineMaps.hasOwnProperty(k)) {
var entry = document.createElement("option");
entry.textContent = k;
if (k === searchMap) {
// console.log("selected map " + k);
selectIndex = selMap.options.length;
if (fragment.length > 1) loadMoves = fragment[1];
}
selMap.appendChild(entry);
}
//entry.add
}
selMap.selectedIndex = 0;
selMap.selectedIndex = selectIndex;
selMap.onchange();
if (loadMoves !== '') {
// console.log("preset moves: " + loadMoves);
inpMoves.value = loadMoves;
inpMoves.onchange();
}
}
function mineGui_addCustomMap() {
@ -174,10 +216,12 @@ function mineGui_move(cmd) {
}
function mineGui_setMap(map, ndx) {
mineGui_mapname = map;
mineGui_movesBackup[mineGui_curndx] = mineGui_moves;
mineGui_curmap = map;
mineGui_curmap = mineMaps[map];
mineGui_curndx = ndx;
mineGui_moves = mineGui_movesBackup[mineGui_curndx];
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
if (!mineGui_moves) mineGui_moves = "";
mineGui_updateMine();
}
@ -197,6 +241,27 @@ function mineGui_updateMine() {
function mineGui_show() {
if (!mineGui_mine) return;
location.href = '#' + mineGui_mapname + ';' + mineGui_moves;
var state = "";
var spriteOffset = mineGui_spriteOffset;
switch (mineGui_mine.state) {
case Mine.ALIVE:
state = "Still mining";
break;
case Mine.LOST:
state = "Robot broken - " + mineGui_mine.reason;
spriteOffset = mineGui_spriteOffset_Lost;
break;
case Mine.ABORTED:
state = "Aborted";
break;
case Mine.WON:
state = "Won - " + mineGui_mine.reason;
spriteOffset = mineGui_spriteOffset_Won;
break;
}
var waterLevel = Math.max(mineGui_mine.water_level, 0);
var map = mineGui_mine.toString().split(/\n/);
var canv = document.getElementById("mineGui_mineCanvas");
@ -216,7 +281,7 @@ function mineGui_show() {
for (var y = 0; y < mineGui_mine.height; ++y) {
for (var x = 0; x < mineGui_mine.width; ++x) {
ctx.drawImage(sprites, 0, mineGui_spriteOffset[map[y][x]] * 16, 16, 16, 16*x, 16*y, 16, 16);
ctx.drawImage(sprites, 0, spriteOffset[map[y][x]] * 16, 16, 16, 16*x, 16*y, 16, 16);
}
}
ctx.fillStyle = "#0000FF";
@ -238,21 +303,6 @@ function mineGui_show() {
document.getElementById("mineGui_mineMapDry").textContent = map.join("\n");
document.getElementById("mineGui_moves").value = mineGui_moves;
var state = "";
switch (mineGui_mine.state) {
case Mine.ALIVE:
state = "Still mining";
break;
case Mine.LOST:
state = "Robot broken - " + mineGui_mine.reason;
break;
case Mine.ABORTED:
state = "Aborted";
break;
case Mine.WON:
state = "Won - " + mineGui_mine.reason;
break;
}
document.getElementById("mineGui_meta").textContent = mineGui_mine.metaText();
document.getElementById("mineGui_state").textContent = state;
document.getElementById("mineGui_score").textContent = mineGui_mine.score;

2
js/gui.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -154,7 +154,6 @@ var Mine = function() {
}
this.water_level = this.water.level;
this.razors = this.beard.razors;
this.beard_growth = this.beard.growth;
this.state = ALIVE;
};
@ -301,15 +300,17 @@ var Mine = function() {
}
this.moves++;
if (0 == this.lambdas) {
if (false !== this.lift && 'L' == this.map[this.lift.y][this.lift.x]) {
if (false !== this.lift) {
/* skip 'L' == this.map[this.lift.y][this.lift.x] - official validator replaces
* 'R' with 'O' after the last move too
*/
this.map[this.lift.y][this.lift.x] = 'O';
}
}
newMap = [];
growBeard = false;
if (0 > --this.beard_growth) {
this.beard_growth = this.beard.growth;
if (this.beard.growth > 0 && 0 == (this.moves % this.beard.growth)) {
growBeard = true;
}
for (y = 0; y < map.length; ++y) { newMap[y] = this.map[y].slice(); }

2
js/mine.min.js vendored

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 179 B

BIN
js/minerlift.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 963 B