Skip to content

Commit

Permalink
(ui) add hints for the user
Browse files Browse the repository at this point in the history
  • Loading branch information
AkselsLedins committed Mar 6, 2018
1 parent 5fe010c commit de0d98f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ func run() {

// reset the matrix
win.SetMatrix(pixel.IM)

// drall the UI
ui.DrawStepNumber(win, simulation.Step)
ui.DrawScore(win, simulation.Score)
ui.DrawNumberOfVehicles(win, len(simulation.Vehicles))
ui.DrawNumberOfTrips(win, len(simulation.Trips))
ui.DrawStartHint(win)

win.Update()
}

Expand Down
Binary file modified screenshots/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion ui/cam.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ var (
func init() {
camera = new(cam)

camera.CamPos = pixel.ZV
camera.CamPos = pixel.V(500, 350)
camera.CamSpeed = 500.0
camera.CamZoom = 1.0
camera.CamZoomSpeed = 1.2
}

// Cam return the singleton cam
func Cam() *cam {
return camera
}
Expand Down
27 changes: 19 additions & 8 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,47 @@ import (

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

fmt.Fprintf(txt, "Score : %06d", score)
fmt.Fprintf(txt, "Score : %09d", score)

txt.Draw(win, pixel.IM)
}

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

fmt.Fprintf(txt, "Step : %06d", step)
fmt.Fprintf(txt, "Step : %06d", step)

txt.Draw(win, pixel.IM)
}

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

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

txt.Draw(win, pixel.IM)
}

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

fmt.Fprintf(txt, "Number of trips : %04d", numberOfTrips)
fmt.Fprintf(txt, "Number of trips : %04d", numberOfTrips)

txt.Draw(win, pixel.IM)
}

func DrawStartHint(win *pixelgl.Window) {
basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
txt := text.New(pixel.V(340, 30), basicAtlas)

fmt.Fprintf(txt, " Press [T] to display all the trips (at your own risk)\n")
fmt.Fprintf(txt, " [Arrow Keys] to move around [Scroll] to Zoom in/out \n")
fmt.Fprintf(txt, " Press [SPACE] to start/pause simulation")

txt.Draw(win, pixel.IM)
}

0 comments on commit de0d98f

Please sign in to comment.