0

Im making my 1st snake game getting syntax error uncaught syntaxerror cannot use import statement outside a module

game.js import { update as updateSnake, draw as drawSnake, SNAKE_SPEED } from "/.snake.js" let lastRenderTime = 0 const SNAKE_SPEED = 2 function main(currentTime) { const secondsSinceLastRender = (currentTime - lastRenderTime) / 1000 if secondsSinceLastRender < 1 / SNAKE_SPEED return window.requestAnimationFrame(main) console.log("Render") lastRenderTime = currentTime; update() draw() } window.requestAnimationFrame(main) function update(){ updateSnake() } functuon draw(){ drawSnake() } snake.js export const SNAKE_SPEED = 1 const snakeBody = [{x: 11, y: 11}] export function update() { console.log("update snake") } export function draw(gameBoard) { snakeBody.forEach(segment => { const snakeElement = document.createElement("div") snakeElement.style.gridRowStart = segment.x snakeElement.style.gridColumnStart = segment.y }) }

2nd Jan 2021, 6:35 AM
Emmanuel Riano
Emmanuel Riano - avatar
2 Respostas
+ 1
The condition for your of statement. if secondsSinceLastRender < 1 / SNAKE_SPEED see anything missing here??? (condition)
2nd Jan 2021, 6:41 AM
ChaoticDawg
ChaoticDawg - avatar
0
It still doesnt work. Ima figure it out probably once im finished codin
2nd Jan 2021, 7:02 AM
Emmanuel Riano
Emmanuel Riano - avatar