Skip to content

Commit

Permalink
refactor: added logger, keyboards, settings
Browse files Browse the repository at this point in the history
  • Loading branch information
elenik72 committed Jun 27, 2022
1 parent c11c503 commit 28d27b3
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import './style.css'
import Keyboard from './keyboard'
import Logger from './logger'
import Settings from './settings'

const SIZE_WIDTH = 4
const SIZE_HEIGHT = 4

const logger = Logger.make(console)
const settings = Settings.make({ width: SIZE_WIDTH, height: SIZE_HEIGHT })
const keyboard = Keyboard.make({ logger })

let down = {
x: 0,
y: 0
Expand Down Expand Up @@ -252,23 +259,23 @@ class UI {
}

direction() {
document.addEventListener('keydown', (e) => {
switch (e.key) {
case 'w':
this.moving('up')
break
case 's':
this.moving('down')
break
case 'd':
this.moving('right')
break
case 'a':
this.moving('left')
break
}
this.randomView()
})
// document.addEventListener('keydown', (e) => {
// switch (e.key) {
// case 'w':
// this.moving('up')
// break
// case 's':
// this.moving('down')
// break
// case 'd':
// this.moving('right')
// break
// case 'a':
// this.moving('left')
// break
// }
// this.randomView()
// })
}

render() {
Expand Down

0 comments on commit 28d27b3

Please sign in to comment.