|
|
@ -34,10 +34,9 @@ type Game struct { |
|
|
|
enemies []Position |
|
|
|
enemies []Position |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (game *Game) Text(msg string) { |
|
|
|
func (game *Game) DrawStatus(msg string) { |
|
|
|
var comb []rune |
|
|
|
|
|
|
|
for x, cell := range msg { |
|
|
|
for x, cell := range msg { |
|
|
|
game.screen.SetContent(x, game.height, cell, comb, tcell.StyleDefault) |
|
|
|
game.screen.SetContent(x, game.height, cell, nil, tcell.StyleDefault) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -45,16 +44,15 @@ func (game *Game) Status(msg string) { |
|
|
|
game.status = msg |
|
|
|
game.status = msg |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (game *Game) DrawEntity(symbol rune, pos Position) { |
|
|
|
func (game *Game) DrawEntity(symbol rune, pos Position, color tcell.Color) { |
|
|
|
var comb []rune |
|
|
|
style := tcell.StyleDefault.Bold(true).Foreground(color) |
|
|
|
game.screen.SetContent(pos.x, pos.y, symbol, comb, tcell.StyleDefault) |
|
|
|
game.screen.SetContent(pos.x, pos.y, symbol, nil, style) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (game *Game) DrawMap() { |
|
|
|
func (game *Game) DrawMap() { |
|
|
|
var comb []rune |
|
|
|
|
|
|
|
for y, line := range game.level { |
|
|
|
for y, line := range game.level { |
|
|
|
for x, cell := range line { |
|
|
|
for x, cell := range line { |
|
|
|
game.screen.SetContent(x, y, cell, comb, tcell.StyleDefault) |
|
|
|
game.screen.SetContent(x, y, cell, nil, tcell.StyleDefault) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -63,13 +61,13 @@ func (game *Game) Render() { |
|
|
|
game.screen.Clear() |
|
|
|
game.screen.Clear() |
|
|
|
|
|
|
|
|
|
|
|
game.DrawMap() |
|
|
|
game.DrawMap() |
|
|
|
game.DrawEntity('@', game.player) |
|
|
|
game.DrawEntity('@', game.player, tcell.ColorYellow) |
|
|
|
|
|
|
|
|
|
|
|
for _, pos := range game.enemies { |
|
|
|
for _, pos := range game.enemies { |
|
|
|
game.DrawEntity('G', pos) |
|
|
|
game.DrawEntity('G', pos, tcell.ColorRed) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
game.Text(game.status) |
|
|
|
game.DrawStatus(game.status) |
|
|
|
|
|
|
|
|
|
|
|
game.screen.Show() |
|
|
|
game.screen.Show() |
|
|
|
} |
|
|
|
} |
|
|
|