-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (74 loc) · 1.82 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
84
85
86
87
88
89
90
91
92
93
package main
import (
"bytes"
"encoding/base64"
"flag"
"fmt"
"io"
"time"
"github.com/faiface/pixel/pixelgl"
"github.com/bobtfish/mayhem/character"
"github.com/bobtfish/mayhem/game"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/player"
"github.com/bobtfish/mayhem/render"
"github.com/bobtfish/mayhem/screen"
screeniface "github.com/bobtfish/mayhem/screen/iface"
_ "github.com/bobtfish/mayhem/otherspells"
_ "github.com/bobtfish/mayhem/spellswithscreen"
)
func loadSpriteSheet() io.Reader {
data, err := base64.StdEncoding.DecodeString(sprite_sheet_base64)
if err != nil {
panic(err)
}
return bytes.NewReader(data)
}
func run() {
character.LoadCharacterTemplates()
quickPtr := flag.Bool("quick", false, "Skip Intro questions")
flag.Parse()
title := "Mayhem!"
spriteReader := loadSpriteSheet()
ss := render.GetSpriteSheet(spriteReader)
gw := game.NewWindow(ss)
var s screeniface.GameScreen
s = &screen.InitialScreen{}
s.Enter(gw)
if *quickPtr {
fred := player.NewPlayer()
fred.Name = "fred"
fred.CharacterIcon = logical.V(0, 23)
fred.Color = render.GetColor(255, 0, 0)
bob := player.NewPlayer()
bob.Name = "bob"
bob.CharacterIcon = logical.V(1, 23)
bob.Color = render.GetColor(255, 0, 255)
gw.AddPlayer(fred)
gw.AddPlayer(bob)
s = &screen.StartMainGame{}
s.Enter(gw)
}
// players := getPlayers()
// placePlayers(players, grid)
//placeCharactersTest(grid, ct)
frames := 0
Second := time.Tick(time.Second)
for !gw.Closed() {
//sd := render.NewSpriteDrawer(ss).WithOffset(render.GameBoardV())
//batch := grid.DrawBatch(sd)
//batch.Draw(gw.Window)
s = gw.Update(s)
frames++
select {
case <-Second:
gw.Window.SetTitle(fmt.Sprintf("%s | FPS: %d", title, frames))
frames = 0
//blowSomethingUp(grid)
default:
}
}
}
func main() {
pixelgl.Run(run)
}