-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
83 lines (70 loc) · 1.65 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"bytes"
"image"
_ "image/png"
"io/ioutil"
"log"
"math/rand"
"time"
"github.com/gocs/kroek/domain"
"github.com/gocs/kroek/space"
"github.com/hajimehoshi/ebiten"
)
var (
screen *space.Screen
theGame *space.Game
w, h = 0, 0
)
func init() {
rand.Seed(time.Now().UnixNano())
// ebiten.SetFullscreen(true)
// w, h = ebiten.ScreenSizeInFullscreen()
// On mobiles, ebiten.MonitorSize is not available so far.
// Use arbitrary values.
if w == 0 || h == 0 {
// w = 300
w = 800
h = 450
}
screen = space.NewScreen(w, h)
content, err := ioutil.ReadFile("assets/pirate-treasure-map-sticker.png")
if err != nil {
log.Fatal(err)
}
img, _, err := image.Decode(bytes.NewReader(content))
if err != nil {
log.Fatal(err)
}
ebitenImage, _ := ebiten.NewImageFromImage(img, ebiten.FilterDefault)
content1, err := ioutil.ReadFile("assets/pirate-treasure-map-sticker-bigger.png")
if err != nil {
log.Fatal(err)
}
img1, _, err := image.Decode(bytes.NewReader(content1))
if err != nil {
log.Fatal(err)
}
ebitenImage1, _ := ebiten.NewImageFromImage(img1, ebiten.FilterDefault)
// Initialize the sprites.
sprites := []domain.Spriter{}
middlePosX, middlePosY := ebitenImage.Size()
var cities []*domain.City
mapSprite := domain.NewMapSprite(
screen,
ebitenImage,
ebitenImage1,
screen.Width()/2-middlePosX/2, screen.Height()/2-middlePosY/2,
cities)
sprites = append(sprites, mapSprite)
// Initialize the game.
theGame = space.NewGame(
map[*domain.Stroke]struct{}{},
sprites,
)
}
func main() {
if err := ebiten.Run(theGame.Update, screen.Width(), screen.Height(), 2, "Kroek"); err != nil {
log.Fatal(err)
}
}