diff --git a/main.go b/main.go index 095b7b7..dcbda0c 100644 --- a/main.go +++ b/main.go @@ -20,13 +20,20 @@ func main() { // Our initial variables. player := entity.NewEntity(screen.Columns/2, screen.Rows/2, '@', goro.Style{Foreground: goro.ColorWhite}) + npc := entity.NewEntity(screen.Columns/2-5, screen. Rows/2, '@', goro.Style{Foreground: goro.ColorYellow}) + + entities := []*entity.Entity{ + player, + npc, + } + + // The game loop. for { // Draw screen. - screen.DrawRune(player.X, player.Y, player.Rune, player.Style) - screen.Flush() - screen.DrawRune(player.X, player.Y, ' ', goro.Style{}) + DrawAll(screen, entities) + ClearAll(screen, entities) // Handle events. switch event := screen.WaitEvent().(type) { case goro.EventKey: diff --git a/render.go b/render.go new file mode 100644 index 0000000..b0b49f7 --- /dev/null +++ b/render.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/kettek/goro" + + "steel/entity" +) +// DrawAll draws all entities to the screen and flushes it. +func DrawAll(screen *goro.Screen, entities[]*entity.Entity) { + for _, entity := range entities { + DrawEntity(screen, entity) + } + screen.Flush() +} +// ClearAll clears all entities from the screen. +func ClearAll(screen *goro.Screen, entities[]*entity.Entity) { + for _, entity := range entities { + ClearEntity(screen, entity) +} +} +// DrawEntity draws a given entity to the screen. +func DrawEntity(screen *goro.Screen, e*entity.Entity) { + screen.DrawRune(e.X, e.Y, e.Rune, e.Style) +} +// ClearEntity clears a given entity from the screen. +func ClearEntity(screen *goro.Screen, e*entity.Entity) { + screen.DrawRune(e.X, e.Y, ' ', goro.Style{}) +} \ No newline at end of file diff --git a/steel b/steel new file mode 100755 index 0000000..e3fd169 Binary files /dev/null and b/steel differ