Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ document.addEventListener('DOMContentLoaded', () => {
squares[pacmanCurrentIndex].classList.remove('pac-man')
switch(e.keyCode) {
case 37:
if(
if (squares[pacmanCurrentIndex -1] === squares[363]) {
pacmanCurrentIndex = 391
} else if(
pacmanCurrentIndex % width !== 0 &&
!squares[pacmanCurrentIndex -1].classList.contains('wall') &&
!squares[pacmanCurrentIndex -1].classList.contains('ghost-lair')
)
pacmanCurrentIndex -= 1
if (squares[pacmanCurrentIndex -1] === squares[363]) {
pacmanCurrentIndex = 391
}
break
case 38:
if(
Expand All @@ -99,15 +98,14 @@ document.addEventListener('DOMContentLoaded', () => {
pacmanCurrentIndex -= width
break
case 39:
if(
if (squares[pacmanCurrentIndex +1] === squares[392]) {
pacmanCurrentIndex = 364
} else if(
pacmanCurrentIndex % width < width - 1 &&
!squares[pacmanCurrentIndex +1].classList.contains('wall') &&
!squares[pacmanCurrentIndex +1].classList.contains('ghost-lair')
)
pacmanCurrentIndex += 1
if (squares[pacmanCurrentIndex +1] === squares[392]) {
pacmanCurrentIndex = 364
}
break
case 40:
if (
Expand Down