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 (
ScreenWidth = 210
ScreenHeight = 300
ScreenWidth = 420
ScreenHeight = 600
boardSize = 4
)

View File

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

View File

@ -44,7 +44,7 @@ func main() {
if err != nil {
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)
}
}