1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2018 Dave Astels
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ """
24
+ A gaunlet running game using the dotstar wing and the joy wing.
25
+ """
26
+
27
+ import time
28
+ import random
29
+
1
30
import board
2
31
import busio
3
32
import dotstar_featherwing
4
33
import Adafruit_seesaw
5
- import time
6
- import random
7
34
8
35
i2c = busio .I2C (board .SCL , board .SDA )
9
36
ss = Adafruit_seesaw .Seesaw (i2c )
22
49
23
50
24
51
def run ():
52
+ """Play the game."""
53
+
25
54
player_position_col = 6
26
55
score = 0
27
56
steps = 0
@@ -48,7 +77,7 @@ def run():
48
77
else :
49
78
player_delta = 0
50
79
player_position_col += player_delta
51
-
80
+
52
81
under_player = wing .get_color (3 , player_position_col )
53
82
if under_player == background :
54
83
return steps , score
@@ -65,7 +94,7 @@ def run():
65
94
while True :
66
95
result = run ()
67
96
# got here because of a crash, so report and restart
68
- print ( 'Score: {} Steps: {}' .format (result [1 ], result [0 ]) )
97
+ print 'Score: {} Steps: {}' .format (result [1 ], result [0 ])
69
98
wing .clear ()
70
99
wing .show ()
71
100
wing .fill ((255 , 0 , 0 ))
0 commit comments