Skip to content

Commit

Permalink
Change to inform about the game status
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Nov 2, 2019
1 parent e4b867f commit 76aaea8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/tenpin/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "tty-screen"

require_relative "bowler"
require_relative "info_box"
require_relative "lane"
require_relative "pins"
require_relative "position"
Expand Down Expand Up @@ -87,11 +88,12 @@ def run
pins = Pins.new(pos.x, pos.y)
bowler = Bowler.new(pos.x + 8, pos.y + 23)
score = Score.new
scoreboard = Scoreboard.new(pos.x + 23, pos.y - 1, score: score)
scoreboard = Scoreboard.new(pos.x + 22, pos.y - 1, score: score)
power_bar = SwingBar.new(power_pos.x + 1, power_pos.y + 1,
gradient: SwingBar::GRADIENT_POWER)
hook_bar = SwingBar.new(hook_pos.x + 1, hook_pos.y + 1,
gradient: SwingBar::GRADIENT_HOOK)
info_box = InfoBox.new(hook_pos.x, hook_pos.y + 4)

loop do
print game_frame
Expand All @@ -102,6 +104,8 @@ def run
print power_frame
print hook_frame

info_box.draw "Score: #{score.total}"

break if score.finish?

# set bowler position
Expand Down Expand Up @@ -134,6 +138,7 @@ def run
print cursor.clear_screen
end

info_box.draw "Score: #{score.total}", "", "Game finished!"
@reader.read_keypress
print cursor.clear_screen
print cursor.show
Expand Down

0 comments on commit 76aaea8

Please sign in to comment.