Learn Intermediate OOP by Building a Platformer Game - Step 42

Tell us what’s happening:

I can’t understand this quesiton

Your code so far

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

  }
}

Your issue is here

you need to target the player’s position, not this.position

Remember that the player variable represents the new player you created here

const player = new Player();

if you want to access properties from that player class then you reference the player followed by the property name

for example, if I wanted to access the player’s x velocity, then I would do the following:

player.velocity.x

once you fix that, then it will pass

hope that helps

1 Like