Class: RubyTerminalGames::Snake::Board

Inherits:
Board
  • Object
show all
Defined in:
lib/ruby_terminal_games/snake/board.rb

Instance Attribute Summary

Attributes inherited from Board

#cols, #height, #rows, #width

Instance Method Summary collapse

Methods inherited from Board

#clear!, #draw_border!, #move_cursor, #write

Constructor Details

#initialize(width: nil, height: nil) ⇒ Board

Returns a new instance of Board.



4
5
6
7
8
# File 'lib/ruby_terminal_games/snake/board.rb', line 4

def initialize(width: nil, height: nil)
  super
  @width = cols
  @height = rows - 1
end

Instance Method Details



10
11
12
13
14
15
16
17
# File 'lib/ruby_terminal_games/snake/board.rb', line 10

def print_world!(game)
  clear!
  draw_border!
  draw_exit_instructions!
  draw_apple!(game.apple)
  draw_stats!(game.counter, game.points)
  draw_snake!(game.snake.state, game.direction)
end