Skip to content

Commit 00d0172

Browse files
committed
(main) v0.5
1 parent d22adc6 commit 00d0172

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

main.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
func createGrid(sizeX, sizeY int32) *imdraw.IMDraw {
3030
imd := imdraw.New(nil)
3131

32-
imd.Color = colornames.Blueviolet
32+
imd.Color = config.Config.UI.GridColor
3333
imd.EndShape = imdraw.RoundEndShape
3434
squareSize := config.Config.UI.SquareSize
3535
for x := int32(0); x < sizeX; x++ {
@@ -46,7 +46,7 @@ func createGrid(sizeX, sizeY int32) *imdraw.IMDraw {
4646
}
4747

4848
func init() {
49-
frameRate = flag.Duration("frameRate", 33*time.Millisecond, "The framerate in milliseconds")
49+
frameRate = flag.Duration("frameRate", 1*time.Millisecond, "The framerate in milliseconds")
5050
outputFile = flag.String("o", "", "Path to your result")
5151
inputFile = flag.String("i", "", "Path to the exercice input")
5252
flag.Parse()
@@ -59,29 +59,42 @@ func run() {
5959

6060
cfg := pixelgl.WindowConfig{
6161
Title: config.Config.UI.WindowTitle,
62-
Bounds: pixel.R(0, 0, 1024, 768),
62+
Bounds: pixel.R(0, 0, 1500, 900),
6363
}
6464
win, err := pixelgl.NewWindow(cfg)
6565
if err != nil {
6666
panic(err)
6767
}
6868

69-
grid := createGrid(100, 100)
69+
// grid := createGrid(100, 100)
7070

7171
tick := time.Tick(*frameRate)
72+
73+
step := 0
74+
lastStep := 0
7275
for !win.Closed() {
7376
// logic loop
7477
frames++
7578
select {
7679
case <-tick:
7780
win.Clear(colornames.Whitesmoke)
78-
grid.Draw(win)
79-
for _, vehicle := range vehicles {
80-
vehicle.DrawToWindow(win)
81+
// grid.Draw(win)
82+
// fmt.Printf("STEP (%d)\n", step)
83+
if win.JustPressed(pixelgl.KeyRight) {
8184
}
85+
step++
8286
for _, trip := range trips {
8387
trip.DrawToWindow(win)
8488
}
89+
for _, vehicle := range vehicles {
90+
if lastStep != step {
91+
vehicle.Drive(trips)
92+
}
93+
vehicle.DrawToWindow(win)
94+
}
95+
if lastStep != step {
96+
lastStep = step
97+
}
8598
case <-second:
8699
win.SetTitle(fmt.Sprintf("%s | FPS: %d", cfg.Title, frames))
87100
frames = 0

0 commit comments

Comments
 (0)