0
Bugs on PC, but not on mobile
My code ( https://code.sololearn.com/WpCApR631liy/?ref=app) has a few bugs and I don't know why. Sometimes the moving red square seems to jump between to points very quickly (it's movement is defined in the function at line 276). [And when you lose and click "try again", the reset button is gone. (That's solved now.)] Also, sometimes the console says "TypeError: Cannot read property 'style' of null" (but nothing is wrong with the output, except for the other two bugs). Weirdly though, none of these problems appears when I run the code on my mobile phone. I couldn't find out why that happens. I hope my code isn't too messy for you. Edit: The problems seem to be gone now.
3 Respostas
+ 2
The reset button doesn't reappear, is due to the conditional at line 265 and the fact that line 268 is inside of it's code block. The way the conditional reads - if variable playing_on_pc is false then ...display reset button.
While running your game on pc, the only instance I see any of the blocks jumping/glitching is after I click the 'Run' button. Is this the case for you also?
+ 1
ODLNT Oh, I had forgotten about that if statement, thank you.
When I run the code on my laptop, the red square either moves normally or it looks like two flickering squares (apparently it switches between two positions quickly). These "two" squares move right and left too, sometimes "they" move past each other and sometimes one of them moves into the green block. But it's not only at the beginning.
+ 1
Yes, I see the same thing, but it only happens after I press the run button instead of the reset button while the game is already in play.
It appears that clicking the run button does not clear the setInterval for block_moving but it does start up a new setInterval which is causing the ghosting blocks.
You might have to setup an eventlistener on the parent window and clear the setInveral when the run button is pressed.
https://code.sololearn.com/W0a154A4a24a
Most likely there is some other route to solve this issue but it is eluding me at the moment.