WDI-SEA / game-project-issues

0 stars 0 forks source link

Object moving problem #50

Closed JuanR9910 closed 3 years ago

JuanR9910 commented 3 years ago

What's the problem you're trying to solve?

I'm trying to get my hockey sticks to move through the game using event listeners but they inputs will not register.

Post any code you think might be relevant (one fenced block per file)

const goals = document.getElementsByClassName("goal")
const xgoal = document.getElementById("Player1")
const ygoal = document.getElementById("Player2")
const hockeysticks = document.getElementsByClassName("hockeystick")
const hockeystick1 = document.getElementById("XPlayer")
const hockeystick2 = document.getElementById("YPlayer")
const puck = document.getElementById("puck")
const scoreboard = document.getElementsByClassName("scorebooard")
const player1score = document.getElementById("Player1score")
const player2score = document.getElementById("Player2score")

function movementHandler.addEventListener('keydown', movementHandler => {
    switch (movementHandler.key) {
        case (38) : hockeystick1
        case (40) : hockeystick1
        case (39) : hockeystick1
        case (37) : hockeystick1
    }
    console.log(movementHandler)
})

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

Uncaught SyntaxError: Unexpected token '.' script line 13

What is your best guess as to the source of the problem?

I'm using the wrong function

What things have you already tried to solve the problem?

I tried making movement handler into a function