0

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:

  1. creating a setter for the pos (didn't work : unexpected identifier errors)
  2. using Object.observe (didn't work : Object.observe is not a function)
  3. 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).

  • Maybe [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) can mean something for you? – KooiInc May 07 '21 at 08:40
  • Use a breakpoint/watchpoint in the JS debugger? https://stackoverflow.com/questions/11618278/breakpoint-on-property-change, https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_watchpoints – CBroe May 07 '21 at 08:40

0 Answers0