corrections stylistiques mineures

This commit is contained in:
papush! 2019-12-09 15:34:37 +01:00
parent a235f8f77e
commit 04197da18b
7 changed files with 17 additions and 18 deletions

View File

@ -12,13 +12,15 @@ class CollideRect(Component):
self.vx = 0 self.vx = 0
self.vy = 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 load(self):
def x_change_cb(x): self.parent.subscribe('x', self.x_change_cb)
self.rect.x = x self.parent.subscribe('y', self.y_change_cb)
def y_change_cb(y):
self.rect.y = y
self.parent.subscribe('x', x_change_cb)
self.parent.subscribe('y', y_change_cb)
def register(self): def register(self):
PhysicsServer().register_component(self) PhysicsServer().register_component(self)

View File

@ -1,5 +1,6 @@
from .observer import Observer from .observer import Observer
class Entity(Observer): class Entity(Observer):
def __init__(self, name): def __init__(self, name):
super().__init__() super().__init__()

View File

@ -4,7 +4,8 @@ from pygame import event
from pygame.locals import QUIT from pygame.locals import QUIT
class StopException(RuntimeError): pass class StopException(RuntimeError):
pass
class InputServer(Server): class InputServer(Server):

View File

@ -14,7 +14,6 @@ class Server(metaclass=Singleton):
def unregister_component(self, component): def unregister_component(self, component):
self._components.remove(component) self._components.remove(component)
@abstractmethod @abstractmethod
def step(self): def step(self):
pass pass

View File

@ -1,6 +1,6 @@
from random import random, randint from random import random, randint
from pygame import Surface, draw, Rect, image from pygame import Rect, image
from engine.entity import Entity from engine.entity import Entity
from engine.scene_manager import SceneManager from engine.scene_manager import SceneManager
@ -9,7 +9,6 @@ from engine.components.collide_rect import CollideRect
from engine.components.sprite import Sprite from engine.components.sprite import Sprite
from .common import S, Direction from .common import S, Direction
from .pacdot import PacDot
class Ghost(Entity): class Ghost(Entity):

View File

@ -14,6 +14,7 @@ from .pacdot import PacDot, EnsmallmentDot
class Node(): class Node():
cpt = 0 cpt = 0
def __init__(self): def __init__(self):
self.id = self.__class__.cpt self.id = self.__class__.cpt
self.__class__.cpt += 1 self.__class__.cpt += 1
@ -68,10 +69,10 @@ class Level(Entity):
if node is None: if node is None:
continue continue
node.neighbors[Direction.LEFT.value] = \ node.neighbors[Direction.LEFT.value] = \
self.graph[y][(x-1)%w] self.graph[y][(x-1) % w]
node.neighbors[Direction.RIGHT.value] = \ node.neighbors[Direction.RIGHT.value] = \
self.graph[y][(x+1)%w] self.graph[y][(x+1) % w]
node.neighbors[Direction.UP.value] = \ node.neighbors[Direction.UP.value] = \
self.graph[(y-1)%h][x] self.graph[(y-1) % h][x]
node.neighbors[Direction.DOWN.value] = \ node.neighbors[Direction.DOWN.value] = \
self.graph[(y+1)%h][x] self.graph[(y+1) % h][x]

View File

@ -1,4 +0,0 @@
class MainMenu(Scene):
pass
scene = MainMenu()