forked from gen2brain/raylib-go
/
main.go
36 lines (23 loc) · 773 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
package main
import (
"fmt"
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel")
boxPositionY := screenHeight/2 - 40
scrollSpeed := int32(4) // Scrolling speed in pixels
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
boxPositionY -= rl.GetMouseWheelMove() * scrollSpeed
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.DrawRectangle(screenWidth/2-40, boxPositionY, 80, 80, rl.Maroon)
rl.DrawText("Use mouse wheel to move the square up and down!", 10, 10, 20, rl.Gray)
rl.DrawText(fmt.Sprintf("Box position Y: %d", boxPositionY), 10, 40, 20, rl.LightGray)
rl.EndDrawing()
}
rl.CloseWindow()
}