engagementlab / CivicSeed

Civic social training on steroids for students.
Other
9 stars 4 forks source link

When transitioning between screens, interrupting a slow loading process will freeze the game #178

Open louh opened 9 years ago

louh commented 9 years ago

Observed: on @EGL's laptop, when transitioning between screens, there is a noticeable lag between the time the player lands on the screen edge, and the transition of the screen itself. During this time, the player can still move. If he does move before the screen begins its transition, it will freeze the game.

Expected behavior: When the player lands on the screen edge, the player should not be allowed to move again until after the screen completes its transition. The additional movement is likely causing the script conflict with itself (e.g. causing two transitions to the same screen to occur simultaneously). Additionally, the transition itself should occur much faster.

Likely source of the bug: There is a wait time for the map data of the next screen to load. During this moment, there is a small window of time when additional player input is accepted, because of the gap caused by player._endMove() removing the is-moving flag, then waiting for the map to load, then transitioning the screen and applying the in-transit flag. A proposed solution would be to refactor this area of the script:

  1. To apply the in-transit flag much earlier in the execution process so as to not accept player input for any amount of time.
  2. Reduce the amount of time the game checks to see if the map data has finished loading (currently, there are 50ms wait times between checking). Could we watch for changes to that variable instead, or trigger the transition as a callback to map data loading?
  3. Reduce the latency of retrieving map data.

In case we are unable to do anything about (3) (because of bad wifi for example) we should be able to reduce the likelihood of this bug by fixing 1 and 2.

louh commented 9 years ago

Re-opening to visit the question of whether there's anything to be done to accommodate a slow loading time / slow connection.