Skip to content

Commit

Permalink
Day 13: render score along with board
Browse files Browse the repository at this point in the history
  • Loading branch information
nlowe committed Dec 14, 2019
1 parent 5616828 commit b188f70
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions challenge/day13/b.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ func b(challenge *challenge.Input) int {

if x == -1 && y == 0 {
score = tile
scoreString := fmt.Sprintf("Score: %d", score)
for i, r := range scoreString {
term.SetContent(i, 0, r, nil, tcell.StyleDefault)
}
} else {
r := ' '
switch tile {
case tileBlock:
term.SetContent(x, y, tcell.RuneBlock, nil, tcell.StyleDefault)
r = tcell.RuneBlock
case tileBall:
bx = x
if bx < px {
Expand All @@ -96,16 +101,16 @@ func b(challenge *challenge.Input) int {
joystick <- positionNeutral
}

term.SetContent(x, y, '0', nil, tcell.StyleDefault)
r = '0'
case tileHorizontalPaddle:
px = x
term.SetContent(x, y, '\u2582', nil, tcell.StyleDefault)
r = '\u2582'
case tileWall:
term.SetContent(x, y, '=', nil, tcell.StyleDefault)
case tileEmpty:
term.SetContent(x, y, ' ', nil, tcell.StyleDefault)
r = '='
}

term.SetContent(x, 1+y, r, nil, tcell.StyleDefault)

if !headless {
term.Show()
}
Expand Down

0 comments on commit b188f70

Please sign in to comment.