From baab07480c40d6186f8a68cf50fe78d245296c07 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 24 Oct 2020 23:42:51 +0000 Subject: [PATCH] can walk around --- ui.go | 26 ++++++++++++++++++++++++++ ui_mode.go | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 ui_mode.go diff --git a/ui.go b/ui.go index e3fdb72..906ab3f 100644 --- a/ui.go +++ b/ui.go @@ -69,6 +69,16 @@ func (ui *ui) menu() { ui.writeString(0, height-1, "fart", tcell.StyleDefault) ui.screen.Sync() + type point struct{ x, y int } + position := point{10, 10} + + redraw := func() { + ui.screen.Clear() + ui.screen.SetContent(position.x, position.y, '+', nil, tcell.StyleDefault) + ui.screen.Show() + } + redraw() + for { e := ui.screen.PollEvent() if e == nil { @@ -81,6 +91,22 @@ func (ui *ui) menu() { if key == tcell.KeyCtrlC { return } + if key == tcell.KeyRune { + switch v.Rune() { + case 'w': + position.y-- + redraw() + case 'a': + position.x-- + redraw() + case 's': + position.y++ + redraw() + case 'd': + position.x++ + redraw() + } + } default: log.Debug("screen saw unhandled event of type %T", e) } diff --git a/ui_mode.go b/ui_mode.go new file mode 100644 index 0000000..fe65cd4 --- /dev/null +++ b/ui_mode.go @@ -0,0 +1,4 @@ +package main + +type uiMode interface { +}