def createDerangatang(self): viewPort = self.viewPort images = self.images random.seed(time.process_time) derangatangStartPos = Point( viewPort.halfWidth, viewPort.halfHeight) + Point( random.randint(-100, 100), random.randint(-100, 100)) # derangatangStartPos = Point( viewPort.halfWidth, viewPort.halfHeight ) derangatangBounds = gd.CollisionBoundary() moveStyle = gd.RandomWalkMovementStyle(boundaryStyle=derangatangBounds) moveStyle.setMoveRate(MOVERATE) moveStyle.setBounceRates(BOUNCERATE, BOUNCEHEIGHT) spriteImages = go.ImageCollection(left=images.Derangatang_RightL, right=images.Derangatang_RightR) derangatang = go.Sprite(derangatangStartPos, moveStyle, size=DERSIZE, ratio=1.0, image=spriteImages, name='Derangatang') # Only collide with the map. # derangatang.setCollisionMask( InteractionType.IMPERVIOUS ) return derangatang
def createPlayer(self): viewPort = self.viewPort images = self.images # How big the player starts off. playerStartPos = Point(viewPort.halfWidth, viewPort.halfHeight) # Sets up the movement style of the player. # playerBounds = gd.RectangleBoundary( Rectangle( Point( 0, 220 ), Point( 900, 550 ) ) ) playerBounds = gd.CollisionBoundary() moveStyle = gd.KeyMovementStyle(boundaryStyle=playerBounds) moveStyle.setMoveRate(MOVERATE) moveStyle.setBounceRates(BOUNCERATE, BOUNCEHEIGHT) leftImages = go.ImageAnimation( [images.Jimmy_Pixel_RightL, images.Jimmy_Pixel_Right_WalkL]) rightImages = go.ImageAnimation( [images.Jimmy_Pixel_RightR, images.Jimmy_Pixel_Right_WalkR]) playerImages = go.ImageCollection(left=leftImages, right=rightImages) collisionSpec = go.CollisionSpecification(width=0.38, left=0.32) return go.Player(playerStartPos, moveStyle, size=JIMSIZE, ratio=1.0, image=playerImages, name='Jimmy Pixel', collisionSpecification=collisionSpec)
def createPlayer(self): viewPort = self.viewPort images = self.images # How big the player starts off. playerStartPos = Point(viewPort.halfWidth, viewPort.halfHeight) # Sets up the movement style of the player. # playerBounds = game_dynamics.RectangleBoundary( Rectangle( Point( 0, 220 ), Point( 900, 550 ) ) ) playerBounds = game_dynamics.CollisionBoundary() moveStyle = game_dynamics.KeyMovementStyle(boundaryStyle=playerBounds) moveStyle.setMoveRate(MOVERATE) moveStyle.setBounceRates(BOUNCERATE, BOUNCEHEIGHT) playerImages = go.ImageCollection(left=images.manL, right=images.manR) return go.Player(playerStartPos, moveStyle, size=MANSIZE, ratio=1.0, image=playerImages)
def createSmilee(self): viewPort = self.viewPort images = self.images random.seed(time.process_time) smileeStartPos = Point( viewPort.halfWidth, viewPort.halfHeight) + Point( random.randint(-100, 100), random.randint(-100, 100)) smileeBounds = gd.CollisionBoundary() moveStyle = gd.RandomWalkMovementStyle(boundaryStyle=smileeBounds) moveStyle.setMoveRate(FLOATMOVERATE) moveStyle.setBounceRates(FLOATRATE, FLOATHEIGHT) spriteImages = go.ImageCollection(left=images.Smilee_RightL, right=images.Smilee_RightR) smilee = go.GhostSprite(smileeStartPos, moveStyle, size=SMILESIZE, ratio=1.0, image=spriteImages, name='Smilee') return smilee