File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -100,11 +100,8 @@ def win_focus():
100
100
# Create a list of all possible locations
101
101
s = list (range (0 , BOARD_SIZE ** 2 ))
102
102
# Delete cells that are part of the snake
103
- try :
104
- for part in snake :
105
- s .remove (part .x * BOARD_SIZE + part .y )
106
- except :
107
- pass
103
+ for part in snake :
104
+ s .remove (part .x * BOARD_SIZE + part .y )
108
105
109
106
# Randomly pick from one of the remaining cells
110
107
a = choice (s )
@@ -151,14 +148,16 @@ def win_focus():
151
148
152
149
if quit :
153
150
break
154
-
151
+
152
+ # The snake grows graduallly over multiple frames
153
+ if grow > 0 :
154
+ snake .append (SnakePart (snake [- 1 ], subx , suby ))
155
+ grow -= 1
156
+
155
157
# Grows the snake when it eats an apple
156
158
if applex == head .x and appley == head .y :
157
159
subx = snake [- 1 ].x
158
160
suby = snake [- 1 ].y
159
161
eaten = True
160
162
grow += GROWTH
161
- # The snake grows graduallly over multiple frames
162
- if grow > 0 :
163
- snake .append (SnakePart (snake [- 1 ], subx , suby ))
164
- grow -= 1
163
+
You can’t perform that action at this time.
0 commit comments