use one sprite image

This commit is contained in:
Stefan Bühler 2012-07-14 17:47:05 +02:00
parent c88a39c7ac
commit 8a8caeef76

View File

@ -4,15 +4,19 @@ var mineGui_customNdx = 1;
var mineGui_canvas = true; var mineGui_canvas = true;
var mineGui_imgSources = { var mineGui_imgSources = {
'R': 'robot.png', 'sprites': 'sprites.png'
'#': 'wall.png',
'*': 'rock.png',
'\\': 'lambda.png',
'L': 'liftclosed.png',
'O': 'liftopen.png',
'.': 'earth.png',
' ': 'empty.png'
}; };
var mineGui_spriteOffset = {
'R': 5,
'#': 7,
'*': 6,
'\\': 2,
'L': 3,
'O': 4,
'.': 0,
' ': 1
};
var mineGui_images = {}; var mineGui_images = {};
var mineGui_imagesNeed = 0; var mineGui_imagesNeed = 0;
@ -203,9 +207,11 @@ function mineGui_show() {
ctx.globalAlpha=1.0; ctx.globalAlpha=1.0;
ctx.fillStyle = "black"; ctx.fillStyle = "black";
ctx.fillRect(0,0,canv.width, canv.height); ctx.fillRect(0,0,canv.width, canv.height);
var sprites = mineGui_images.sprites;
for (var y = 0; y < mineGui_mine.height; ++y) { for (var y = 0; y < mineGui_mine.height; ++y) {
for (var x = 0; x < mineGui_mine.width; ++x) { for (var x = 0; x < mineGui_mine.width; ++x) {
ctx.drawImage(mineGui_images[map[y][x]],16*x,16*y); ctx.drawImage(sprites, mineGui_spriteOffset[map[y][x]] * 16, 0, 16, 16, 16*x, 16*y, 16, 16);
} }
} }
ctx.fillStyle = "#0000FF"; ctx.fillStyle = "#0000FF";