|
@ -337,25 +337,20 @@ class CharacterSprite { |
|
|
|
|
|
|
|
|
class Resources { |
|
|
class Resources { |
|
|
constructor() { |
|
|
constructor() { |
|
|
const atlantis = document.getElementById('atlantis'); |
|
|
|
|
|
|
|
|
const terrain = document.getElementById('terrain'); |
|
|
|
|
|
const witch = document.getElementById('witch'); |
|
|
const spritesheet = document.getElementById('spritesheet'); |
|
|
const spritesheet = document.getElementById('spritesheet'); |
|
|
const ts = 16; |
|
|
const ts = 16; |
|
|
this.sprites = { |
|
|
this.sprites = { |
|
|
'ground0': new Sprite(atlantis, 2 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground1': new Sprite(atlantis, 3 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground2': new Sprite(atlantis, 4 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground3': new Sprite(atlantis, 5 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground4': new Sprite(atlantis, 6 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground5': new Sprite(atlantis, 7 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground6': new Sprite(atlantis, 8 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'rock0': new Sprite(atlantis, 1 * ts, 2 * ts, 16, 16), |
|
|
|
|
|
'rock1': new Sprite(atlantis, 2 * ts, 2 * ts, 16, 16), |
|
|
|
|
|
'rock2': new Sprite(atlantis, 3 * ts, 2 * ts, 16, 16), |
|
|
|
|
|
'anchor0': new Sprite(atlantis, 21 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'seaweed0': new Sprite(atlantis, 20 * ts, 2 * ts, 16, 32), |
|
|
|
|
|
'seaweed1': new Sprite(atlantis, 16 * ts, 2 * ts, 16, 32), |
|
|
|
|
|
'coral0': new Sprite(atlantis, 15 * ts, 9 * ts, 32, 16), |
|
|
|
|
|
'rockpile0': new Sprite(atlantis, 17 * ts, 10 * ts, 32, 32), |
|
|
|
|
|
|
|
|
'ground0': new Sprite(terrain, 2 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground1': new Sprite(terrain, 3 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground2': new Sprite(terrain, 4 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground3': new Sprite(terrain, 5 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground4': new Sprite(terrain, 6 * ts, 1 * ts, 16, 16), |
|
|
|
|
|
'ground5': new Sprite(terrain, 2 * ts, 2 * ts, 16, 16), |
|
|
|
|
|
'ground6': new Sprite(terrain, 6 * ts, 2 * ts, 16, 16), |
|
|
|
|
|
'cauldron_blue': new Sprite(witch, 0, 0, 32, 32), |
|
|
|
|
|
'cauldron_green': new Sprite(witch, 32, 0, 32, 32), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (const key in spritesheet_json) { |
|
|
for (const key in spritesheet_json) { |
|
@ -372,7 +367,7 @@ class Player { |
|
|
// TODO: stop hard-coding player bounding box.
|
|
|
// TODO: stop hard-coding player bounding box.
|
|
|
constructor() { |
|
|
constructor() { |
|
|
this.x = (SNES_WIDTH - 26) / 2; |
|
|
this.x = (SNES_WIDTH - 26) / 2; |
|
|
this.y = (SNES_HEIGHT - 36) / 2; |
|
|
|
|
|
|
|
|
this.y = (SNES_HEIGHT - 36) / 2 - 28; |
|
|
this.orientation = Orientation.DOWN; |
|
|
this.orientation = Orientation.DOWN; |
|
|
this.spriteNames_ = []; |
|
|
this.spriteNames_ = []; |
|
|
for (const name in spritesheet_json) { |
|
|
for (const name in spritesheet_json) { |
|
@ -442,38 +437,39 @@ class PlayerRenderer { |
|
|
class TileRenderer { |
|
|
class TileRenderer { |
|
|
draw(gfx, sprites) { |
|
|
draw(gfx, sprites) { |
|
|
const tileSize = 16; |
|
|
const tileSize = 16; |
|
|
|
|
|
// The screen is 14 x 16 tiles by default.
|
|
|
const rows = gfx.height / tileSize; |
|
|
const rows = gfx.height / tileSize; |
|
|
const columns = gfx.width / tileSize; |
|
|
const columns = gfx.width / tileSize; |
|
|
const layer1 = ["-,*-...*'.,-_'`o", |
|
|
|
|
|
"_..'-_**,',_.'oo", |
|
|
|
|
|
"-*-''_-'o,0O_```", |
|
|
|
|
|
"o`0_._,*O'`--'-'", |
|
|
|
|
|
"`0O-_'',`o*o*`-,", |
|
|
|
|
|
"*,`'---o'O'_*''-", |
|
|
|
|
|
"'-.**.'_'`.,'-.'", |
|
|
|
|
|
".O'``*``'`*,,_o`", |
|
|
|
|
|
"_*_''*O'`_OO-_'o", |
|
|
|
|
|
"0`0,*-,`_*'`O'*.", |
|
|
|
|
|
".o'-*.*_',`,,`.'", |
|
|
|
|
|
"`o`O',.`OO,*-'**", |
|
|
|
|
|
"-..*'-''',*'.'.O", |
|
|
|
|
|
"*-_'-0.--__O`O`_", |
|
|
|
|
|
"*-_,O_'*'`*'_._.", |
|
|
|
|
|
"-.*,`OO'_`'*-0-O"]; |
|
|
|
|
|
const layer2 = [" ", |
|
|
|
|
|
|
|
|
const layer1 = [ |
|
|
|
|
|
".'...__,._..*..`", |
|
|
|
|
|
"*'..,_.--.,.*..`", |
|
|
|
|
|
"_._.*._.,.--,._.", |
|
|
|
|
|
"._``_.,_..._..``", |
|
|
|
|
|
"_,.`.....'...._`", |
|
|
|
|
|
"..`_'*...._.._..", |
|
|
|
|
|
".,'.'_-'...__.`.", |
|
|
|
|
|
".....,'...*,'..`", |
|
|
|
|
|
"__..'_......_...", |
|
|
|
|
|
"'*..``.,.,..,.,.", |
|
|
|
|
|
"...'._'*'..___..", |
|
|
|
|
|
"'._'.-....,.`.._", |
|
|
|
|
|
"_*_.*_,'-...`-..", |
|
|
|
|
|
".-...*._`,`'`.,."]; |
|
|
|
|
|
const layer2 = [ |
|
|
" ", |
|
|
" ", |
|
|
" iil ", |
|
|
|
|
|
" ", |
|
|
" ", |
|
|
" A ", |
|
|
|
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" ", |
|
|
" i ", |
|
|
|
|
|
" l ", |
|
|
|
|
|
|
|
|
" O ", |
|
|
" ", |
|
|
" ", |
|
|
" c R ", |
|
|
|
|
|
" c "]; |
|
|
|
|
|
|
|
|
" ", |
|
|
|
|
|
" ", |
|
|
|
|
|
" ", |
|
|
|
|
|
" ", |
|
|
|
|
|
" ", |
|
|
|
|
|
" "]; |
|
|
const spriteLookup = { |
|
|
const spriteLookup = { |
|
|
'.': sprites.ground0, |
|
|
'.': sprites.ground0, |
|
|
',': sprites.ground1, |
|
|
',': sprites.ground1, |
|
@ -482,14 +478,8 @@ class TileRenderer { |
|
|
'-': sprites.ground4, |
|
|
'-': sprites.ground4, |
|
|
'*': sprites.ground5, |
|
|
'*': sprites.ground5, |
|
|
"'": sprites.ground6, |
|
|
"'": sprites.ground6, |
|
|
'o': sprites.rock0, |
|
|
|
|
|
'O': sprites.rock1, |
|
|
|
|
|
'0': sprites.rock2, |
|
|
|
|
|
'A': sprites.anchor0, |
|
|
|
|
|
'i': sprites.seaweed0, |
|
|
|
|
|
'l': sprites.seaweed1, |
|
|
|
|
|
'c': sprites.coral0, |
|
|
|
|
|
'R': sprites.rockpile0, |
|
|
|
|
|
|
|
|
'O': sprites.cauldron_blue, |
|
|
|
|
|
'o': sprites.cauldron_green, |
|
|
}; |
|
|
}; |
|
|
for (let j = 0; j < columns; j++) { |
|
|
for (let j = 0; j < columns; j++) { |
|
|
for (let i = 0; i < rows; i++) { |
|
|
for (let i = 0; i < rows; i++) { |
|
|