@@ -73,12 +73,12 @@ func NewGame(width int, height int, fonts Fonts, tty io.Reader, adapter InputAda
7373 bounds , _ , _ := fonts .Normal .GlyphBounds ([]rune ("█" )[0 ])
7474 size := bounds .Max .Sub (bounds .Min )
7575
76- cellWidth := size .X .Round ()
77- cellHeight := size .Y .Round ()
78- cellOffsetY := - bounds .Min .Y .Round ()
76+ cellWidth := size .X .Ceil ()
77+ cellHeight := size .Y .Ceil ()
78+ cellOffsetY := - bounds .Min .Y .Ceil ()
7979
80- cellsWidth := width / cellWidth
81- cellsHeight := height / cellHeight
80+ cellsWidth := int ( float64 ( width ) * DeviceScale ()) / cellWidth
81+ cellsHeight := int ( float64 ( height ) * DeviceScale ()) / cellHeight
8282
8383 grid := make ([][]GridCell , cellsHeight )
8484 for y := 0 ; y < cellsHeight ; y ++ {
@@ -597,14 +597,13 @@ func (g *Window) Draw(screen *ebiten.Image) {
597597}
598598
599599func (g * Window ) Layout (outsideWidth , outsideHeight int ) (int , int ) {
600- return g .cellsWidth * g .cellWidth , g .cellsHeight * g .cellHeight
600+ s := DeviceScale ()
601+ return int (float64 (outsideWidth ) * s ), int (float64 (outsideHeight ) * s )
601602}
602603
603604func (g * Window ) Run (title string ) error {
604- sw , sh := g .Layout (0 , 0 )
605-
606605 ebiten .SetScreenFilterEnabled (false )
607- ebiten .SetWindowSize (sw , sh )
606+ ebiten .SetWindowSize (int ( float64 ( g . cellsWidth * g . cellWidth ) / DeviceScale ()), int ( float64 ( g . cellsHeight * g . cellHeight ) / DeviceScale ()) )
608607 ebiten .SetWindowTitle (title )
609608 if err := ebiten .RunGame (g ); err != nil {
610609 return err
0 commit comments