Class: RubySnake::UI::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_snake/ui/base.rb

Direct Known Subclasses

One, Two

Class Method Summary collapse

Class Method Details

.clear_tailObject



15
16
17
# File 'lib/ruby_snake/ui/base.rb', line 15

def clear_tail
  display snake.tail, ' '
end

.display(stuff, symbol) ⇒ Object



9
10
11
12
13
# File 'lib/ruby_snake/ui/base.rb', line 9

def display stuff, symbol
  x = stuff.last + 1
  y = stuff.first + 1
  window.mvprintw x, y, symbol
end

.draw_dialog(x, y, text) ⇒ Object



5
6
7
# File 'lib/ruby_snake/ui/base.rb', line 5

def draw_dialog x, y, text
  UI.draw_dialog x, y, text
end

.draw_foodObject



19
20
21
22
23
24
25
26
# File 'lib/ruby_snake/ui/base.rb', line 19

def draw_food
  if Game.pause?
    window.color_set 3, nil
  else
    window.color_set 1, nil
  end
  display snake.food, '$'
end

.draw_snakeObject



28
29
30
31
32
33
34
35
36
# File 'lib/ruby_snake/ui/base.rb', line 28

def draw_snake
  snake.body.each do |body|
    if body == snake.head
      display body, '@'
    else
      display body, 'o'
    end
  end
end