-
Notifications
You must be signed in to change notification settings - Fork 0
/
result_scene.go
35 lines (25 loc) · 936 Bytes
/
result_scene.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
package main
import (
"fmt"
"github.com/boynux/goward/actions"
"github.com/gen2brain/raylib-go/raygui"
rl "github.com/gen2brain/raylib-go/raylib"
)
const Message = "%d correct out of %d questions"
var actionTriggered = false
func showResults(total, correct int32, a actions.Action) bool {
if float32(correct) / float32(total) * 100.0 < 70 {
actionTriggered = true
}
s := fmt.Sprintf(Message, correct, total)
o := rl.MeasureText(s, rl.GetFontDefault().BaseSize)
r := rl.NewRectangle(float32(int32(rl.GetScreenWidth())-o)/2, float32(rl.GetScreenHeight())/2-20, 20, 20)
raygui.Label(r, s)
r = rl.NewRectangle(float32(rl.GetScreenWidth())/2-20, float32(rl.GetScreenHeight())/2+30, 40, 20)
action := raygui.Button(r, "Turn on TV")
if !actionTriggered && action {
a(correct)
}
r = rl.NewRectangle(float32(rl.GetScreenWidth())/2-20, float32(rl.GetScreenHeight())/2+5, 40, 20)
return raygui.Button(r, "Retry")
}