Class: Pacman::BoardScale
- Inherits:
-
Object
- Object
- Pacman::BoardScale
- Defined in:
- lib/pacman/board_scale.rb
Overview
How much the board is zoomed for a given terminal, and how that zoom slows the game's movement pace so on-screen speed stays roughly constant.
Constant Summary collapse
- HUD_ROWS =
2- SLOWDOWN_ZOOM =
3
Instance Method Summary collapse
- #cramped? ⇒ Boolean
- #factor ⇒ Object
-
#initialize(screen:, maze:) ⇒ BoardScale
constructor
A new instance of BoardScale.
-
#pace ⇒ Object
Timer pulses per movement tick: full speed at modest zooms, one gentle halving once cells get big enough that motion would blur across the board.
Constructor Details
#initialize(screen:, maze:) ⇒ BoardScale
Returns a new instance of BoardScale.
9 10 11 12 |
# File 'lib/pacman/board_scale.rb', line 9 def initialize(screen:, maze:) @screen = screen @maze = maze end |
Instance Method Details
#cramped? ⇒ Boolean
18 19 20 |
# File 'lib/pacman/board_scale.rb', line 18 def cramped? factor < 1 end |
#factor ⇒ Object
14 15 16 |
# File 'lib/pacman/board_scale.rb', line 14 def factor [width_factor, height_factor].min end |
#pace ⇒ Object
Timer pulses per movement tick: full speed at modest zooms, one gentle halving once cells get big enough that motion would blur across the board.
26 27 28 |
# File 'lib/pacman/board_scale.rb', line 26 def pace (factor >= SLOWDOWN_ZOOM) ? 2 : 1 end |