-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene_menu.go
65 lines (51 loc) · 1.92 KB
/
scene_menu.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
package main
import (
"fmt"
"rapidengine/child"
)
var MenuBackChild *child.Child2D
func InitializeMenuScene() {
MenuScene = Engine.SceneControl.NewScene("menu")
MenuBackChild = Engine.ChildControl.NewChild2D()
MenuBackChild.ScaleX = 200
MenuBackChild.ScaleY = 300
MenuBackChild.Static = true
MenuBackChild.SetPosition(620, 250)
resumeText := Engine.TextControl.NewTextBox("Resume", "pixel", 100, 500, 1, [3]float32{255, 255, 255})
saveText := Engine.TextControl.NewTextBox("Save", "pixel", 100, 400, 1, [3]float32{255, 255, 255})
exitText := Engine.TextControl.NewTextBox("Exit", "pixel", 100, 300, 1, [3]float32{255, 255, 255})
resumeButton := Engine.UIControl.NewUIButton(100, 500, 200, 50)
resumeButton.SetClickCallback(resume)
resumeButton.AttachText(resumeText)
resumeButton.ButtonChild.AttachMaterial(ButtonMaterial)
saveButton := Engine.UIControl.NewUIButton(100, 400, 200, 50)
saveButton.SetClickCallback(save)
saveButton.AttachText(saveText)
saveButton.ButtonChild.AttachMaterial(ButtonMaterial)
exitButton := Engine.UIControl.NewUIButton(100, 300, 200, 50)
exitButton.SetClickCallback(exitToTitle)
exitButton.AttachText(exitText)
exitButton.ButtonChild.AttachMaterial(ButtonMaterial)
Engine.UIControl.AlignCenter(resumeButton)
Engine.UIControl.AlignCenter(saveButton)
Engine.UIControl.AlignCenter(exitButton)
Engine.UIControl.InstanceElement(resumeButton, MenuScene)
Engine.UIControl.InstanceElement(saveButton, MenuScene)
Engine.UIControl.InstanceElement(exitButton, MenuScene)
MenuScene.InstanceChild(MenuBackChild)
MenuScene.Deactivate()
}
func resume() {
GamePaused = false
MenuScene.Deactivate()
}
func save() {
Engine.SceneControl.SetCurrentScene(SaveScene)
WorldMap.WriteToFile("./worlds/world" + fmt.Sprint(CurrentWorld) + ".hln")
Engine.SceneControl.SetCurrentScene(WorldScene)
MenuScene.Activate()
}
func exitToTitle() {
exitButton.Block()
Engine.SceneControl.SetCurrentScene(TitleScene)
}