Skip to content

Commit

Permalink
Correct an issue when winning "arc anoid" with certain terminal dimen…
Browse files Browse the repository at this point in the history
…sions

Summary: See PHI2085. Python 3 is stricter about integers and floats than Python 2 was, and we can end up passing a float where an integer was expected if the player wins "arc anoid" using a terminal with certain (most?) character dimensions.

Test Plan:
  - Modified "arcanoid.py" to win instantly.
  - Adjusted terminal window to 80x24, ran "arc anoid", reproduced crash.
  - Ran "python2 arcanoid.py" and observed old victory animation behavior.
  - Applied patch.
  - Ran "arc anoid" and observed identical victory animation behavior.

Differential Revision: https://secure.phabricator.com/D21667
  • Loading branch information
epriestley committed Jun 1, 2021
1 parent be1a4a9 commit 246e604
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions support/arcanoid/arcanoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,16 @@ def main(stdscr):
i = int(time.time() / 0.8)
for x in range(width):
for y in range(6):
game.addch(height / 2 + y - 3 + (x / 8 + i) % 2, x,
curses.ACS_BLOCK,
curses.A_BOLD | curses.color_pair(colors[y]))
game.addstr(height / 2, (width - len(message)) / 2, message,
curses.A_BOLD | curses.color_pair(7))
game.addch(
int(height / 2 + y - 3 + (x / 8 + i) % 2),
x,
curses.ACS_BLOCK,
curses.A_BOLD | curses.color_pair(colors[y]))
game.addstr(
int(height / 2),
int((width - len(message)) / 2),
message,
curses.A_BOLD | curses.color_pair(7))

game.refresh()
status.refresh()
Expand Down

0 comments on commit 246e604

Please sign in to comment.