-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.go
80 lines (75 loc) · 1.91 KB
/
init.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
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
func startTubes(TubePos *[5][2]Tube, Player *goppy) {
for i := 0; i < len(TubePos); i++ {
if i == 0 {
TubePos[i][0] = Tube{
Source: rl.Rectangle{X: 55, Y: 323, Width: 27, Height: 161},
DestRec: rl.Rectangle{X: 850, Y: float32(rl.GetRandomValue(-400, -150)), Width: 27 * 3, Height: 3 * 161},
}
} else {
TubePos[i][0] = Tube{
Source: rl.Rectangle{X: 55, Y: 323, Width: 27, Height: 161},
DestRec: rl.Rectangle{X: TubePos[i-1][0].DestRec.X + TubePos[i-1][0].DestRec.Width + Xspace,
Y: float32(rl.GetRandomValue(-400, -150)),
Width: 27 * 3,
Height: 3 * 161},
}
}
TubePos[i][1] = Tube{
Source: rl.Rectangle{X: 83, Y: 320, Width: 27, Height: 161},
DestRec: rl.Rectangle{
X: TubePos[i][0].DestRec.X,
Y: TubePos[i][0].DestRec.Y + TubePos[i][0].DestRec.Height + Yspace,
Width: 27 * 3,
Height: 161 * 3},
}
}
Player.DestRec = rl.Rectangle{
X: 140,
Y: 360,
Width: Player.SourceRec.Width * Scale,
Height: Player.SourceRec.Height * Scale,
}
}
func (Game *Game) initGame() {
Game.Player = goppy{
SourceRec: rl.Rectangle{
X: 0,
Y: 491,
Width: 28,
Height: 12,
},
}
startTubes(&Game.TubePos, &Game.Player)
Game.Player.Origin = rl.Vector2{
X: Game.Player.DestRec.Width / 2,
Y: Game.Player.DestRec.Height / 2,
}
Game.Player.CircleCol = Circle{
Origin: rl.Vector2{
X: Game.Player.DestRec.X,
Y: Game.Player.DestRec.Y,
},
Radios: 17,
}
Game.Foreground.RecSource = rl.Rectangle{
X: 292,
Y: 0,
Width: 167,
Height: 56,
}
Game.Foreground.RecDest = rl.Rectangle{
X: 0,
Y: 570,
Width: ScreenWidth,
Height: 200,
}
Game.Player.FrameSpeed = 8
Game.Player.SpeedY = 5
Game.Over = false
Game.Pause = false
Game.Score = 0
}