-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (46 loc) · 1.07 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
package main
import (
"log"
"image/color"
_ "image/png"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
);
const (
screenWidth int = 800;
screenHeight int = 600;
)
var img *ebiten.Image;
// Create Game Struct
type Game struct{};
func init() {
var err error;
img, _, err = ebitenutil.NewImageFromFile("./assets/visual/sprite/character/Cat_32.png");
if err != nil {
log.Fatal(err);
}
}
// Update
func (g *Game) Update() error {
return nil;
}
// Draw
func (g *Game) Draw(screen *ebiten.Image) {
// Fill Screen.
screen.Fill(color.RGBA{0xff, 0, 0xff, 0xa3});
// Text Log.
messageText := "Debug Log Test.";
ebitenutil.DebugPrint(screen, messageText);
screen.DrawImage(img, nil);
}
// Layout
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return 320, 240;
}
func main() {
ebiten.SetWindowSize(screenWidth, screenHeight);
ebiten.SetWindowTitle("Test Ebiten GUI");
if err := ebiten.RunGame(&Game{}); err != nil {
log.Fatal(err);
}
}