-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplayer.go
50 lines (41 loc) · 944 Bytes
/
player.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 (
"net"
)
// Player-related functions, including inventory status, position, health, etc.
type PlayerCoords struct {
// Normal coordinate structure within the world, used for all entities.
WorldCoords
// YTop is the top of the player's bounding box, sometimes refered to as "stance"
YTop float64
OnGround bool
}
type PlayerLook struct {
Yaw float32
Pitch float32
OnGround bool
}
var playerPosition *PlayerCoords
var playerLook *PlayerLook
func UpdatePlayerPos(pp *PlayerCoords) {
if pp.YTop - pp.Y < 0.1 {
log3.Println("Illegal stance!")
pp.YTop = pp.Y + 0.2
}
if pp.YTop - pp.Y > 1.65 {
log3.Println("Illegal stance!")
pp.YTop = pp.Y + 1.5
}
playerPosition = pp
}
func UpdatePlayerLook(pl *PlayerLook) {
playerLook = pl
}
func SetPlayerPos(c net.Conn, pp *PlayerCoords) {
UpdatePlayerPos(pp)
SendPlayerPos(c, pp)
}
func GetPlayerPos() *PlayerCoords {
tmp := *playerPosition
return &tmp
}