Skip to content

Commit de0d98f

Browse files
committed
(ui) add hints for the user
1 parent 5fe010c commit de0d98f

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ func run() {
8585

8686
// reset the matrix
8787
win.SetMatrix(pixel.IM)
88+
89+
// drall the UI
8890
ui.DrawStepNumber(win, simulation.Step)
8991
ui.DrawScore(win, simulation.Score)
9092
ui.DrawNumberOfVehicles(win, len(simulation.Vehicles))
9193
ui.DrawNumberOfTrips(win, len(simulation.Trips))
94+
ui.DrawStartHint(win)
95+
9296
win.Update()
9397
}
9498

screenshots/preview.gif

1.58 MB
Loading

ui/cam.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ var (
2121
func init() {
2222
camera = new(cam)
2323

24-
camera.CamPos = pixel.ZV
24+
camera.CamPos = pixel.V(500, 350)
2525
camera.CamSpeed = 500.0
2626
camera.CamZoom = 1.0
2727
camera.CamZoomSpeed = 1.2
2828
}
2929

30+
// Cam return the singleton cam
3031
func Cam() *cam {
3132
return camera
3233
}

ui/ui.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,47 @@ import (
1111

1212
func DrawScore(win *pixelgl.Window, score int) {
1313
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
14-
txt := text.New(pixel.V(920, 685), basicAtlas)
14+
txt := text.New(pixel.V(900, 685), basicAtlas)
1515

16-
fmt.Fprintf(txt, "Score : %06d", score)
16+
fmt.Fprintf(txt, "Score : %09d", score)
1717

1818
txt.Draw(win, pixel.IM)
1919
}
2020

2121
func DrawStepNumber(win *pixelgl.Window, step int) {
2222
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
23-
txt := text.New(pixel.V(920, 700), basicAtlas)
23+
txt := text.New(pixel.V(900, 700), basicAtlas)
2424

25-
fmt.Fprintf(txt, "Step : %06d", step)
25+
fmt.Fprintf(txt, "Step : %06d", step)
2626

2727
txt.Draw(win, pixel.IM)
2828
}
2929

3030
func DrawNumberOfVehicles(win *pixelgl.Window, numberOfVehicles int) {
3131
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
32-
txt := text.New(pixel.V(850, 670), basicAtlas)
32+
txt := text.New(pixel.V(830, 670), basicAtlas)
3333

34-
fmt.Fprintf(txt, "Number of cars : %04d", numberOfVehicles)
34+
fmt.Fprintf(txt, "Number of cars : %04d", numberOfVehicles)
3535

3636
txt.Draw(win, pixel.IM)
3737
}
3838

3939
func DrawNumberOfTrips(win *pixelgl.Window, numberOfTrips int) {
4040
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
41-
txt := text.New(pixel.V(850, 655), basicAtlas)
41+
txt := text.New(pixel.V(830, 655), basicAtlas)
4242

43-
fmt.Fprintf(txt, "Number of trips : %04d", numberOfTrips)
43+
fmt.Fprintf(txt, "Number of trips : %04d", numberOfTrips)
44+
45+
txt.Draw(win, pixel.IM)
46+
}
47+
48+
func DrawStartHint(win *pixelgl.Window) {
49+
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
50+
txt := text.New(pixel.V(340, 30), basicAtlas)
51+
52+
fmt.Fprintf(txt, " Press [T] to display all the trips (at your own risk)\n")
53+
fmt.Fprintf(txt, " [Arrow Keys] to move around [Scroll] to Zoom in/out \n")
54+
fmt.Fprintf(txt, " Press [SPACE] to start/pause simulation")
4455

4556
txt.Draw(win, pixel.IM)
4657
}

0 commit comments

Comments
 (0)