|
Hello,
I just finished Ch. 11 and passed all tests, however, when I run the Pong game in the VMEmulator on my Mac OSX (Monterey 12.4, Intel I7), game over is triggered immediately and a score of 1 is shown. I didn't get a chance to move the bat.. in 'no animation' mode game over is shown as soon as I click run.
I ran the exact same code on Linux, and the game works fine. Also, I noticed that translating the .jack code using the supplied JackCompiler tool resulted in the same behaviour; on my MAC, game over triggered immediately.
I wondered if the game was simply running 'too fast' on my Mac, and added a "do Sys.wait(50);" command at the very end of the Ball.move() method in Ball.jack. This fixed the issue!
I don't know enough about the source code, or differences in JRE on MAC/Linux, but is it possible there is such a speed difference when running the VMEmulator on Mac? I'm currently using Java SE Runtime Environment 18.0.1.1+2-6.
This post is mostly for curiosity, since my fix worked well enough to solve my problem. Just thought I'd let the community know and also hope someone more knowledgeable can answer my question. If there is a way to ensure consistent behaviour across OS's that would be good, since I plan on teaching from this textbook next year, and my students use different OS's.
Thanks!
ps - great book! Love it.
|