Mysterious Input Problems

id: 751177

category: Bugs and Glitches

posts: 5

My browser / operating system: IPad iOS 17.2, ChromeiOS 123.0.6312.52, No Flash version detected


So I’ve been working on this scrolling tile map project. (Link: https://scratch.mit.edu/projects/991697687/) Basically, the collisions were jerky, b/c you could see the system compensating for the wall. So, naturally, I turned it to Run Without Screen Refresh… and it went BONKERS. It’s actually ridiculous. This is the only change I have made, and now the system a) freezes up for a second, b) teleports my character about 40 tiles away, and c) THINKS THE RIGHT ARROW KEY IS BEING PRESSED WHEN IT’S NOT BEING PRESSED! It’s like Scratch is possessed or something lol.
Maximouse Maximouse loading
Run without screen refresh doesn't just make the block run faster – it prevents any other code from running until that block finished. In your project, this has the following consequences:
  • Keyboard input (releasing the right arrow key) can't be detected.
  • Tiles aren't redrawn when changing Character X, so “touching color black” will always return false.
Maximouse Maximouse loading
The following code should work:

when [right arrow v] key pressed
repeat until <not <key [right arrow v] pressed?>>
change [Character X v] by (10)
Move [R]
end

define Move [input]
if <(input) = [R]> then
repeat until <not <touching color [#000]?>>
change x by (-1)
end
change [Character X v] by (x position)
set x to (0)
else
...
end

To avoid the first problem mentioned above, I moved the loop that waits for the arrow key to be released out of the custom block. To fix the second problem, I used “change x” instead of “change Character X” to move the character and not the tiles. After finding the distance needed to move the character out of the wall, the “Character X” variable is updated and the x position is reset.
Wow, that was…amazingly comprehensive and helpful. Thanks!!
(*me being astonished that I spelled comprehensive correctly*)
(*me realizing it was autocorrect*)
(*me crying in the bathroom*)
XD