Skip to content

Commit ac2901f

Browse files
committed
(ui) fix its position
1 parent 3eb7619 commit ac2901f

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func run() {
134134
win.SetTitle(fmt.Sprintf("%s | FPS: %d", cfg.Title, frames))
135135
frames = 0
136136
}
137+
138+
win.SetMatrix(pixel.IM)
137139
ui.DrawStepNumber(win, step)
138140
ui.DrawScore(win, 0)
139141
ui.DrawNumberOfVehicles(win, len(vehicles))

ui/ui.go

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

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

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

18-
basicTxt.Draw(win, pixel.IM)
18+
txt.Draw(win, pixel.IM)
1919
}
2020

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

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

27-
basicTxt.Draw(win, pixel.IM)
27+
txt.Draw(win, pixel.IM)
2828
}
2929

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

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

36-
basicTxt.Draw(win, pixel.IM)
36+
txt.Draw(win, pixel.IM)
3737
}
3838

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

43-
fmt.Fprintf(basicTxt, "Number of trips : %04d", numberOfTrips)
43+
fmt.Fprintf(txt, "Number of trips : %04d", numberOfTrips)
4444

45-
basicTxt.Draw(win, pixel.IM)
45+
txt.Draw(win, pixel.IM)
4646
}

0 commit comments

Comments
 (0)