class Petli::HUD

Constants

GAME_HEIGHT
GAME_WIDTH

Public Class Methods

new() click to toggle source
Calls superclass method Tatty::Game::new
# File lib/petli/hud.rb, line 9
def initialize
  super()
  @pet = Pet.new
  Rooms.enter(@pet)
end

Public Instance Methods

draw() click to toggle source
# File lib/petli/hud.rb, line 21
def draw
  h, w = self.screen_size
  left, top = ((w-GAME_WIDTH)/2).round, ((h-GAME_HEIGHT)/2).round
  render_box(
    title: {
      top_left: Pastel.new.bright_white.bold(" Petli "),
      bottom_right: Pastel.new.green(" #{@pet.lifetime} days "),
    },
    width: GAME_WIDTH,
    height: GAME_HEIGHT,
    left: left,
    top: top,
  )
  Rooms.current.draw(self, left, top)
  render_at(left+1, top+1, status_bar)
  render_at(left+1, top+GAME_HEIGHT-2, Rooms.current.action_bar)
end
keypress(event) click to toggle source
# File lib/petli/hud.rb, line 15
def keypress(event)
  exit if event.value == "q"
  return if @pet.busy? || @pet.dead?
  Rooms.current.keypress(event)
end
status_bar() click to toggle source
# File lib/petli/hud.rb, line 39
def status_bar
  p = Pastel.new
  "#{p.red("♥")*@pet.health}#{"♡"*(10-@pet.health)}      #{"☺"*(10-@pet.happiness)}#{p.green("☻")*@pet.happiness}"
end