Remove the -win-x and -win-y options for the ordoor binary
This commit is contained in:
@@ -19,11 +19,7 @@ type Game interface {
|
||||
|
||||
var (
|
||||
screenScale = flag.Float64("screen-scale", 1.0, "Scale the window by this factor")
|
||||
|
||||
winX = flag.Int("win-x", 1280, "Pre-scaled window X dimension")
|
||||
winY = flag.Int("win-y", 1024, "Pre-scaled window Y dimension")
|
||||
|
||||
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
|
||||
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
|
||||
)
|
||||
|
||||
type Window struct {
|
||||
@@ -36,12 +32,15 @@ type Window struct {
|
||||
|
||||
debug bool
|
||||
firstRun bool
|
||||
|
||||
xRes int
|
||||
yRes int
|
||||
}
|
||||
|
||||
// 0,0 is the *top left* of the window
|
||||
//
|
||||
// ebiten assumes a single window, so only call this once...
|
||||
func NewWindow(game Game, title string) (*Window, error) {
|
||||
func NewWindow(game Game, title string, xRes int, yRes int) (*Window, error) {
|
||||
ebiten.SetRunnableInBackground(true)
|
||||
|
||||
return &Window{
|
||||
@@ -50,6 +49,8 @@ func NewWindow(game Game, title string) (*Window, error) {
|
||||
debug: true,
|
||||
firstRun: true,
|
||||
game: game,
|
||||
xRes: xRes,
|
||||
yRes: yRes,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ func (w *Window) OnMouseWheel(f func(x, y float64)) {
|
||||
}
|
||||
|
||||
func (w *Window) Layout(_, _ int) (int, int) {
|
||||
return *winX, *winY
|
||||
return w.xRes, w.yRes
|
||||
}
|
||||
|
||||
func (w *Window) Update(screen *ebiten.Image) error {
|
||||
@@ -120,7 +121,7 @@ func (w *Window) Run() error {
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
ebiten.SetWindowSize(int(float64(*winX)**screenScale), int(float64(*winY)**screenScale))
|
||||
ebiten.SetWindowSize(int(float64(w.xRes)*(*screenScale)), int(float64(w.yRes)*(*screenScale)))
|
||||
ebiten.SetWindowTitle(w.Title)
|
||||
return ebiten.RunGame(w) // Native game resolution: 640x480
|
||||
return ebiten.RunGame(w)
|
||||
}
|
||||
|
Reference in New Issue
Block a user