mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/2048: high resolution
This commit is contained in:
parent
6334320762
commit
f1cb294913
@ -28,8 +28,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScreenWidth = 210
|
ScreenWidth = 420
|
||||||
ScreenHeight = 300
|
ScreenHeight = 600
|
||||||
boardSize = 4
|
boardSize = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user