Learn Intermediate OOP by Building a Platformer Game - Step 46

Tell us what’s happening:

if (keys.right.pressed && player.position.x < proportionalSize(400)) { }
I do not know why the code is not working as I have followed all the instructions.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region


const animate = () => {
  requestAnimationFrame(animate);
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  player.update();
  if (keys.right.pressed && player.position.x < proportionalSize(400)) {
    
  }
}


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 46

this says that the keys object has a property called right
but does it?

I also tried rightkeys.pressed and got the same error message.

do you think you can find the line of code that defines the object to compare what you wrote with what is defined there?
Then show us the new code you wrote that still doesn’t work if that is the case.

Thanks! I firgured it out
Mod Edit: solution removed

1 Like

perfect. We knew you could do it.

just fyi, I edited your post and removed the solution code to not spoil this topic for someone reading it in future.