Пример #1
0
 def __init__(self, config):
     self._theme = config.theme
     self.mapX = config.mapX
     self.mapY = config.mapY
     self._model = config.modelFactory(config.model, self)
     BasicSprite.__init__(self, config)
     try:
         config.model.put(self.mapX, self.mapY, self._model)
     except:
         _LOGGER.exception("################ %s: cannot put at %sx%s (model: %s)", self, self.mapX, self.mapY, self._model)
Пример #2
0
    def __init__(self, config):
        config.behaviour = GridBehaviour(self)
        BasicSprite.__init__(self, config)
        self._tile = config.tile
        self._size = config.size
        self._visibleArea = PySGE.engine.getRect((0, 0), self._size)
        self._sprites = list(config.sprites or [])
        self._makeScrollers(config.scrollSize or int(self._tile / 2), config.scrollSpeed or 1)

        self._mapSize = config.mapSize
        x, y = self._mapSize
        self._model = GridModel(x, y, mover=self.behaviour)
        self._resource = PySGE.engine.getSurface((x * self._tile, y * self._tile), TRANSPARENCY)
        self.rect = self._resource.get_rect()

        self._scrollPosition = (0, 0)

        self._landscape = reduce(
            lambda x, y: x + y, [[tile for tile in feature.expand(self._model)] for feature in config.landscape], []
        )
        _LOGGER.debug("LANDSCAPE=%s", self._landscape)

        self._bugs = [bug.get(self._model) for bug in config.bugs]
        _LOGGER.debug("BUGS=%s", self._bugs)
Пример #3
0
 def getMousePosition(self):
     realPosition = BasicSprite.getMousePosition(self)
     return (realPosition[0] - self._position[0], realPosition[1] - self._position[1])