Mercurial > mhrok3
changeset 11:fc564ddb226a
Add walls
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Tue, 30 Oct 2012 23:50:18 +0100 |
| parents | 6314a8b18d71 |
| children | c8ae248daed0 |
| files | floor.png mhrok.css mhrok.js wall.png |
| diffstat | 4 files changed, 51 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mhrok.css Tue Oct 30 22:51:16 2012 +0100 +++ b/mhrok.css Tue Oct 30 23:50:18 2012 +0100 @@ -12,7 +12,7 @@ width: 48px; height: 48px; position: absolute; - margin-top: -24px; + margin-top: -20px; margin-left: -8px; } @@ -25,16 +25,24 @@ #mhrok .mhrok-hero .mhrok-sprite { background-image: url('hero.png'); } + #mhrok .mhrok-shadow { - width: 32px; - height: 24px; - background-image: url('floor.png'); - background-position: -128px -96px; - opacity: 0.25; + width: 48px; + height: 48px; + background-image: url('wall.png'); + background-position: -48px -48px; + opacity: 0.5; position: absolute; - bottom: 0; - left: 50%; - margin-left: -16px; +} + +#mhrok .mhrok-wall .mhrok-sprite { + background-image: url('wall.png'); +} + +#mhrok .mhrok-edge .mhrok-shadow, +#mhrok .mhrok-wall .mhrok-shadow { + opacity: 0.5; + background-position: -48px -0px; } #mhrok .mhrok-map { @@ -55,9 +63,6 @@ height: 24px; background-image: url('floor.png'); } -#mhrok .mhrok-map b:hover { - opacity: 0.5; -} #mhrok .mhrok-map .mhrok-X { background-position: 0px -0;
--- a/mhrok.js Tue Oct 30 22:51:16 2012 +0100 +++ b/mhrok.js Tue Oct 30 23:50:18 2012 +0100 @@ -31,11 +31,26 @@ }; + var Wall = function (x, y, tile) { + Mob.apply(this, arguments); + this.x = x * 32; + this.y = y * 24; + this.z = this.y; + this.frameX = 0; + this.frameY = tile; + }; + Wall.prototype = Object.create(Mob.prototype); + Wall.prototype.classes += ' mhrok-wall'; + Wall.prototype.animate = function (frame) {}; + + var Hero = function () { Mob.apply(this, arguments); - this.animation = 'stand_north'; - this.direction = 'north'; + this.animation = 'stand'; + this.direction = 'south'; this.waiting = true; + this.x = 32; + this.y = 24; }; Hero.prototype = Object.create(Mob.prototype); Hero.prototype.classes += ' mhrok-hero'; @@ -104,6 +119,21 @@ }; return html; }; + Level.prototype.mobs = function () { + mobs = []; + for (var y=0; y < 20; ++y) { + for (var x=0; x < 20; ++x) { + var c = this.map[y][x]; + if (c === 'b') { + mobs.push(new Wall(x, y, 0)); + }; + if (c === 'X') { + mobs.push(new Wall(x, y, 1)); + }; + }; + }; + return mobs; + }; var Game = function (element) { @@ -220,6 +250,7 @@ Game: Game, Mob: Mob, Hero: Hero, + Wall: Wall, Level: Level, } } (); @@ -253,6 +284,7 @@ this.map_element.innerHTML = this.level.html(); this.hero = new MhrokLib.Hero(); this.mobs.push(this.hero); + this.mobs.push.apply(this.mobs, this.level.mobs()); }; Game.prototype = Object.create(MhrokLib.Game.prototype);
