@@ -112,23 +112,23 @@ def is_colliding(self, _other_entity):
112
112
half_width_other = _other_entity .width / 2
113
113
114
114
gap_between = length_x - half_width_self - half_width_other
115
- if ( gap_between > 0 ) :
115
+ if gap_between > 0 :
116
116
pass
117
- elif ( gap_between == 0 ) :
117
+ elif gap_between == 0 :
118
118
pass
119
- elif ( gap_between < 0 ) :
119
+ elif gap_between < 0 :
120
120
_colliding_x = True
121
121
122
122
length_y = abs (self .y - _other_entity .y )
123
123
half_height_self = self .height / 2
124
124
half_height_other = _other_entity .height / 2
125
125
126
126
gap_between = length_y - half_height_self - half_height_other
127
- if ( gap_between > 0 ) :
127
+ if gap_between > 0 :
128
128
pass
129
- elif ( gap_between == 0 ) :
129
+ elif gap_between == 0 :
130
130
pass
131
- elif ( gap_between < 0 ) :
131
+ elif gap_between < 0 :
132
132
_colliding_y = True
133
133
134
134
# print("colliding x: {} - y: {}".format(_colliding_x, _colliding_y))
@@ -237,22 +237,25 @@ def game_tick(self, game_obj):
237
237
:param game_obj: The ChomperGame object to access variables and update things
238
238
:return: True if the action resulted in display needing to be refreshed, otherwise False
239
239
"""
240
- # now = ticks_ms()
240
+ # pylint: disable=too-many-branches
241
241
now = time .monotonic_ns () // 1000000
242
242
need_refresh = False
243
243
244
244
# Top level if statements to check current state within the state machine
245
245
246
246
# process movement for normal, edible, and blinking states
247
- if self .current_state in (Ghost .STATE_NORMAL , Ghost .STATE_EDIBLE , Ghost .STATE_EDIBLE_WARNING ):
247
+ if self .current_state in (Ghost .STATE_NORMAL ,
248
+ Ghost .STATE_EDIBLE ,
249
+ Ghost .STATE_EDIBLE_WARNING ):
248
250
249
251
# if it's been long enough since the last movement
250
252
if now > self .last_move_time + Ghost .MOVE_DELAY :
251
253
# update the last moved timestamp
252
254
self .last_move_time = now
253
255
254
256
# Check direction and prevent Ghost from moving thru the edges
255
- if self .x < (game_obj .display_size [0 ] // 3 ) - 16 and self .direction == Entity .DIRECTION_RIGHT :
257
+ if self .x < (game_obj .display_size [0 ] // 3 ) - 16 and \
258
+ self .direction == Entity .DIRECTION_RIGHT :
256
259
# we're moving right, increase x position
257
260
self .x += 1
258
261
if self .x > 0 and self .direction == Entity .DIRECTION_LEFT :
@@ -309,7 +312,8 @@ def game_tick(self, game_obj):
309
312
self .last_move_time = now
310
313
311
314
# check direction and move. Stopping at the edge
312
- if self .x < game_obj .display_size [0 ] // 3 and self .direction == Entity .DIRECTION_RIGHT :
315
+ if self .x < game_obj .display_size [0 ] // 3 and \
316
+ self .direction == Entity .DIRECTION_RIGHT :
313
317
self .x += 2
314
318
if self .x > 0 and self .direction == Entity .DIRECTION_LEFT :
315
319
self .x -= 2
@@ -431,7 +435,7 @@ class ChomperGame(displayio.Group):
431
435
added to another Group to be shown. Also supports Group scaling which
432
436
is used by default at scale=3.
433
437
"""
434
-
438
+ # pylint: disable=too-many-statements
435
439
EMPTY_MAP_TILE = 17
436
440
PLAYER_TILE = 0
437
441
@@ -469,7 +473,8 @@ def __init__(
469
473
470
474
# Create the background TileGrid. It will be flat black
471
475
# with everything else drawn on top.
472
- self ._background_tilegrid = displayio .TileGrid (self ._sprite_sheet , pixel_shader = self ._palette ,
476
+ self ._background_tilegrid = displayio .TileGrid (self ._sprite_sheet ,
477
+ pixel_shader = self ._palette ,
473
478
width = 21 ,
474
479
height = 3 ,
475
480
tile_width = self ._tile_width ,
@@ -549,7 +554,8 @@ def __init__(
549
554
# Gameover, bottom middle
550
555
self .gameover_lbl = Label (terminalio .FONT , text = "Game Over" )
551
556
self .gameover_lbl .anchor_point = (0.5 , 1.0 )
552
- self .gameover_lbl .anchored_position = ((self .display_size [0 ] // 2 ) // 3 , self .display_size [1 ] // 3 - 5 )
557
+ self .gameover_lbl .anchored_position = ((self .display_size [0 ] // 2 ) // 3 ,
558
+ self .display_size [1 ] // 3 - 5 )
553
559
554
560
# Highscore, top right.
555
561
# Doesn't need separate label and value because it doesn't update during the game loop
@@ -564,7 +570,7 @@ def __init__(
564
570
read_data = nvm_helper .read_data ()
565
571
566
572
# if we found data check if it's a highscore value
567
- if type (read_data ) == list and read_data [0 ] == "1dc_hs" :
573
+ if isinstance (read_data , list ) and read_data [0 ] == "1dc_hs" :
568
574
# it is a highscore so populate the label with its value
569
575
self .highscore_value_lbl .text = f"HI: { read_data [1 ]} "
570
576
self .highscore = read_data [1 ]
@@ -620,6 +626,7 @@ def spawn_pellets(self):
620
626
self .pellets_in_play = 21
621
627
622
628
def game_tick (self ):
629
+ # pylint:disable=too-many-branches
623
630
"""
624
631
Main "heartbeat" function of the game. This will get called over and over from the
625
632
main code.py file. game_tick() is responsible for carrying out all game logic and
@@ -686,7 +693,9 @@ def game_tick(self):
686
693
# if it was a big pellet
687
694
if current_tile_type == 9 :
688
695
# if the ghost is currently normal state, it becomes edible
689
- if self .ghost .current_state in (Ghost .STATE_NORMAL , Ghost .STATE_EDIBLE , Ghost .STATE_EDIBLE_WARNING ):
696
+ if self .ghost .current_state in (Ghost .STATE_NORMAL ,
697
+ Ghost .STATE_EDIBLE ,
698
+ Ghost .STATE_EDIBLE_WARNING ):
690
699
# set the state and edible property
691
700
self .ghost .current_state = Ghost .STATE_EDIBLE
692
701
self .ghost .edible = True
@@ -727,7 +736,9 @@ def game_tick(self):
727
736
self .ghost .current_state = Ghost .STATE_DESPAWN_FLYOFF
728
737
729
738
# change ghost's direction
730
- self .ghost .direction = Entity .DIRECTION_LEFT if self .ghost .direction == Entity .DIRECTION_RIGHT else Entity .DIRECTION_RIGHT
739
+ self .ghost .direction = Entity .DIRECTION_LEFT if \
740
+ self .ghost .direction == Entity .DIRECTION_RIGHT else \
741
+ Entity .DIRECTION_RIGHT
731
742
732
743
# set the ghost sprite to eyes only
733
744
self .ghost .tilegrid [0 , 0 ] = 23
@@ -764,6 +775,8 @@ def big_pellet_exists(self):
764
775
if self ._map_tilegrid [i , 1 ] == 9 :
765
776
return True
766
777
778
+ return False
779
+
767
780
def find_pellets (self ):
768
781
"""
769
782
Find all pellet locations
0 commit comments