def load(): global blockSS global townSS global grass global cactus blockSS = spriteSheet.SpriteSheet("spritesheet_complete.png") townSS = spriteSheet.SpriteSheet("town_spritesheet.png") grass = pygame.image.load("grass.png").convert_alpha() cactus = pygame.image.load("cactus.png").convert_alpha()
def load(): global inventory global genericSS global fishSS genericSS = spriteSheet.SpriteSheet("genericItems.png") fishSS = spriteSheet.SpriteSheet("fishSpritesheet.png") inventory.append([ "Spatula", 0, pygame.transform.scale(genericSS.img(462, 1132, 88, 140), (22, 35)), "Melee", 50, True, "Order up!" ]) inventory.append([ "Rock", 0, pygame.transform.scale(fishSS.img(320, 359, 53, 32), (25, 15)), "Ranged", 50, True, "It's just a rock." ])
def __init__(self): super().__init__() self.sprite = 0 self.SS = spriteSheet.SpriteSheet("p1_walk.png") self.leftImages = [] self.rightImages = [] self.isWalking = False self.isLeft = False self.detectLeft = 0 self.detectRight = 0 self.ableLeft = True self.ableRight = True self.collisionList = [] self.case = 0 self.moveY = 0 self.ableJump = True self.jumpHeight = 3 self.jumpArc = [int(height) * 10 for height in range(1, 5)] self.health = 100 self.hitList = [] self.isAlive = True self.collectList = [] # Get Sprites coords = ((0, 0, 66, 90), (66, 0, 66, 90), (133, 0, 66, 90), (0, 93, 66, 90), (67, 93, 65, 90), (132, 93, 72, 90), (0, 186, 70, 90), (71, 186, 70, 90), (142, 186, 72, 90), (0, 279, 71, 90), (71, 279, 66, 90)) for i in range(len(coords)): self.leftImages.append( pygame.transform.flip( self.SS.img(coords[i][0], coords[i][1], coords[i][2], coords[i][3]), True, False)) self.rightImages.append( self.SS.img(coords[i][0], coords[i][1], coords[i][2], coords[i][3])) # Default Position self.image = self.rightImages[0] self.image = pygame.transform.scale(self.image, (36, 50)) self.rect = self.image.get_rect() self.rect.x = 234 self.rect.y = 460 self.mask = pygame.mask.from_surface(self.image) self.mask.fill()
def load(): global enemySS enemySS = spriteSheet.SpriteSheet("spritesheet_complete.png")
def intro(screen): # Intro cutscene global counter global isOver bg = pygame.image.load("planets.png").convert() bg2 = pygame.image.load("space2.png").convert() rocket = pygame.image.load("rocket.png").convert_alpha() rocket = pygame.transform.scale(rocket, (312, 158)) shipInterior = pygame.image.load("shipInterior.png").convert() warningScreen = pygame.image.load("warningScreen.png").convert() exclamationMark = pygame.image.load("!.png").convert_alpha() sky = pygame.Surface((800, 600)) sky.fill((0, 175, 175)) rocketSS = spriteSheet.SpriteSheet("space_spritesheet.png") rocketPart1 = rocketSS.img(1555, 512, 136, 156).convert_alpha() # Tip rocketPart2 = rocketSS.img(1519, 0, 136, 512).convert_alpha() # Body rocketPart3 = rocketSS.img(1763, 0, 93, 169).convert_alpha() # Wings bloo = pygame.transform.scale( spriteSheet.SpriteSheet("p1_walk.png").img(0, 0, 66, 90), (33, 45)) ground = pygame.Surface((800, 600)) ground.fill((0, 175, 0)) if counter <= 200: # Rocket floats in space screen.blit(bg, (0, 0)) screen.blit(rocket, (800 - 3 * counter, 221 + 0.1 * np.rad2deg(np.sin(counter / 10)))) counter += 1 if counter >= 150: # SCREEN FADE blackBg.set_alpha(10 * (counter - 150)) screen.blit(blackBg, (0, 0)) elif counter <= 360: # Inside rocket screen.blit(shipInterior, (0, 0)) if counter <= 250: # NEXT SCENE blackBg.set_alpha(5 * (250 - counter)) screen.blit(blackBg, (0, 0)) elif counter >= 275 and counter % 10 <= 5: # Panel flashes screen.blit(warningScreen, (480, 284)) if counter >= 300: # Exclamation mark appears over head screen.blit(exclamationMark, (170, 300)) elif counter <= 430: # Back in space if counter <= 400: screen.blit(bg2, (0, 0)) screen.blit(rocket, (400 - 3 * (counter - 360), 300)) elif counter >= 410: screen.blit(bg2, (0, 0)) screen.blit(rocket, (277, 300 + 20 * (counter - 410))) # Top: 1555, 512, 136, 156 # Body: 1519, 0, 136, 512 # Wings: 1763, 0, 93, 169 elif counter <= 600: if counter <= 450: screen.blit(sky, (0, 0)) screen.blit(pygame.transform.rotozoom(rocketPart1, 180, 0.5), (336, 256)) screen.blit(pygame.transform.rotozoom(rocketPart2, 180, 0.5), (336, 0)) screen.blit(pygame.transform.rotozoom(rocketPart3, 180, 0.5), (290, 43)) screen.blit( pygame.transform.rotozoom( pygame.transform.flip(rocketPart3, True, False), 180, 0.5), (405, 43)) elif counter <= 470: screen.blit(sky, (0, 0)) screen.blit(pygame.transform.rotozoom(rocketPart1, 180, 0.5), (336, 256)) screen.blit(pygame.transform.rotozoom(rocketPart2, 180, 0.5), (336, 0)) screen.blit(pygame.transform.rotozoom(rocketPart3, 180, 0.5), (290 - 10 * (counter - 450), 43 - 10 * (counter - 450))) screen.blit( pygame.transform.rotozoom( pygame.transform.flip(rocketPart3, True, False), 180, 0.5), (405 + 10 * (counter - 450), 43 - 10 * (counter - 450))) elif counter <= 500: screen.blit(sky, (0, 0)) screen.blit(pygame.transform.rotozoom(rocketPart1, 180, 0.5), (336, 256)) screen.blit(bloo, (360, 200)) screen.blit(pygame.transform.rotozoom(rocketPart2, 180, 0.5), (336, 0 - 10 * (counter - 470))) elif counter <= 550: screen.blit(sky, (0, 0)) screen.blit(pygame.transform.rotozoom(rocketPart1, 180, 0.5), (336, 256 - 10 * (counter - 500))) screen.blit(bloo, (360, 200)) elif counter <= 575: screen.blit(sky, (0, 0)) screen.blit(bloo, (360, 200)) screen.blit(ground, (0, 600 - 10 * (counter - 550))) else: isOver = True counter += 1
def load(): global coinSS coinSS = spriteSheet.SpriteSheet("spritesheet_complete.png")
titleScroll = -200 titleAcceleration = 5 titleBounce = 10 titleHeight = -titleBounce titlePhase = False menu = False cutscene = True # Shop shop = False purchased = False ableAfford = False purchasedItem = None equipped = 0 preview = -1 equipButton = pygame.image.load("Equip.png").convert_alpha() blockSS = spriteSheet.SpriteSheet("spritesheet_complete.png") weaponSS = spriteSheet.SpriteSheet("genericItems.png") storeInventory = [ # [Name, Price, Image, Weapon type, Damage, isBought, tip] [ "Spare limb", 1, pygame.image.load("tint1_arm.png").convert_alpha(), "Melee", 60, False, "Hopefully it can lend you a hand!" ], [ "Money", 2, weaponSS.img(268, 650, 101, 106), "Ranged", 70, False, "The exchange rate is high these days..." ], [ "Toothbrush", 5, weaponSS.img(552, 507, 74, 106), "Melee", 90, False,