def __init__(self) : Big.__init__(self) self.awake = True self.inputLeft = Input.find("left") self.inputRight = Input.find("right") self.inputUp = Input.find("up") self.inputDown = Input.find("down") self.inputScrollLeft = Input.find("scrollLeft") self.inputScrollRight = Input.find("scrollRight") self.inputScrollUp = Input.find("scrollUp") self.inputScrollDown = Input.find("scrollDown") self.inputScrollReset = Input.find("scrollReset") self.scrollOffsetX = 0 self.scrollOffsetY = 0 self.maxScrollX = 400 self.maxScrollY = 300 self.scrollResetting = False self.scrollSpeed = 1 self.defaultScrollSpeed = 1 self.sleepyZ = None
def onBirth( self ) : Big.onBirth(self) self.talkX = self.costumeFeatures.talkX self.talkY = self.costumeFeatures.talkY self.speed = 6 self.addTag("player")
def onPlacedOnGrid(self) : Big.onPlacedOnGrid(self) self.costumeFeatures.createParts( self ) self.calculateLeadingEdges() self.allAddTag("collector") self.allAddTag("hittable") self.allAddTag("enemySoft") self.allAddTag("digger") # Allows me to dig hard soil. See class Hard
def playerTick( self ) : if self.scrollResetting : self.resetScroll() elif self.inputScrollReset.pressed() : self.scrollResetting = True elif self.inputScrollLeft.pressed() : self.scroll( -1, 0 ) elif self.inputScrollRight.pressed() : self.scroll( 1, 0 ) elif self.inputScrollUp.pressed() : self.scroll( 0, 1 ) elif self.inputScrollDown.pressed() : self.scroll( 0, -1 ) else : self.scrollSpeed = self.defaultScrollSpeed if self.square is None : return for evil in self.collisions(["enemy"]) : self.killMe( evil ) return if self.isMoving() : pass else : self.movements() Big.tick(self) tx = self.actor.x + self.scrollOffsetX ty = self.actor.y + self.scrollOffsetY game.director.centerOn( tx, ty )
def onDeath( self ) : game.sceneDirector.playerDied( self ) self.killZs() Big.onDeath(self)
def move( self, dx, dy, speed=None ) : Big.move(self,dx, dy, speed ) if dy == 0 : self.event( "move-" + ("L" if dx == -1 else "R" ) ) else : self.event( "move-" + ("U" if dy == 1 else "D" ) )