cleaned up codebase from not needed experimental code and styles

This commit is contained in:
Patryk Hegenberg 2023-01-10 07:40:23 +01:00
parent 4991e28180
commit 8fd71ae57a
3 changed files with 6 additions and 135 deletions

View file

@ -48,10 +48,9 @@
height: 40, height: 40,
}; };
const usePointer = true; //const usePointer = true;
const useArrows = true; //const useArrows = true;
const touchOffsetY = -20; // move the center by this much const touchOffsetY = -20; // move the center by this much
const scaleMobile = 4; // scale mobile screens by this much
const scaleMonitor = 6; // scale computer screens by this much const scaleMonitor = 6; // scale computer screens by this much
const turnLengthMS = 200; // shortest time between turns const turnLengthMS = 200; // shortest time between turns
@ -515,6 +514,7 @@
} else { } else {
const key = m._x + "," + m._y; const key = m._x + "," + m._y;
removeMonster(m); removeMonster(m);
Game.player.stats.xp += 1;
sfx["kill"].play(); sfx["kill"].play();
return true; return true;
} }
@ -605,7 +605,7 @@
msg.push("You hit the monster"); msg.push("You hit the monster");
hitter.stats.hp -= 1; hitter.stats.hp -= 1;
sfx["hit"].play(); sfx["hit"].play();
Game.player.stats.xp += 1; //Game.player.stats.xp += 1;
} else { } else {
console.log(false); console.log(false);
sfx["miss"].play(); sfx["miss"].play();
@ -616,6 +616,7 @@
toast(battleMessage(msg)); toast(battleMessage(msg));
} }
checkDeath(hitter); checkDeath(hitter);
checkDeath(receiver);
showScreen("game"); showScreen("game");
renderStats(Game.player.stats); renderStats(Game.player.stats);
Game.playerAllowedToMove = true; Game.playerAllowedToMove = true;
@ -644,7 +645,6 @@
const p = Game.player; const p = Game.player;
p.character = "T"; p.character = "T";
drawTile(Game, p._x + "," + p._y); drawTile(Game, p._x + "," + p._y);
const ghost = createGhost([p._x, p._y]);
removeListeners(Game); removeListeners(Game);
sfx["lose"].play(); sfx["lose"].play();
setTimeout(function () { setTimeout(function () {
@ -659,7 +659,7 @@
*** graphics, UI & browser utils *** *** graphics, UI & browser utils ***
************************************/ ************************************/
const clickevt = !!("ontouchstart" in window) ? "touchstart" : "click"; const clickevt = "click";
const $ = document.querySelector.bind(document); const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document); const $$ = document.querySelectorAll.bind(document);
@ -671,9 +671,6 @@
$("#canvas").appendChild(el); $("#canvas").appendChild(el);
window.onkeydown = keyHandler; window.onkeydown = keyHandler;
window.onkeyup = arrowStop; window.onkeyup = arrowStop;
if (useArrows) {
document.ontouchend = arrowStop;
}
showScreen("game"); showScreen("game");
} }
@ -755,22 +752,6 @@
} }
} }
// creates the ghost sprite when the player dies
function createGhost(pos) {
const tw = tileOptions.tileWidth;
const th = tileOptions.tileHeight;
const left = "left:" + pos[0] * tw + "px;";
const top = "top:" + pos[1] * th + "px;";
const ghost = el("div", {
className: "sprite ghost free float-up",
style: left + top,
});
ghost.onanimationend = function () {
rmel(ghost);
};
return attach($("#canvas"), ghost);
}
function battleMessage(messages) { function battleMessage(messages) {
const components = messages.reduce(function (msgs, m) { const components = messages.reduce(function (msgs, m) {
return msgs return msgs
@ -860,10 +841,6 @@
console.log("Full screen pressed."); console.log("Full screen pressed.");
return; return;
} }
if (code == 73) {
toggleInventory(ev, true);
return;
}
if (code == 190) { if (code == 190) {
Game.engine.unlock(); Game.engine.unlock();
return; return;

View file

@ -271,34 +271,14 @@ a:hover {
transform: none; transform: none;
} }
.tomb { .tomb {
background-position: -72px -56px; background-position: -72px -56px;
} }
.ghost {
background-position: -72px -8px;
margin: 0px;
}
.empty { .empty {
background-position: -8px -48px; background-position: -8px -48px;
} }
.float-up {
animation: float-up 2s linear forwards;
}
@keyframes float-up {
from {
transform: scale(1) translate(0px, 0px);
opacity: 1;
}
to {
transform: scale(3) translate(0px, -20px);
opacity: 0;
}
}
.grow-fade { .grow-fade {
animation: grow-fade 2s linear; animation: grow-fade 2s linear;
@ -351,33 +331,6 @@ a:hover {
color: #FFB570; color: #FFB570;
} }
#inventory {
position: absolute;
bottom: 0px;
left: 0px;
}
#inventory .sprite {
transform: scale(3);
display: inline-block;
margin: 1em 2em 1em 1em;
vertical-align: middle;
}
#inventory li {
margin: 1em 0px;
}
#inventory ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
#inventory > div {
display: none;
}
@media (max-width: 750px) { @media (max-width: 750px) {
#inventory { #inventory {
bottom: 72px; bottom: 72px;
@ -388,58 +341,6 @@ a:hover {
} }
} }
#arrows {
display: none;
position: absolute;
right: 0px;
bottom: 0px;
}
#arrows > * {
float: left;
font-size: 16px;
bottom: 0px;
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
#arrows > * > span {
pointer-events: none;
}
#btn-left {
position: absolute;
right: 7em;
}
#btn-right {
position: absolute;
right: 0em;
}
#btn-up {
transform: rotate(90deg);
position: absolute;
right: 3.5em;
margin-bottom: 3.75em;
}
#btn-down {
transform: rotate(90deg);
position: absolute;
right: 3.5em;
}
#btn-skip {
position: absolute;
right: 0em;
margin-bottom: 3.75em;
padding: 0px;
}
@media (max-width: 1024px) { @media (max-width: 1024px) {
#arrows > * { #arrows > * {
bottom: 72px; bottom: 72px;

View file

@ -142,13 +142,6 @@
<div id="canvas"></div> <div id="canvas"></div>
<div id="message" class="nes-container is-rounded is-dark hide"></div> <div id="message" class="nes-container is-rounded is-dark hide"></div>
<div id="hud" class="nes-container is-rounded is-dark"></div> <div id="hud" class="nes-container is-rounded is-dark"></div>
<div id="arrows">
<div id="btn-left" class="nes-container is-rounded is-dark"><span>&lt;</span></div>
<div id="btn-up" class="nes-container is-rounded is-dark"><span>&lt;</span></div>
<div id="btn-down" class="nes-container is-rounded is-dark"><span>&gt;</span></div>
<div id="btn-right" class="nes-container is-rounded is-dark"><span>&gt;</span></div>
<div id="btn-skip" class="nes-container is-rounded is-dark"><span>.</span></div>
</div>
</div> </div>
</body> </body>