Skip to content

Commit

Permalink
clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Steinke committed Feb 17, 2024
1 parent a2cd1df commit c1cf6dd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
1 change: 0 additions & 1 deletion game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ input[name="difficulty-setting"] {
transition: 200ms;
}

.simon-button.active span {
.simon-button.active span,
.simon-button:active span {
background: none;
}

Expand Down
13 changes: 2 additions & 11 deletions ui/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c1cf6dd

Please sign in to comment.