Sha256: e82f2b9b0b3d026b90c2a7e9678f9f8b3e608fe3324ef39d4c686be7db38f381
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require_relative '../tatty/game' require 'pastel' module Petli class HUD < Tatty::Game GAME_WIDTH = 28 GAME_HEIGHT = 13 def initialize super() @pet = Pet.new Rooms.enter(@pet) end def keypress(event) exit if event.value == "q" return if @pet.busy? || @pet.dead? Rooms.current.keypress(event) end 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 def status_bar p = Pastel.new "#{p.red("♥")*@pet.health}#{"♡"*(10-@pet.health)} #{"☺"*(10-@pet.happiness)}#{p.green("☻")*@pet.happiness}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
petli-0.0.2 | lib/petli/hud.rb |