-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.go
49 lines (42 loc) · 1.17 KB
/
game.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
package main
import (
"bytes"
"engo.io/engo"
"engo.io/engo/common"
"engo.io/ecs"
"image/color"
"golang.org/x/image/font/gofont/gosmallcaps"
"./systems"
)
type myScene struct {}
func (*myScene) Type() string { return "myGame" }
func (*myScene) Preload() {
//"tilemap/tilesheet_grass.png"
//https://pipoya.net/sozai/
engo.Files.Load("pics/greenoctocat.png", "pics/ghost.png", "tilemap/tilesheet_grass.png", "tilemap/tilesheet_snow.png")
engo.Files.LoadReaderData("go.ttf", bytes.NewReader(gosmallcaps.TTF))
common.SetBackground(color.RGBA{255, 250, 220, 0})
}
func (*myScene) Setup(u engo.Updater){
engo.Input.RegisterButton("MoveRight", engo.KeyD, engo.KeyArrowRight)
engo.Input.RegisterButton("MoveLeft", engo.KeyA, engo.KeyArrowLeft)
engo.Input.RegisterButton("Jump", engo.KeySpace)
world, _ := u.(*ecs.World)
world.AddSystem(&common.RenderSystem{})
world.AddSystem(&systems.TileSystem{})
world.AddSystem(&systems.PlayerSystem{})
world.AddSystem(&systems.EnemySystem{})
}
func (*myScene) Exit() {
engo.Exit()
}
func main(){
opts := engo.RunOptions{
Title:"myGame",
Width:400,
Height:300,
StandardInputs: true,
NotResizable:true,
}
engo.Run(opts,&myScene{})
}