-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameInfo.go
56 lines (50 loc) · 1.69 KB
/
gameInfo.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
package main
import (
"fmt"
"image"
"image/color"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/text"
)
var (
displayInfo bool = false
canChangeDisplayInfo bool = true // If you can press f5 again
version = "0.2.6" // Game version
title = "UNRAY ALPHA" // Game title
devVersion = true // Is it in development or release?
)
func displayGameInfo(screen *ebiten.Image, player Player) {
// Draw box
boxRect := image.Rect(0, 16, 100, 51)
op := &ebiten.DrawImageOptions{}
informationBoxPosition := newVec2f(0, 0)
op.GeoM.Translate(informationBoxPosition.x, informationBoxPosition.y)
screen.DrawImage(iUISpritesheet.SubImage(boxRect).(*ebiten.Image), op)
// Draw UNRAY V...
versionFontPosition := newVec2i(2, 10)
dev := ""
if devVersion {
dev = "d"
}
msg := fmt.Sprintf("%s v%s%s", title, version, dev)
text.Draw(screen, msg, mversionFont, versionFontPosition.x, versionFontPosition.y, color.NRGBA{255, 0, 0, 255})
// Draw info
tpsFontPosition := newVec2i(2, 20)
msg = fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS())
text.Draw(screen, msg, mdataFont, tpsFontPosition.x, tpsFontPosition.y, color.White)
// Draw player movement
movementFontPosition := newVec2i(2, 30)
msg = fmt.Sprintf("Movement: %s", player.movement)
text.Draw(screen, msg, mdataFont, movementFontPosition.x, movementFontPosition.y, color.NRGBA{200, 200, 200, 200})
}
// Check if the game should display game info or not
func checkChangeDisplayInfo() {
if !ebiten.IsKeyPressed(ebiten.KeyF5) {
canChangeDisplayInfo = true
} else {
if canChangeDisplayInfo {
displayInfo = !displayInfo
canChangeDisplayInfo = false
}
}
}