Skip to content

Commit 5fe010c

Browse files
committed
(ui:options) add the ability to hide/show all trips
1 parent 97cb295 commit 5fe010c

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

ghashcode/trip.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"math"
66

77
config "github.com/AkselsLedins/google-hashcode-2018-live-simulation/config"
8+
"github.com/AkselsLedins/google-hashcode-2018-live-simulation/ui"
89

910
"github.com/faiface/pixel"
1011
"github.com/faiface/pixel/imdraw"
@@ -50,7 +51,7 @@ type Trip struct {
5051
func (t *Trip) AddToImd(imd *imdraw.IMDraw) {
5152
// we only show taken trips for performance
5253
// TODO a way to desactivate this
53-
if !t.Taken {
54+
if !t.Taken && !ui.Options().ShowAllTrips {
5455
return
5556
}
5657

simulator/events.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ func (s *Simulation) HandleEvents(win *pixelgl.Window, dt float64) {
1010
s.Toggle()
1111
}
1212

13+
if win.JustPressed(pixelgl.KeyT) {
14+
ui.Options().ShowAllTrips = !ui.Options().ShowAllTrips
15+
}
16+
1317
if win.Pressed(pixelgl.KeyLeft) {
1418
ui.Cam().CamPos.X -= ui.Cam().CamSpeed * dt
1519
}

ui/options.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ui
2+
3+
type options struct {
4+
ShowAllTrips bool
5+
}
6+
7+
var (
8+
opt *options
9+
)
10+
11+
func init() {
12+
opt = new(options)
13+
opt.ShowAllTrips = false
14+
}
15+
16+
func Options() *options {
17+
return opt
18+
}

0 commit comments

Comments
 (0)