Skip to content

Commit 2367684

Browse files
committed
pylint fixes
1 parent e947db6 commit 2367684

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

Qualia/Qualia_S3_1D_Chomper_Game/chomper_1d_lib.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,23 @@ def is_colliding(self, _other_entity):
112112
half_width_other = _other_entity.width / 2
113113

114114
gap_between = length_x - half_width_self - half_width_other
115-
if (gap_between > 0):
115+
if gap_between > 0:
116116
pass
117-
elif (gap_between == 0):
117+
elif gap_between == 0:
118118
pass
119-
elif (gap_between < 0):
119+
elif gap_between < 0:
120120
_colliding_x = True
121121

122122
length_y = abs(self.y - _other_entity.y)
123123
half_height_self = self.height / 2
124124
half_height_other = _other_entity.height / 2
125125

126126
gap_between = length_y - half_height_self - half_height_other
127-
if (gap_between > 0):
127+
if gap_between > 0:
128128
pass
129-
elif (gap_between == 0):
129+
elif gap_between == 0:
130130
pass
131-
elif (gap_between < 0):
131+
elif gap_between < 0:
132132
_colliding_y = True
133133

134134
# print("colliding x: {} - y: {}".format(_colliding_x, _colliding_y))
@@ -237,22 +237,25 @@ def game_tick(self, game_obj):
237237
:param game_obj: The ChomperGame object to access variables and update things
238238
:return: True if the action resulted in display needing to be refreshed, otherwise False
239239
"""
240-
# now = ticks_ms()
240+
# pylint: disable=too-many-branches
241241
now = time.monotonic_ns() // 1000000
242242
need_refresh = False
243243

244244
# Top level if statements to check current state within the state machine
245245

246246
# 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):
248250

249251
# if it's been long enough since the last movement
250252
if now > self.last_move_time + Ghost.MOVE_DELAY:
251253
# update the last moved timestamp
252254
self.last_move_time = now
253255

254256
# 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:
256259
# we're moving right, increase x position
257260
self.x += 1
258261
if self.x > 0 and self.direction == Entity.DIRECTION_LEFT:
@@ -309,7 +312,8 @@ def game_tick(self, game_obj):
309312
self.last_move_time = now
310313

311314
# 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:
313317
self.x += 2
314318
if self.x > 0 and self.direction == Entity.DIRECTION_LEFT:
315319
self.x -= 2
@@ -431,7 +435,7 @@ class ChomperGame(displayio.Group):
431435
added to another Group to be shown. Also supports Group scaling which
432436
is used by default at scale=3.
433437
"""
434-
438+
# pylint: disable=too-many-statements
435439
EMPTY_MAP_TILE = 17
436440
PLAYER_TILE = 0
437441

@@ -469,7 +473,8 @@ def __init__(
469473

470474
# Create the background TileGrid. It will be flat black
471475
# 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,
473478
width=21,
474479
height=3,
475480
tile_width=self._tile_width,
@@ -549,7 +554,8 @@ def __init__(
549554
# Gameover, bottom middle
550555
self.gameover_lbl = Label(terminalio.FONT, text="Game Over")
551556
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)
553559

554560
# Highscore, top right.
555561
# Doesn't need separate label and value because it doesn't update during the game loop
@@ -564,7 +570,7 @@ def __init__(
564570
read_data = nvm_helper.read_data()
565571

566572
# 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":
568574
# it is a highscore so populate the label with its value
569575
self.highscore_value_lbl.text = f"HI: {read_data[1]}"
570576
self.highscore = read_data[1]
@@ -620,6 +626,7 @@ def spawn_pellets(self):
620626
self.pellets_in_play = 21
621627

622628
def game_tick(self):
629+
# pylint:disable=too-many-branches
623630
"""
624631
Main "heartbeat" function of the game. This will get called over and over from the
625632
main code.py file. game_tick() is responsible for carrying out all game logic and
@@ -686,7 +693,9 @@ def game_tick(self):
686693
# if it was a big pellet
687694
if current_tile_type == 9:
688695
# 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):
690699
# set the state and edible property
691700
self.ghost.current_state = Ghost.STATE_EDIBLE
692701
self.ghost.edible = True
@@ -727,7 +736,9 @@ def game_tick(self):
727736
self.ghost.current_state = Ghost.STATE_DESPAWN_FLYOFF
728737

729738
# 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
731742

732743
# set the ghost sprite to eyes only
733744
self.ghost.tilegrid[0, 0] = 23
@@ -764,6 +775,8 @@ def big_pellet_exists(self):
764775
if self._map_tilegrid[i, 1] == 9:
765776
return True
766777

778+
return False
779+
767780
def find_pellets(self):
768781
"""
769782
Find all pellet locations

Qualia/Qualia_S3_1D_Chomper_Game/code.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
Circuitpython based 1 dimensional pacman style game inspired by Paku Paku.
88
"""
9-
import time
109
import board
1110
from adafruit_qualia import Qualia
1211
from adafruit_qualia.graphics import Displays

0 commit comments

Comments
 (0)