Learn Intermediate OOP by Building a Platformer Game - Step 21

Tell us what’s happening:

Describe your issue in detail here.
When the player moves to the right, you will need to adjust its velocity.

Use the addition assignment operator to add the velocity’s x coordinate to the player’s x position.

Don’t forget to include the this keyword for the velocity and position.

I keep getting this error =>

You should use the addition assignment operator += to add the velocity’s x coordinate to the player’s x position.

Your code so far

update() {
    this.draw();
    this.velocity.x += this.position.x;
  }

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 21

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi @jcbsmith20

Currently your code is adding position to velocity.

Is this what the instructions asked you to do?

Happy coding

2 Likes

always something simple, thank you

1 Like

Wow, very impressive. Been stuck here for something so simple

1 Like