-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.go
67 lines (55 loc) · 1.86 KB
/
models.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
66
67
package main
import (
"image/color"
rl "github.com/gen2brain/raylib-go/raylib"
)
func DrawTracks() {
// Track
rl.DrawCube(rl.NewVector3(0, 0, 0), 5, 0.5, 20, rl.ColorFromNormalized(rl.NewVector4(0.35, 0.35, 0.35, 1)))
// Lanes
rl.DrawCube(rl.NewVector3(-2.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
rl.DrawCube(rl.NewVector3(-1.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
rl.DrawCube(rl.NewVector3(-0.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
rl.DrawCube(rl.NewVector3(0.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
rl.DrawCube(rl.NewVector3(1.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
rl.DrawCube(rl.NewVector3(2.5, 0.05, 0), 0.05, 0.5, 20, rl.White)
}
func DrawDisk(lane int, position float32) {
// -10 - Disk spawn position
// 6 - Disk perfect position
// 10 - Disk destroy position
colors := []color.RGBA{rl.Green, rl.Red, rl.Yellow, rl.Blue, rl.Orange}
rl.DrawSphere(rl.NewVector3(float32(-2+lane), 0.1, position), 0.4, colors[lane])
}
func DrawMarker(lane int, song [][]Note, score *int) {
colors := []color.RGBA{rl.Green, rl.Red, rl.Yellow, rl.Blue, rl.Orange}
var color color.RGBA
keys := []int32{rl.KeyA, rl.KeyS, rl.KeyJ, rl.KeyK, rl.KeyL}
height := 0.5
if rl.IsKeyDown(keys[lane]) {
height = 0.6
color = colors[lane]
foundNote := false
if rl.IsKeyPressed(keys[lane]) {
for i := range song {
for j := range song[i] {
if song[i][j].Position > 5.5 && song[i][j].Position < 6.5 && song[i][j].Lane == lane && !song[i][j].Pressed {
song[i][j].Pressed = true
*score += 1
foundNote = true
PlaySound(notes[lane], "4")
}
}
}
if !foundNote {
*score -= 1
PlaySound(notes[lane], "1")
}
}
} else {
height = 0.5
color = rl.DarkGray
}
rl.DrawCylinder(rl.NewVector3(float32(-2+lane), -0.25, 6.5), 0.4, 0.4, 0.5, 12, rl.Gray)
rl.DrawCylinder(rl.NewVector3(float32(-2+lane), -0.2, 6.5), 0.3, 0.3, float32(height), 12, color)
}