Skip to content

Commit 31c3194

Browse files
committed
Approaching 2.0 -need to bugfix and add patrol
1 parent 77a3231 commit 31c3194

File tree

4 files changed

+63
-10
lines changed

4 files changed

+63
-10
lines changed

src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<script src="/js/app.js" charset="utf-8"></script>
88
<!-- <link rel="stylesheet" href="/css/normalize.css"> -->
99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">
10+
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
1011
<link rel="stylesheet" href="/css/style.css">
1112
</head>
1213
<body>

src/js/app.js

+47-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global walls itemDefinitions characterDefinitions mapDimensions */
1+
/* global walls itemDefinitions characterDefinitions mapDimensions instructions*/
22
console.log('JS locked and loaded');
33
// Declare global variables
44

@@ -7,6 +7,12 @@ let $board = null;
77
let $newGame = null;
88
let $soundButton = null;
99
let $healthBar = null;
10+
let $healthBarNpc = null;
11+
let $damage = null;
12+
let $damageNpc = null;
13+
let $armor = null;
14+
let $armorNpc = null;
15+
let $backpack = null;
1016
let $timerDisplay = null;
1117
let $stepDisplay = null;
1218
let $enemiesKilledDisplay = null;
@@ -36,8 +42,7 @@ let visibleSquares = [];
3642
// Declare global functions
3743

3844
//Check for DOM loaded
39-
$(function() {
40-
// run DOM related functions
45+
$(function() { // run DOM related functions
4146
init();
4247
});
4348
function init(){
@@ -52,6 +57,12 @@ function init(){
5257
$timerDisplay = $('#timer');
5358
$stepDisplay = $('#stepstaken');
5459
$enemiesKilledDisplay = $('#enemieskilled');
60+
$healthBarNpc = $('#healthbarnpc');
61+
$damage = $('#damage');
62+
$damageNpc = $('#damagenpc');
63+
$armor = $('#armor');
64+
$armorNpc = $('#armornpc');
65+
$backpack = $('#backpack');
5566
// run Functions
5667

5768
// add Event listeners
@@ -203,7 +214,7 @@ class Character {
203214
// add armor
204215
$('#armornpc img').remove();
205216
for (let i = 0; i < (this.armor); i++){
206-
$('#armornpc').append('<img src="/images/leather_armor.png" alt="Armor">');
217+
$armorNpc.append('<img src="/images/leather_armor.png" alt="Armor">');
207218
}
208219
}
209220
}
@@ -291,7 +302,12 @@ function newGame() {
291302
}, 2000);
292303

293304
reset();
305+
deactivateMovement();
306+
307+
// create map
294308
createMap(mapDimensions[level][0],mapDimensions[level][1]);
309+
// Display instructions
310+
displayManual(0);
295311
// spawn player
296312
startingHealth();
297313
spawnPlayer();
@@ -391,6 +407,22 @@ function countGameTime() {
391407
function startGameTimer() {
392408
setInterval(countGameTime, 1000);
393409
}
410+
function displayManual(level) {
411+
$($board.children()).hide();
412+
$board.append(`<p>${instructions[level]}<p>`);
413+
setTimeout(hideInstructions, 5000);
414+
setTimeout(showGame, 5000);
415+
setTimeout(function() {
416+
$board.find('p').remove();
417+
}, 5000);
418+
}
419+
function showGame() {
420+
$board.find('div').show(2000);
421+
}
422+
function hideInstructions() {
423+
$board.find('p').hide(2000);
424+
}
425+
394426
// Map Editor Mode
395427
function activateMapEditor() {
396428
// toggle this
@@ -453,6 +485,7 @@ function levelUp() {
453485
spawnEnemies(3,1);
454486
spawnItems();
455487
spawnItems();
488+
displayManual(1);
456489
}
457490
if (level === 2) {
458491
spawnEnemies(3,1);
@@ -462,8 +495,9 @@ function levelUp() {
462495
spawnItems();
463496
spawnItems();
464497
spawnItems();
498+
displayManual(2);
465499
}
466-
500+
changeVisibility();
467501
}
468502
function loseGame() {
469503
if (player.health <= 0) {
@@ -485,6 +519,7 @@ function reset() {
485519
$('.floor').html('');
486520
// Stop Timer
487521
clearInterval(startGameTimer);
522+
// reset everything
488523
level = 0;
489524
stepsTaken = 0;
490525
enemies = [];
@@ -493,4 +528,11 @@ function reset() {
493528
itemLocations = [];
494529
timeTaken = 0;
495530
$timerDisplay.html = 0;
531+
$armor.html('');
532+
$armorNpc.html('');
533+
$damage.html('');
534+
$damageNpc.html('');
535+
$healthBar.html('');
536+
$healthBarNpc.html('');
537+
$backpack.html('');
496538
}

src/js/libraries.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
/* eslint-disable no-unused-vars */
2+
const instructions1 = 'You were poisoned by an evil wizard and left to die in a little room in this massive abandoned dungeon. <br> Find your way out and have your revenge! <br> You can move with W,A,S,D - find the door to the next floor.';
3+
4+
const instructions2 = 'Good job! You managed to leave your personal little prison <br> But be careful, there are critters about that have been going hungry for far too long <br> Keep your eyes open for items that might help you during your escape';
5+
6+
const instructions3 = 'You\'ve made it as far as I have come, my friend. <br> Be careful, some of the enemies on this level are restless and wander about in search of food';
7+
8+
const instructions = [instructions1,instructions2,instructions3];
29

310
const mapDimensions = [[10,10],[20,10],[30,20]];
411
const characterDefinitions = [

src/scss/style.scss

+8-5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ body {
5656
background-size: cover;
5757
}
5858

59-
// .hidden {
60-
// opacity: 0;
61-
// }
59+
.hidden {
60+
opacity: 0;
61+
}
6262

6363
.hide {
6464
display: none;
@@ -80,8 +80,11 @@ h2 {
8080
height: 90vh;
8181
display: flex;
8282
flex-wrap: wrap;
83-
.player {
84-
// background-color: red;
83+
p {
84+
font-size: 2rem;
85+
font-family: 'Press Start 2P', cursive;
86+
font-weight: 500;
87+
color: red;
8588
}
8689
img {
8790
height: 100%;

0 commit comments

Comments
 (0)