diff --git a/game/game.go b/game/game.go index cbbf533..56f6bbf 100644 --- a/game/game.go +++ b/game/game.go @@ -46,7 +46,6 @@ type Game struct { } func (g *Game) simonSays(ctx app.Context, sequence []int64) { - fmt.Println(sequence) ctx.Async(func() { <-time.After(200 * time.Millisecond) for _, btnIndex := range sequence { diff --git a/main.go b/main.go index 7514b98..f152873 100644 --- a/main.go +++ b/main.go @@ -18,11 +18,10 @@ func main() { flag.Parse() l := game.New() - // TODO: improve statistics + // TODO: improved statistics // TODO: for endless mode add histogram of how far you got. // TODO: add tests // TODO: add dependabot - // TODO: add linter app.Handle(ui.EventClick, l.HandleClick) app.Handle(ui.EventNewGame, l.HandleNewGame) diff --git a/styles.css b/styles.css index 881196f..202e906 100644 --- a/styles.css +++ b/styles.css @@ -150,7 +150,8 @@ input[name="difficulty-setting"] { transition: 200ms; } -.simon-button.active span { +.simon-button.active span, +.simon-button:active span { background: none; } diff --git a/ui/button.go b/ui/button.go index f42597f..b10ce3c 100644 --- a/ui/button.go +++ b/ui/button.go @@ -40,20 +40,11 @@ func (b *button) Render() app.UI { } func (b *button) handleClick(ctx app.Context, _ app.Event) { - // Needs a short delay because it doesn't work if it is done directly on click - ctx.After(50*time.Millisecond, func(_ app.Context) { - b.Active = true - ctx.After(400*time.Millisecond, func(_ app.Context) { - b.Active = false - ctx.NewActionWithValue(EventClick, b.id) - }) - }) + ctx.NewActionWithValue(EventClick, b.id) } func (b *button) handlePlayButton(ctx app.Context, _ app.Action) { - ctx.Dispatch(func(_ app.Context) { - b.Active = true - }) + b.Active = true ctx.After(800*time.Millisecond, func(_ app.Context) { ctx.Dispatch(func(_ app.Context) { b.Active = false diff --git a/ui/ui.go b/ui/ui.go index 38f843a..022d956 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -87,7 +87,5 @@ func (u *UI) handleStateChange(ctx app.Context, a app.Action) { fmt.Println("wrong type") return } - ctx.Dispatch(func(_ app.Context) { - u.Text = txt - }) + u.Text = txt }