forked from gen2brain/raylib-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (35 loc) · 967 Bytes
/
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
package main
import (
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
message := "This sample illustrates a text writing\nanimation effect! Check it out! ;)"
length := len(message)
framesCounter := 0
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
// Update
if rl.IsKeyDown(rl.KeySpace) {
framesCounter += 8
} else {
framesCounter++
}
if rl.IsKeyPressed(rl.KeyEnter) {
framesCounter = 0
}
if framesCounter/10 > length {
framesCounter = length * 10
}
// Draw
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.DrawText(message[0:framesCounter/10], 210, 160, 20, rl.Maroon)
rl.DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, rl.LightGray)
rl.DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, rl.LightGray)
rl.EndDrawing()
}
rl.CloseWindow()
}