-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinput.go
53 lines (47 loc) · 1.73 KB
/
input.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
package main
import (
"github.com/goxjs/glfw"
"github.com/shurcooL/eX0/eX0-go/packet"
)
// inputCommand returns a move.
func inputCommand(window *glfw.Window) packet.Move {
var move packet.Move
var direction [2]int8
if (window.GetKey(glfw.KeyA) != glfw.Release) && !(window.GetKey(glfw.KeyD) != glfw.Release) {
direction[0] = -1
} else if (window.GetKey(glfw.KeyD) != glfw.Release) && !(window.GetKey(glfw.KeyA) != glfw.Release) {
direction[0] = +1
}
if (window.GetKey(glfw.KeyW) != glfw.Release || window.GetKey(glfw.KeyUp) != glfw.Release) && !(window.GetKey(glfw.KeyS) != glfw.Release || window.GetKey(glfw.KeyDown) != glfw.Release) {
direction[1] = -1
} else if (window.GetKey(glfw.KeyS) != glfw.Release || window.GetKey(glfw.KeyDown) != glfw.Release) && !(window.GetKey(glfw.KeyW) != glfw.Release || window.GetKey(glfw.KeyUp) != glfw.Release) {
direction[1] = +1
}
switch {
case direction[0] == 0 && direction[1] == -1:
move.MoveDirection = 0
case direction[0] == 1 && direction[1] == -1:
move.MoveDirection = 1
case direction[0] == 1 && direction[1] == 0:
move.MoveDirection = 2
case direction[0] == 1 && direction[1] == 1:
move.MoveDirection = 3
case direction[0] == 0 && direction[1] == 1:
move.MoveDirection = 4
case direction[0] == -1 && direction[1] == 1:
move.MoveDirection = 5
case direction[0] == -1 && direction[1] == 0:
move.MoveDirection = 6
case direction[0] == -1 && direction[1] == -1:
move.MoveDirection = 7
default:
move.MoveDirection = -1
}
components.client.TargetZMu.Lock()
move.Z = components.client.TargetZ
components.client.TargetZMu.Unlock()
if window.GetKey(glfw.KeyLeftShift) != glfw.Release || window.GetKey(glfw.KeyRightShift) != glfw.Release {
move.Stealth = 1
}
return move
}