From 04197da18b7873be6089c44311a7b6bd88224c12 Mon Sep 17 00:00:00 2001 From: papush! Date: Mon, 9 Dec 2019 15:34:37 +0100 Subject: [PATCH] corrections stylistiques mineures --- engine/components/collide_rect.py | 14 ++++++++------ engine/entity.py | 1 + engine/servers/input.py | 3 ++- engine/servers/server.py | 1 - scenes/game_objects/ghost.py | 3 +-- scenes/game_objects/level.py | 9 +++++---- scenes/main_menu.py | 4 ---- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/engine/components/collide_rect.py b/engine/components/collide_rect.py index 39a6133..adcd18a 100644 --- a/engine/components/collide_rect.py +++ b/engine/components/collide_rect.py @@ -12,13 +12,15 @@ class CollideRect(Component): self.vx = 0 self.vy = 0 + def x_change_cb(self, x): + self.rect.x = x + + def y_change_cb(self, y): + self.rect.y = y + def load(self): - def x_change_cb(x): - self.rect.x = x - def y_change_cb(y): - self.rect.y = y - self.parent.subscribe('x', x_change_cb) - self.parent.subscribe('y', y_change_cb) + self.parent.subscribe('x', self.x_change_cb) + self.parent.subscribe('y', self.y_change_cb) def register(self): PhysicsServer().register_component(self) diff --git a/engine/entity.py b/engine/entity.py index 3b6a1c8..551effe 100644 --- a/engine/entity.py +++ b/engine/entity.py @@ -1,5 +1,6 @@ from .observer import Observer + class Entity(Observer): def __init__(self, name): super().__init__() diff --git a/engine/servers/input.py b/engine/servers/input.py index 116df35..2cb54df 100644 --- a/engine/servers/input.py +++ b/engine/servers/input.py @@ -4,7 +4,8 @@ from pygame import event from pygame.locals import QUIT -class StopException(RuntimeError): pass +class StopException(RuntimeError): + pass class InputServer(Server): diff --git a/engine/servers/server.py b/engine/servers/server.py index ed0b856..8c3d046 100644 --- a/engine/servers/server.py +++ b/engine/servers/server.py @@ -14,7 +14,6 @@ class Server(metaclass=Singleton): def unregister_component(self, component): self._components.remove(component) - @abstractmethod def step(self): pass diff --git a/scenes/game_objects/ghost.py b/scenes/game_objects/ghost.py index 6f923dc..0258a5c 100644 --- a/scenes/game_objects/ghost.py +++ b/scenes/game_objects/ghost.py @@ -1,6 +1,6 @@ from random import random, randint -from pygame import Surface, draw, Rect, image +from pygame import Rect, image from engine.entity import Entity from engine.scene_manager import SceneManager @@ -9,7 +9,6 @@ from engine.components.collide_rect import CollideRect from engine.components.sprite import Sprite from .common import S, Direction -from .pacdot import PacDot class Ghost(Entity): diff --git a/scenes/game_objects/level.py b/scenes/game_objects/level.py index 826cc04..2704006 100644 --- a/scenes/game_objects/level.py +++ b/scenes/game_objects/level.py @@ -14,6 +14,7 @@ from .pacdot import PacDot, EnsmallmentDot class Node(): cpt = 0 + def __init__(self): self.id = self.__class__.cpt self.__class__.cpt += 1 @@ -68,10 +69,10 @@ class Level(Entity): if node is None: continue node.neighbors[Direction.LEFT.value] = \ - self.graph[y][(x-1)%w] + self.graph[y][(x-1) % w] node.neighbors[Direction.RIGHT.value] = \ - self.graph[y][(x+1)%w] + self.graph[y][(x+1) % w] node.neighbors[Direction.UP.value] = \ - self.graph[(y-1)%h][x] + self.graph[(y-1) % h][x] node.neighbors[Direction.DOWN.value] = \ - self.graph[(y+1)%h][x] + self.graph[(y+1) % h][x] diff --git a/scenes/main_menu.py b/scenes/main_menu.py index afe6b75..e69de29 100644 --- a/scenes/main_menu.py +++ b/scenes/main_menu.py @@ -1,4 +0,0 @@ -class MainMenu(Scene): - pass - -scene = MainMenu()