I am make a side scroller game and am having trouble with window.requestAnimationFrame. I am creating a function that loops over the game and exporting it. When I call this function instead of logging the player object it logs a float value.
gameLoop.js
export default function gameLoop(player){
window.requestAnimationFrame(gameLoop);
console.log(player);
}
main.js
import Player from "./player.js";
import gameLoop from "./gameLoop.js";
const canvas = document.getElementById("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let ctx = canvas.getContext("2d");
let player = new Player(30,canvas.height - 100,ctx);
gameLoop(player);