Reputation: 11
I was trying to load a paddle with mouse controls (on the x) when i run and check the console it says "error document.documentElement is not a function".... Now i have tried to figure it out but i still have no acvaile i am using a udemy course but it was not very helpful im trying to make a paddle with collisions and a ball bouncing with lots of weird elements some are to long that i cant even say them lol
<html>
<body>
<canvas id="gameCanvas" width="800" height="600"></canvas>
</body>
<script>
var ballX = 100
var ballspeedX = 5
var ballY = 100
var ballspeedY = 5
const PADDLE_WIDTH = 100
const PADDLE_THICKNESS = 10
var paddleX = -100
var canvas
var canvasContext
function updateMousePos(evt) {
var rect = canvas.getBoundingClientRect()
var root = document.documentElement();
var mouseX = evt.clientX - rect.left - root.scrollLeft
paddleX = mouseX
}
window.onload = function() {
canvas = document.getElementById("gameCanvas")
canvasContext = canvas.getContext("2d")
var fps = 30
setInterval(updateAll, 100)
canvas.addEventListener("mousemove", updateMousePos)
}
Upvotes: 1
Views: 57
Reputation: 75
btw (this was probably you forgeiting to copy in the end of the thing but) you forgot </script>
and </html>
at the end
Upvotes: 0
Reputation: 819
When defining the root var you need to remove the parenthesis from document.documentElement;
Upvotes: 1