examples/2048: high resolution

This commit is contained in:
Hajime Hoshi 2018-01-19 12:12:29 +09:00
parent 6334320762
commit f1cb294913
3 changed files with 17 additions and 8 deletions

View File

@ -28,8 +28,8 @@ func init() {
} }
const ( const (
ScreenWidth = 210 ScreenWidth = 420
ScreenHeight = 300 ScreenHeight = 600
boardSize = 4 boardSize = 4
) )

View File

@ -34,6 +34,7 @@ import (
) )
var ( var (
mplusSmallFont font.Face
mplusNormalFont font.Face mplusNormalFont font.Face
mplusBigFont font.Face mplusBigFont font.Face
) )
@ -56,13 +57,18 @@ func init() {
} }
const dpi = 72 const dpi = 72
mplusSmallFont = truetype.NewFace(tt, &truetype.Options{
Size: 24,
DPI: dpi,
Hinting: font.HintingFull,
})
mplusNormalFont = truetype.NewFace(tt, &truetype.Options{ mplusNormalFont = truetype.NewFace(tt, &truetype.Options{
Size: 12, Size: 32,
DPI: dpi, DPI: dpi,
Hinting: font.HintingFull, Hinting: font.HintingFull,
}) })
mplusBigFont = truetype.NewFace(tt, &truetype.Options{ mplusBigFont = truetype.NewFace(tt, &truetype.Options{
Size: 24, Size: 48,
DPI: dpi, DPI: dpi,
Hinting: font.HintingFull, Hinting: font.HintingFull,
}) })
@ -341,8 +347,8 @@ func meanF(a, b float64, rate float64) float64 {
} }
const ( const (
tileSize = 40 tileSize = 80
tileMargin = 2 tileMargin = 4
) )
var ( var (
@ -400,7 +406,10 @@ func (t *Tile) Draw(boardImage *ebiten.Image) {
str := strconv.Itoa(v) str := strconv.Itoa(v)
f := mplusBigFont f := mplusBigFont
if 2 < len(str) { switch {
case 3 < len(str):
f = mplusSmallFont
case 2 < len(str):
f = mplusNormalFont f = mplusNormalFont
} }

View File

@ -44,7 +44,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
if err := ebiten.Run(update, twenty48.ScreenWidth, twenty48.ScreenHeight, 2, "2048 (Ebiten Demo)"); err != nil { if err := ebiten.Run(update, twenty48.ScreenWidth, twenty48.ScreenHeight, 1, "2048 (Ebiten Demo)"); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }