Skip to content

Commit 11260c5

Browse files
Merge pull request #23 from MichaelLarocca/develop
Merge Sprint 2 changes from develop into master
2 parents 800e3b7 + b023e29 commit 11260c5

File tree

3 files changed

+77
-31
lines changed

3 files changed

+77
-31
lines changed

src/js/game-board.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ export function roundOutTheGameboard(){
166166
squares[630].classList.add('roundBottomRight');
167167
}
168168

169+
export function reSetLairTextColor(color = "black") {
170+
document.querySelectorAll('.lairText').forEach(el => {
171+
el.style.color = color;
172+
});
173+
}
174+
169175
export function setLairText() {
170176
//
177+
reSetLairTextColor();
171178
squares[403].classList.add('lairText');
172179
squares[404].classList.add('lairText');
173180
squares[405].classList.add('lairText');
@@ -183,6 +190,7 @@ export function setLairText() {
183190
squares[436].classList.add('lairText');
184191

185192
//lairText
193+
reSetLairTextColor("orange");
186194
squares[431].innerHTML = "R";
187195
squares[432].innerHTML = "E";
188196
squares[433].innerHTML = "A";
@@ -195,6 +203,7 @@ export function setLairText() {
195203
}
196204

197205
export function setTitleScreen() {
206+
reSetLairTextColor();
198207
for(let i = 0; i < squares.length; i++) {
199208

200209
squares[i].classList.remove('pacMan', 'pacMan-move-left', 'pacMan-move-right', 'pacMan-move-up', 'pacMan-move-down','blank', 'wall', 'powerPellet', 'pellet', 'ghost', 'ghost-small','ghost-large', 'ghost-look-left', 'ghost-look-up', 'ghost-look-down', 'ghost-look-right',
@@ -323,6 +332,7 @@ export function setTitleScreen() {
323332
} // setTitleScreen
324333

325334
export function setScoreScreen() {
335+
reSetLairTextColor();
326336
for(let i = 0; i < squares.length; i++) {
327337

328338
squares[i].classList.remove('pacMan', 'pacMan-move-left', 'pacMan-move-right', 'pacMan-move-up', 'pacMan-move-down','blank', 'wall', 'powerPellet', 'pellet', 'ghost', 'ghost-small','ghost-large', 'ghost-look-left', 'ghost-look-up', 'ghost-look-down', 'ghost-look-right',
@@ -459,6 +469,7 @@ export function setScoreScreen() {
459469
} // setScoreScreen
460470

461471
export function setGameBoard() {
472+
reSetLairTextColor();
462473
for(let i = 0; i < squares.length; i++) {
463474
squares[i].classList.remove('pacMan', 'pacMan-move-left', 'pacMan-move-right', 'pacMan-move-up', 'pacMan-move-down',
464475
'blank', 'wall', 'powerPellet', 'pellet', 'ghost', 'ghost-look-left', 'ghost-look-up', 'ghost-look-down', 'ghost-look-right',

src/js/helper-functions.js

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { squares, buildGameBoard, setGameBoard, roundOutTheGameboard, setLairText, setTitleScreen } from './game-board.js';
1+
import { squares, buildGameBoard, setGameBoard, roundOutTheGameboard, setLairText, setTitleScreen, reSetLairTextColor } from './game-board.js';
22
import { flagToggled, startToggleTitleAndScoreScreen, endToggleTitleAndScoreScreen } from '../main.js';
33
import { playSiren, stopSiren, switchToSiren2, stopPacManEatingPelletsSound, playPacManEatingPelletsSound, playGhostEatenSounds, stopAllSounds, soundGameStart, soundPacManEatingPellets, soundPacManEatingFruit, soundGhostSiren1, soundCutscene, soundDeath, soundEatingGhost, soundGhostRunningAway, soundGhostSiren2, soundHighScore, soundPowerUp } from './audio.js';
44

@@ -344,24 +344,26 @@ export function control(x) {
344344
} // control
345345

346346
function fruitScoreBonus(){
347+
reSetLairTextColor("whitesmoke");
347348
soundPacManEatingFruit.play();
348349
if(level < 12) {
349350
score += fruitBonusValue[level-1];
350-
squares[433].style.color = 'whitesmoke';
351+
// squares[433].style.color = 'whitesmoke';
351352
squares[433].innerHTML = fruitBonusValue[level-1];
352353
// console.log(`Fruit Eaten! ${fruitBonusValue[level-1]}`);
353354
fruitEaten = true;
354355
squares[pacmanCurrentIndex].classList.remove('bonusFruit');
355356
squares[489].innerHTML = '';
356357
} else {
357358
score += fruitBonusValue[fruitBonusValue.length-1];
358-
squares[433].style.color = 'whitesmoke';
359+
// squares[433].style.color = 'whitesmoke';
359360
squares[433].innerHTML = fruitBonusValue[fruitBonus.length-1];
360361
// console.log(`Fruit Eaten! ${fruitBonusValue[level-1]}`);
361362
fruitEaten = true;
362363
squares[pacmanCurrentIndex].classList.remove('bonusFruit');
363364
squares[489].innerHTML = '';
364365
}
366+
// reSetLairTextColor();
365367
}
366368

367369
// Fruit Score
@@ -390,7 +392,8 @@ export function levelStart() {
390392
flagBonusLife = false;
391393

392394
scoreDisplay.innerHTML = score;
393-
395+
396+
reSetLairTextColor("orange");
394397
squares[431].innerHTML = "R";
395398
squares[432].innerHTML = "E";
396399
squares[433].innerHTML = "A";
@@ -414,7 +417,8 @@ export function levelStart() {
414417
squares[433].innerHTML = "";
415418
squares[434].innerHTML = "";
416419
squares[435].innerHTML = "";
417-
squares[436].innerHTML = "";
420+
squares[436].innerHTML = "";
421+
reSetLairTextColor();
418422

419423
// setPacManSpeed();
420424
speedStartPacMan = setInterval(control, pacManSpeed);
@@ -453,6 +457,23 @@ export function checkForGhostCatchesPacMan() {
453457
}
454458
}
455459

460+
// Function to animate PacMan dying
461+
export function animatePacManDying() {
462+
squares[pacmanCurrentIndex].classList.add('pacMan-move-die');
463+
setTimeout(()=>{
464+
squares[pacmanCurrentIndex].classList.remove('pacMan-move-die');
465+
squares[pacmanCurrentIndex].classList.remove('pacMan');
466+
}, 1250);
467+
468+
setTimeout(()=>{
469+
squares[pacmanCurrentIndex].classList.add('pacMan-explode');
470+
}, 1250);
471+
472+
setTimeout(()=>{
473+
squares[pacmanCurrentIndex].classList.remove('pacMan-explode');
474+
}, 1500);
475+
}
476+
456477
export function loseLife(){
457478
stopAllSounds();
458479
soundDeath.play();
@@ -464,7 +485,8 @@ export function loseLife(){
464485

465486
if(lives === 0) {
466487
clearInterval(speedStartPacMan);
467-
squares[pacmanCurrentIndex].classList.add('pacMan-move-die');
488+
animatePacManDying()
489+
468490
resetGame();
469491
setTimeout(gameOver, 4000);
470492
// setTimeout(setTitleScreen, 8000);
@@ -473,7 +495,8 @@ export function loseLife(){
473495

474496
} else {
475497
clearInterval(speedStartPacMan);
476-
squares[pacmanCurrentIndex].classList.add('pacMan-move-die');
498+
animatePacManDying()
499+
477500
setTimeout(resetPacMan, 4000);
478501
}
479502
// ghostsEaten = 0;
@@ -518,6 +541,7 @@ function extraLife() {
518541

519542
resizeCurrentPacManLives();
520543

544+
reSetLairTextColor("orange");
521545
squares[431].innerHTML = "E";
522546
squares[432].innerHTML = "X";
523547
squares[433].innerHTML = "T";
@@ -532,6 +556,7 @@ function extraLife() {
532556
squares[434].innerHTML = "";
533557
squares[435].innerHTML = "";
534558
squares[436].innerHTML = "";
559+
reSetLairTextColor();
535560
}, 3000);
536561
}
537562
// if(score !== 0 && checkForBonusLife === 0 && flagBonusLife === false){
@@ -565,19 +590,20 @@ function resetGame(){
565590
}
566591

567592
function gameOver() {
593+
reSetLairTextColor("red");
568594
checkForHighScore();
569595
// localStorage.setItem("highScore", JSON.stringify(highScore));
570596
removePacMan();
571597

572-
squares[404].style.color = 'red';
573-
squares[405].style.color = 'red';
574-
squares[406].style.color = 'red';
575-
squares[407].style.color = 'red';
576-
577-
squares[432].style.color = 'red';
578-
squares[433].style.color = 'red';
579-
squares[434].style.color = 'red';
580-
squares[435].style.color = 'red';
598+
// squares[404].style.color = 'red';
599+
// squares[405].style.color = 'red';
600+
// squares[406].style.color = 'red';
601+
// squares[407].style.color = 'red';
602+
603+
// squares[432].style.color = 'red';
604+
// squares[433].style.color = 'red';
605+
// squares[434].style.color = 'red';
606+
// squares[435].style.color = 'red';
581607

582608
squares[403].innerHTML = "";
583609
squares[404].innerHTML = "G";
@@ -594,16 +620,16 @@ function gameOver() {
594620
squares[436].innerHTML = "";
595621

596622
setTimeout(function(){
597-
598-
squares[404].style.color = 'orange';
599-
squares[405].style.color = 'orange';
600-
squares[406].style.color = 'orange';
601-
squares[407].style.color = 'orange';
602-
603-
squares[432].style.color = 'orange';
604-
squares[433].style.color = 'orange';
605-
squares[434].style.color = 'orange';
606-
squares[435].style.color = 'orange';
623+
reSetLairTextColor("orange");
624+
// squares[404].style.color = 'orange';
625+
// squares[405].style.color = 'orange';
626+
// squares[406].style.color = 'orange';
627+
// squares[407].style.color = 'orange';
628+
629+
// squares[432].style.color = 'orange';
630+
// squares[433].style.color = 'orange';
631+
// squares[434].style.color = 'orange';
632+
// squares[435].style.color = 'orange';
607633

608634
squares[403].innerHTML = "";
609635
squares[404].innerHTML = "";
@@ -684,17 +710,19 @@ export function gameStart() {
684710
}
685711

686712
function clearFruitBonus1(){
713+
reSetLairTextColor("orange");
687714
squares[433].innerHTML = '';
688-
squares[433].style.color = 'orange';
715+
// squares[433].style.color = 'orange';
689716
squares[489].classList.remove('bonusFruit');
690717
console.log('clearFruitBonus1');
691718
squares[489].innerHTML = '';
692719
fruitEaten = false;
693720
}
694721

695722
function clearFruitBonus2(){
723+
reSetLairTextColor("orange");
696724
squares[433].innerHTML = '';
697-
squares[433].style.color = 'orange';
725+
// squares[433].style.color = 'orange';
698726
squares[489].classList.remove('bonusFruit');
699727
console.log('clearFruitBonus2');
700728
squares[489].innerHTML = '';
@@ -977,13 +1005,14 @@ export function moveGhost(ghost) {
9771005
} // if(ghost.isScared)
9781006

9791007
if(ghost.isScared && squares[ghost.currentIndex].classList.contains('pacMan')) {
980-
1008+
reSetLairTextColor("whitesmoke");
9811009
playGhostEatenSounds();
9821010

9831011
ghostsEaten += 1;
9841012
score += ghostsEaten * 400;
9851013
console.log(`ghostsEaten score: ${ghostsEaten * 400}`);
986-
squares[433].style.color = 'whitesmoke';
1014+
// squares[433].style.color = 'whitesmoke';
1015+
9871016
squares[433].innerHTML = ghostsEaten * 400;
9881017
setTimeout(()=>{squares[433].innerHTML = ''; }, 5000);
9891018
// Set blinky to respawn inside the lair
@@ -995,6 +1024,7 @@ export function moveGhost(ghost) {
9951024
ghost.currentIndex = ghost.startIndex;
9961025
}
9971026
squares[ghost.currentIndex].classList.add(ghost.className, 'ghost', ghost.size, ghost.color, ghost.eyes);
1027+
// reSetLairTextColor();
9981028
}
9991029
checkForGhostCatchesPacMan();
10001030
// checkForHighScore();

src/styles/_pacman.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
}
3434
.pacMan-move-die {
3535
// animation: pacManMoveDie 3s 1;
36-
animation: pacManMoveDie 3s forwards;
36+
animation: pacManMoveDie 1.5s forwards;
37+
}
38+
39+
.pacMan-explode {
40+
border: 1px dotted orange;
41+
border-radius: 50%;
3742
}
3843

3944
@keyframes pacManMoveLeft {

0 commit comments

Comments
 (0)