diff --git a/collision.py b/collision.py index 05cfbf8..c18af9a 100644 --- a/collision.py +++ b/collision.py @@ -475,7 +475,7 @@ class CollisionLord: def update(self): "Resolve overlaps between all relevant world objects." - for i in range(self.iterations): + for _ in range(self.iterations): # filter shape lists for anything out of room etc valid_dynamic_shapes = [] for shape in self.dynamic_shapes: diff --git a/edit_command.py b/edit_command.py index 75def5e..e470e14 100644 --- a/edit_command.py +++ b/edit_command.py @@ -15,7 +15,7 @@ class EditCommand: for frame in self.tile_commands.values(): for layer in frame.values(): for column in layer.values(): - for tile in column.values(): + for _tile in column.values(): commands += 1 return commands diff --git a/game_object.py b/game_object.py index 404f6ed..01a67bc 100644 --- a/game_object.py +++ b/game_object.py @@ -1082,7 +1082,7 @@ class GameObject: steps = int(total_move_dist / step_dist) # start stepping from beginning of this frame's move distance self.x, self.y = self.last_x, self.last_y - for i in range(steps): + for _ in range(steps): self.x += dir_x * step_dist self.y += dir_y * step_dist collisions = self.get_collisions() diff --git a/games/crawler/scripts/topview.py b/games/crawler/scripts/topview.py index 0bf2815..24bedec 100644 --- a/games/crawler/scripts/topview.py +++ b/games/crawler/scripts/topview.py @@ -41,7 +41,7 @@ class CrawlTopDownView(GameObject): # make a copy of original layer to color for visibility, hide original self.art.duplicate_layer(0) self.art.layers_visibility[0] = False - for frame, layer, x, y in TileIter(self.art): + for _frame, layer, x, y in TileIter(self.art): if layer == 0: continue # set all tiles undiscovered diff --git a/games/fireplace/scripts/fireplace.py b/games/fireplace/scripts/fireplace.py index a8b5f0b..0e8c4b3 100644 --- a/games/fireplace/scripts/fireplace.py +++ b/games/fireplace/scripts/fireplace.py @@ -66,7 +66,7 @@ class Fireplace(GameObject): self.weighted_chars = sorted(chars, key=weights.__getitem__) # spawn initial particles self.particles = [] - for i in range(self.target_particles): + for _ in range(self.target_particles): p = FireParticle(self) self.particles.append(p) # help screen diff --git a/games/wildflowers/scripts/petal.py b/games/wildflowers/scripts/petal.py index 0f0698a..a692881 100644 --- a/games/wildflowers/scripts/petal.py +++ b/games/wildflowers/scripts/petal.py @@ -130,7 +130,7 @@ class Petal: tiles = [] angle = 0 resolution = 30 - for i in range(resolution): + for _ in range(resolution): angle += math.radians(90.0 / resolution) x = round(math.cos(angle) * self.radius) y = round(math.sin(angle) * self.radius) diff --git a/image_convert.py b/image_convert.py index a721057..a74e0a7 100644 --- a/image_convert.py +++ b/image_convert.py @@ -155,7 +155,7 @@ class ImageConverter: def update(self): if time.time() < self.start_time + self.start_delay: return - for i in range(self.tiles_per_tick): + for _ in range(self.tiles_per_tick): x_start, y_start = self.x * self.char_w, self.y * self.char_h x_end, y_end = x_start + self.char_w, y_start + self.char_h block = self.src_array[y_start:y_end, x_start:x_end] @@ -198,8 +198,8 @@ class ImageConverter: color_counts += [(color, counts[i])] color_counts.sort(key=lambda item: item[1], reverse=True) combos = [] - for color1, count1 in color_counts: - for color2, count2 in color_counts: + for color1, _count1 in color_counts: + for color2, _count2 in color_counts: if color1 == color2: continue # fg/bg color swap SHOULD be allowed diff --git a/image_export.py b/image_export.py index a14ee90..8f883df 100644 --- a/image_export.py +++ b/image_export.py @@ -143,7 +143,6 @@ def export_still_image(app, art, out_filename, crt=True, scale=1, bg_color=None) if not src_img: return False src_img.save(out_filename, "PNG") - output_format = "32-bit w/ alpha" else: # else convert to current palette. # as with aniGIF export, use arbitrary color for transparency diff --git a/palette.py b/palette.py index f470563..16db86f 100644 --- a/palette.py +++ b/palette.py @@ -28,10 +28,8 @@ class PaletteLord: ): return self.last_check = self.app.get_elapsed_time() - changed = None for palette in self.app.palettes: if palette.has_updated(): - changed = palette.filename try: palette.load_image() self.app.log( diff --git a/renderable.py b/renderable.py index 95d907a..6efd905 100644 --- a/renderable.py +++ b/renderable.py @@ -101,10 +101,12 @@ class TileRenderable: def __str__(self): "for debug purposes, return a concise unique name" - i = 0 - for i, r in enumerate(self.art.renderables): + for idx, r in enumerate(self.art.renderables): if r is self: + i = idx break + else: + i = 0 return "{} {} {}".format(self.art.get_simple_name(), self.__class__.__name__, i) def create_buffers(self): @@ -546,7 +548,6 @@ class TileRenderable: if not self.app.show_hidden_layers and not self.art.layers_visibility[i]: continue layer_start = i * layer_size - layer_end = layer_start + layer_size # for active art, dim all but active layer based on UI setting if ( not self.app.game_mode diff --git a/renderable_line.py b/renderable_line.py index f0ce1e7..02da38d 100644 --- a/renderable_line.py +++ b/renderable_line.py @@ -331,7 +331,6 @@ class DebugLineRenderable(WorldLineRenderable): def add_lines(self, new_verts, new_colors=None): "add lines to the current ones" line_items = len(self.vert_array) - lines = int(line_items / self.vert_items) # if new_verts is a list of tuples, unpack into flat list if type(new_verts[0]) is tuple: new_verts_unpacked = [] diff --git a/ui.py b/ui.py index 31348ea..806d667 100644 --- a/ui.py +++ b/ui.py @@ -287,10 +287,12 @@ class UI: ) def set_active_art_by_filename(self, art_filename): - i = 0 - for i, art in enumerate(self.app.art_loaded_for_edit): + for idx, art in enumerate(self.app.art_loaded_for_edit): if art_filename == art.filename: + i = idx break + else: + i = 0 new_active_art = self.app.art_loaded_for_edit.pop(i) self.app.art_loaded_for_edit.insert(0, new_active_art) new_active_renderable = self.app.edit_renderables.pop(i) diff --git a/ui_art_dialog.py b/ui_art_dialog.py index bd8ac3f..ee7e1ae 100644 --- a/ui_art_dialog.py +++ b/ui_art_dialog.py @@ -626,7 +626,7 @@ class AddLayerDialog(UIDialog): if not valid_name: return False, self.name_exists_error try: - z = float(self.field_texts[1]) + float(self.field_texts[1]) except Exception: return False, self.invalid_z_error return True, None @@ -684,7 +684,7 @@ class SetLayerZDialog(UIDialog): def is_input_valid(self): try: - z = float(self.field_texts[0]) + float(self.field_texts[0]) except Exception: return False, self.invalid_z_error return True, None @@ -745,7 +745,7 @@ class PaletteFromFileDialog(UIDialog): src_filename = self.field_texts[0] palette_filename = self.field_texts[1] colors = int(self.field_texts[2]) - new_pal = PaletteFromFile(self.ui.app, src_filename, palette_filename, colors) + PaletteFromFile(self.ui.app, src_filename, palette_filename, colors) self.dismiss() diff --git a/ui_chooser_dialog.py b/ui_chooser_dialog.py index 90269af..1eebf28 100644 --- a/ui_chooser_dialog.py +++ b/ui_chooser_dialog.py @@ -176,7 +176,7 @@ class ChooserDialog(UIDialog): # os.access(new_dir, os.R_OK) seems to always return True, # so try/catch listdir instead try: - l = os.listdir(new_dir) + os.listdir(new_dir) except PermissionError: line = "No permission to access {}!".format(os.path.abspath(new_dir)) self.ui.message_line.post_line(line, error=True) diff --git a/ui_console.py b/ui_console.py index c15275c..4bf2c71 100644 --- a/ui_console.py +++ b/ui_console.py @@ -143,7 +143,7 @@ class ImportCommand(ConsoleCommand): ) if not os.path.exists(filename): console.ui.app.log("Couldn't find file {}".format(filename)) - importer = importer_class(console.ui.app, filename) + importer_class(console.ui.app, filename) class ExportCommand(ConsoleCommand): @@ -162,7 +162,7 @@ class ExportCommand(ConsoleCommand): console.ui.app.log( "Couldn't find exporter class {}".format(exporter_classname) ) - exporter = exporter_class(console.ui.app, filename) + exporter_class(console.ui.app, filename) class PaletteFromImageCommand(ConsoleCommand): diff --git a/ui_popup.py b/ui_popup.py index 9414bce..7b77427 100644 --- a/ui_popup.py +++ b/ui_popup.py @@ -431,7 +431,7 @@ class ToolPopup(UIElement): # charset renderable location will be set in update() charset = self.ui.active_art.charset palette = self.ui.active_art.palette - cqw, cqh = ( + _cqw, cqh = ( self.charset_swatch.art.quad_width, self.charset_swatch.art.quad_height, ) diff --git a/ui_tool.py b/ui_tool.py index 6e2074a..b89bf82 100644 --- a/ui_tool.py +++ b/ui_tool.py @@ -294,7 +294,6 @@ class TextTool(UITool): self.input_active = False self.ui.tool_settings_changed = True if self.cursor: - x, y = int(self.cursor.x) + 1, int(-self.cursor.y) + 1 self.cursor.finish_paint() # self.ui.message_line.post_line('Finished text entry at %s, %s' % (x, y)) self.ui.message_line.post_line("Finished text entry.") diff --git a/vector.py b/vector.py index b369c9b..cf6ef27 100644 --- a/vector.py +++ b/vector.py @@ -216,9 +216,9 @@ def world_to_screen(app, world_x, world_y, world_z): # viewport tuple order should be same as glGetFloatv(GL_VIEWPORT) viewport = (0, 0, app.window_width, app.window_height) try: - x, y, z = GLU.gluProject(world_x, world_y, world_z, vm, pjm, viewport) + x, y, _z = GLU.gluProject(world_x, world_y, world_z, vm, pjm, viewport) except Exception: - x, y, z = 0, 0, 0 + x, y = 0, 0 app.log("GLU.gluProject failed!") # does Z mean anything here? return x, y