Use screen scaling
This commit is contained in:
@@ -13,8 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
winX = flag.Int("win-x", 1280, "width of the view-map window")
|
screenScale = flag.Float64("screen-scale", 1.0, "Scale the window by this factor")
|
||||||
winY = flag.Int("win-y", 1024, "height of the view-map window")
|
|
||||||
|
|
||||||
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
|
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
|
||||||
)
|
)
|
||||||
@@ -29,6 +28,7 @@ type Window struct {
|
|||||||
drawFn func(*ebiten.Image) error
|
drawFn func(*ebiten.Image) error
|
||||||
|
|
||||||
debug bool
|
debug bool
|
||||||
|
firstRun bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0,0 is the *top left* of the window
|
// 0,0 is the *top left* of the window
|
||||||
@@ -41,6 +41,7 @@ func NewWindow(title string) (*Window, error) {
|
|||||||
Title: title,
|
Title: title,
|
||||||
KeyUpHandlers: make(map[ebiten.Key]func()),
|
KeyUpHandlers: make(map[ebiten.Key]func()),
|
||||||
debug: true,
|
debug: true,
|
||||||
|
firstRun: true,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +55,11 @@ func (w *Window) OnMouseWheel(f func(x, y float64)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) run(screen *ebiten.Image) error {
|
func (w *Window) run(screen *ebiten.Image) error {
|
||||||
|
if w.firstRun {
|
||||||
|
ebiten.SetScreenScale(*screenScale)
|
||||||
|
w.firstRun = false
|
||||||
|
}
|
||||||
|
|
||||||
if err := w.updateFn(); err != nil {
|
if err := w.updateFn(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -108,5 +114,5 @@ func (w *Window) Run(updateFn func() error, drawFn func(*ebiten.Image) error) er
|
|||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
return ebiten.Run(w.run, *winX, *winY, 1, w.Title)
|
return ebiten.Run(w.run, 640, 480, 1, w.Title) // Native game resolution: 640x480
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user