I've been working on extending and improving a Mario clone project in JS (Link to the original project: http://www.garrettjohnson.net/mario/) (Link to source files for original: https://drive.google.com/file/d/1DOfszLr2r8MBqgsyjjbpgR69413no1w5/view)
I was working on changing screens by calling a function that would replace all the previous game values with new values. So I made a new level and transition from 1 level to another happened smoothly but when going to the third, the pos values for Mario changed into values that I couldn't figure out.
Here's what I've tried:
- creating a setter for the pos (didn't work : unexpected identifier errors)
- using Object.observe (didn't work : Object.observe is not a function)
- tried using object.defineproperty to create a console trace (using something like https://www.youtube.com/watch?v=opJxH_DTUNg) (no errors, but it never used the setter I made using defineproperty
Please suggest any ideas. To reiterate, the exact problem I'm facing is that the value of Player.pos is erratically changing (as checked in the console.log) after reaching a new screen. I need to figure out what function call is changing it in such a way (so I can at least implement an edge case solution).