-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
68 lines (52 loc) · 1.21 KB
/
main.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
package main
import (
"machine"
"time"
"github.com/cdreier/tinygo-twang/twang"
"tinygo.org/x/drivers/ws2812"
)
const leds = 60
func main() {
// machine.InitADC()
machine.D8.Configure(machine.PinConfig{
Mode: machine.PinOutput,
})
led := ws2812.New(machine.D8)
// xPin := machine.ADC{Pin: machine.ADC0}
// xPin.Configure(machine.ADCConfig{})
machine.D0.Configure(machine.PinConfig{
Mode: machine.PinInputPullup,
})
// var middleX uint16 = 65534 / 2
// var threshold uint16 = 3000
game := twang.NewGame(leds, twang.NewPlayer(leds))
game.LoadLevels([]twang.Level{
// twang.NewLevelDebug(game),
twang.NewLevel1(game),
twang.NewLevel2(game),
twang.NewLevel3(game),
twang.NewLevel4(game),
twang.NewLevel5(game),
twang.NewLevel6(game),
twang.NewLevel7(game),
twang.NewLevel8(game),
twang.NewLevel9(game),
twang.NewLevel10(game),
twang.NewLevel11(game),
})
for {
attack := !machine.D0.Get()
game.Player.Attack(attack)
// if !attack {
// x := xPin.Get()
// if x < middleX-threshold {
// game.Player.Move(-1)
// } else if x > middleX+threshold {
// game.Player.Move(1)
// }
// }
game.Update()
game.Render(led)
time.Sleep(50 * time.Millisecond)
}
}