-
Notifications
You must be signed in to change notification settings - Fork 0
/
state_testing.go
49 lines (40 loc) · 927 Bytes
/
state_testing.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
package main
import (
"fmt"
rl "github.com/gen2brain/raylib-go/raylib"
)
type TestingState struct {
lastKeyCode, x, y int
State
}
func NewTestingState(e *Engine) *TestingState {
s := &TestingState{
State: State{e: e},
x: 0,
y: 0,
lastKeyCode: 0,
}
return s
}
func (s TestingState) Draw(dt float32) {
rl.ClearBackground(UIBackgroundColour)
// test sprite sheet whole
for y := 0; y < s.e.sprites.Rows; y++ {
for x := 0; x < s.e.sprites.Cols; x++ {
s.e.sprites.At(x, y).Draw(rl.NewVector2(float32(10+(10*x)), float32(50+(10*y))), PlayerColour)
}
}
s.e.font.Draw(s.lastKeyCode, rl.NewVector2(10, 200), PlayerColour)
}
func (s *TestingState) Update(dt float32) {
keyCode := int(rl.GetKeyPressed())
if keyCode > -1 {
if keyCode != s.lastKeyCode {
fmt.Println(keyCode)
}
s.lastKeyCode = keyCode
}
}
func (s TestingState) GetName() string {
return "Testing"
}