Method: Petli::Stages::Base#draw

Defined in:
lib/petli/stages/base.rb

#drawObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/petli/stages/base.rb', line 64

def draw
  p = Pastel.new
  render_box(
    title: {
      top_left: p.bright_white.bold(" Petli "),
      bottom_right: p.green(" #{@pet.lifetime} days "),
    },
    width: GAME_WIDTH,
    height: GAME_HEIGHT,
    left: left,
    top: top,
  )

  poop = @poop.next
  @pet.poops.each_with_index do |_, i|
    x, y = Pet::POOP_LOCATIONS[i]
    render_at(left+1+x, top+1+y, poop)
  end

  render_at(left+9, top+4, @pet.display)
  sick = @pet.sick
  if sick > 0 && !@pet.dead?
    render_at(left+11-sick, top+4, "[#{'!'*sick}SICK#{'!'*sick}]")
  end

  render_at(left+1, top+1, "#{p.red("")*@pet.health}#{""*(10-@pet.health)}  #{@pet.sick > 0 ? p.red("") : ""}#{@pet.lights_out ? "" : p.yellow("")}  #{""*(10-@pet.happiness)}#{p.green("")*@pet.happiness}")
  render_at(left+1, top+GAME_HEIGHT-2, self.action_bar)
  render_at(left+GAME_WIDTH-2, top, p.bright_white.bold("[x]"))
end