Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
RequestAnimationFrame is changing params

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);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!