From: Peter Gerwinski Date: Sat, 31 Mar 2018 17:12:42 +0000 (+0200) Subject: changed raftcastle, added plants, water, T** **d, cheating, more platform images X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=3edc547f88b8acb62bbbc8f397f39343c033166e;p=ott%2Fmolpy-up changed raftcastle, added plants, water, T** **d, cheating, more platform images --- diff --git a/assets/plantGrass1.png b/assets/plantGrass1.png new file mode 100644 index 0000000..dbb81e9 Binary files /dev/null and b/assets/plantGrass1.png differ diff --git a/assets/plantGrass10.png b/assets/plantGrass10.png new file mode 100644 index 0000000..f47971f Binary files /dev/null and b/assets/plantGrass10.png differ diff --git a/assets/plantGrass11.png b/assets/plantGrass11.png new file mode 100644 index 0000000..415cdbd Binary files /dev/null and b/assets/plantGrass11.png differ diff --git a/assets/plantGrass2.png b/assets/plantGrass2.png new file mode 100644 index 0000000..c758872 Binary files /dev/null and b/assets/plantGrass2.png differ diff --git a/assets/plantGrass3.png b/assets/plantGrass3.png new file mode 100644 index 0000000..d29a360 Binary files /dev/null and b/assets/plantGrass3.png differ diff --git a/assets/plantGrass4.png b/assets/plantGrass4.png new file mode 100644 index 0000000..947934d Binary files /dev/null and b/assets/plantGrass4.png differ diff --git a/assets/plantGrass5.png b/assets/plantGrass5.png new file mode 100644 index 0000000..a28752e Binary files /dev/null and b/assets/plantGrass5.png differ diff --git a/assets/plantGrass6.png b/assets/plantGrass6.png new file mode 100644 index 0000000..3b61e18 Binary files /dev/null and b/assets/plantGrass6.png differ diff --git a/assets/plantGrass7.png b/assets/plantGrass7.png new file mode 100644 index 0000000..947c191 Binary files /dev/null and b/assets/plantGrass7.png differ diff --git a/assets/plantGrass8.png b/assets/plantGrass8.png new file mode 100644 index 0000000..7d460bc Binary files /dev/null and b/assets/plantGrass8.png differ diff --git a/assets/plantGrass9.png b/assets/plantGrass9.png new file mode 100644 index 0000000..9988904 Binary files /dev/null and b/assets/plantGrass9.png differ diff --git a/assets/plantSand1.png b/assets/plantSand1.png new file mode 100644 index 0000000..4468a7e Binary files /dev/null and b/assets/plantSand1.png differ diff --git a/assets/plantSand2.png b/assets/plantSand2.png new file mode 100644 index 0000000..d0b4892 Binary files /dev/null and b/assets/plantSand2.png differ diff --git a/assets/plantSand3.png b/assets/plantSand3.png new file mode 100644 index 0000000..027384f Binary files /dev/null and b/assets/plantSand3.png differ diff --git a/assets/plantSand4.png b/assets/plantSand4.png new file mode 100644 index 0000000..4d87ee5 Binary files /dev/null and b/assets/plantSand4.png differ diff --git a/assets/plantSand5.png b/assets/plantSand5.png new file mode 100644 index 0000000..6a7f3f7 Binary files /dev/null and b/assets/plantSand5.png differ diff --git a/assets/platformGrass.png b/assets/platformGrass1.png similarity index 100% rename from assets/platformGrass.png rename to assets/platformGrass1.png diff --git a/assets/platformGrass1f.png b/assets/platformGrass1f.png new file mode 100644 index 0000000..b473a6d Binary files /dev/null and b/assets/platformGrass1f.png differ diff --git a/assets/platformGrass2.png b/assets/platformGrass2.png new file mode 100644 index 0000000..ddaac52 Binary files /dev/null and b/assets/platformGrass2.png differ diff --git a/assets/platformGrass2f.png b/assets/platformGrass2f.png new file mode 100644 index 0000000..91ffa67 Binary files /dev/null and b/assets/platformGrass2f.png differ diff --git a/assets/platformGrass3.png b/assets/platformGrass3.png new file mode 100644 index 0000000..2321aea Binary files /dev/null and b/assets/platformGrass3.png differ diff --git a/assets/platformGrass3f.png b/assets/platformGrass3f.png new file mode 100644 index 0000000..5f6e3ea Binary files /dev/null and b/assets/platformGrass3f.png differ diff --git a/assets/platformRaftcastle.png b/assets/platformRaftcastle.png index 82c1311..0382195 100644 Binary files a/assets/platformRaftcastle.png and b/assets/platformRaftcastle.png differ diff --git a/assets/platformSand1.png b/assets/platformSand1.png new file mode 100644 index 0000000..040b8d6 Binary files /dev/null and b/assets/platformSand1.png differ diff --git a/assets/platformSand2.png b/assets/platformSand2.png new file mode 100644 index 0000000..fe2b8e3 Binary files /dev/null and b/assets/platformSand2.png differ diff --git a/assets/platformSand3.png b/assets/platformSand3.png new file mode 100644 index 0000000..daa83ae Binary files /dev/null and b/assets/platformSand3.png differ diff --git a/assets/platformSand4.png b/assets/platformSand4.png new file mode 100644 index 0000000..ee3184f Binary files /dev/null and b/assets/platformSand4.png differ diff --git a/assets/platformTheEnd.png b/assets/platformTheEnd.png new file mode 100644 index 0000000..fd03464 Binary files /dev/null and b/assets/platformTheEnd.png differ diff --git a/assets/platformWater1.png b/assets/platformWater1.png new file mode 100644 index 0000000..1d91749 Binary files /dev/null and b/assets/platformWater1.png differ diff --git a/assets/platformWater1f.png b/assets/platformWater1f.png new file mode 100644 index 0000000..c33fb96 Binary files /dev/null and b/assets/platformWater1f.png differ diff --git a/assets/platformWater2.png b/assets/platformWater2.png new file mode 100644 index 0000000..0919836 Binary files /dev/null and b/assets/platformWater2.png differ diff --git a/assets/platformWater2f.png b/assets/platformWater2f.png new file mode 100644 index 0000000..7e3a045 Binary files /dev/null and b/assets/platformWater2f.png differ diff --git a/assets/platformWonTheGame.png b/assets/platformWonTheGame.png new file mode 100644 index 0000000..28c8d00 Binary files /dev/null and b/assets/platformWonTheGame.png differ diff --git a/molpyup.py b/molpyup.py index d1dfd44..bb98165 100644 --- a/molpyup.py +++ b/molpyup.py @@ -46,9 +46,12 @@ class MolpyUp: platformTypeGrapevine = 2 platformTypeAfterLucky = 3 platformTypeCastle = 4 - platformTypeRaftcastle = 5 + platformTypeWater = 5 + platformTypeRaftcastle = 6 platformTypeFloating = platformTypeRaftcastle - platformTypeBreaking = 6 + platformTypeBreaking = 7 + platformTypeTheEnd = 8 + platformTypeWonTheGame = 9 itemTypeAccelerator = 0 itemTypeBeanie = 1 @@ -56,6 +59,8 @@ class MolpyUp: itemTypePrickly = 3 itemTypeSandcastle = 4 itemTypeFlag = 5 + itemTypePlantSand = 6 + itemTypePlantGrass = 7 scoreSnake = 1738 scorePrickly = 2015 @@ -63,6 +68,9 @@ class MolpyUp: scoreAfterLucky = 2315 scoreCastle = 2825 scoreRaftcastle = 3031 + scoreWater = 3043 + scoreTheEnd = 3089 + scoreEpilogue = 3094 def __init__(self): self.sx = 553 @@ -73,14 +81,28 @@ class MolpyUp: self.font = pygame.font.SysFont("xkcd,sans", 25) self.clock = pygame.time.Clock() self.xmovementmax = 10 - self.imgPlatformSand = pygame.image.load("assets/platformSand.png").convert_alpha() - self.imgPlatformGrass = pygame.image.load("assets/platformGrass.png").convert_alpha() + self.imgPlatformSand = [ pygame.image.load("assets/platformSand1.png").convert_alpha(), + pygame.image.load("assets/platformSand2.png").convert_alpha(), + pygame.image.load("assets/platformSand3.png").convert_alpha(), + pygame.image.load("assets/platformSand4.png").convert_alpha() ] + self.imgPlatformGrass = [ pygame.image.load("assets/platformGrass1.png").convert_alpha(), + pygame.image.load("assets/platformGrass2.png").convert_alpha(), + pygame.image.load("assets/platformGrass3.png").convert_alpha(), + pygame.image.load("assets/platformGrass1f.png").convert_alpha(), + pygame.image.load("assets/platformGrass2f.png").convert_alpha(), + pygame.image.load("assets/platformGrass3f.png").convert_alpha() ] + self.imgPlatformWater = [ pygame.image.load("assets/platformWater1.png").convert_alpha(), + pygame.image.load("assets/platformWater2.png").convert_alpha(), + pygame.image.load("assets/platformWater1f.png").convert_alpha(), + pygame.image.load("assets/platformWater2f.png").convert_alpha() ] self.imgPlatformAfterLucky = pygame.image.load("assets/platformAfterLucky.png").convert_alpha() self.imgPlatformCastle = pygame.image.load("assets/platformCastle.png").convert_alpha() self.imgPlatformRaftcastle = pygame.image.load("assets/platformRaftcastle.png").convert_alpha() self.imgPlatformGrapevine = pygame.image.load("assets/platformGrapevine.png").convert_alpha() self.imgPlatformBreaking = pygame.image.load("assets/platformBreaking.png").convert_alpha() self.imgPlatformBroken = pygame.image.load("assets/platformBroken.png").convert_alpha() + self.imgPlatformTheEnd = pygame.image.load("assets/platformTheEnd.png").convert_alpha() + self.imgPlatformWonTheGame = pygame.image.load("assets/platformWonTheGame.png").convert_alpha() self.imgPlayerRightUp = pygame.image.load("assets/playerRightUp.png").convert_alpha() self.imgPlayerRightDown = pygame.image.load("assets/playerRightDown.png").convert_alpha() self.imgPlayerLeftUp = pygame.image.load("assets/playerLeftUp.png").convert_alpha() @@ -102,6 +124,22 @@ class MolpyUp: self.imgFlagLeftDown = pygame.image.load("assets/flagLeftDown.png").convert_alpha() self.imgFlagRight = pygame.image.load("assets/flagRight.png").convert_alpha() self.imgFlagRightDown = pygame.image.load("assets/flagRightDown.png").convert_alpha() + self.imgPlantSand = [ pygame.image.load("assets/plantSand1.png").convert_alpha(), + pygame.image.load("assets/plantSand2.png").convert_alpha(), + pygame.image.load("assets/plantSand3.png").convert_alpha(), + pygame.image.load("assets/plantSand4.png").convert_alpha(), + pygame.image.load("assets/plantSand5.png").convert_alpha() ] + self.imgPlantGrass = [ pygame.image.load("assets/plantGrass1.png").convert_alpha(), + pygame.image.load("assets/plantGrass2.png").convert_alpha(), + pygame.image.load("assets/plantGrass3.png").convert_alpha(), + pygame.image.load("assets/plantGrass4.png").convert_alpha(), + pygame.image.load("assets/plantGrass5.png").convert_alpha(), + pygame.image.load("assets/plantGrass6.png").convert_alpha(), + pygame.image.load("assets/plantGrass7.png").convert_alpha(), + pygame.image.load("assets/plantGrass8.png").convert_alpha(), + pygame.image.load("assets/plantGrass9.png").convert_alpha(), + pygame.image.load("assets/plantGrass10.png").convert_alpha(), + pygame.image.load("assets/plantGrass11.png").convert_alpha() ] def reset(self): self.cameray = 0 @@ -121,8 +159,9 @@ class MolpyUp: self.hadPrickly = False self.hadAfterLucky = False self.hadCastle = False - self.hadRaftcastle = False - self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, False, False]] + self.hadTheEnd = False + self.raftcastleHasFlag = False + self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, 0, 0]] self.generatePlatforms() def updatePlayer(self): @@ -142,11 +181,17 @@ class MolpyUp: self.xmovement -= 1 self.direction = 1 elif key[K_PLUS] or key[K_KP_PLUS]: - self.speed += 1 - self.screen.blit(self.font.render("Speed: " + str(self.speed), -1, (0, 0, 0)), (self.sx // 32, self.sy - self.sy // 12)) + if pygame.key.get_mods() and KMOD_CTRL: + self.score += 10 + else: + self.speed += 1 + self.screen.blit(self.font.render("Speed: " + str(self.speed), -1, (0, 0, 0)), (self.sx // 32, self.sy - self.sy // 12)) elif key[K_MINUS] or key[K_KP_MINUS]: - self.speed -= 1 - self.screen.blit(self.font.render("Speed: " + str(self.speed), -1, (0, 0, 0)), (self.sx // 32, self.sy - self.sy // 12)) + if pygame.key.get_mods() and KMOD_CTRL: + self.score -= 10 + else: + self.speed -= 1 + self.screen.blit(self.font.render("Speed: " + str(self.speed), -1, (0, 0, 0)), (self.sx // 32, self.sy - self.sy // 12)) else: if self.xmovement > 0: self.xmovement -= 1 @@ -202,8 +247,8 @@ class MolpyUp: img = self.imgPlatformRaftcastle else: # all have same size - img = self.imgPlatformSand - rect = pygame.Rect(p[0], p[1], img.get_width(), self.imgPlatformSand.get_height()) + img = self.imgPlatformSand[0] + rect = pygame.Rect(p[0], p[1], img.get_width(), self.imgPlatformSand[0].get_height()) player = pygame.Rect(self.playerx + 15, self.playery, self.imgPlayerRightUp.get_width() - 30, self.imgPlayerRightUp.get_height()) if rect.colliderect(player) and self.gravity and self.playery < (p[1] - self.cameray): if p[2] == self.platformTypeBreaking: @@ -211,10 +256,14 @@ class MolpyUp: else: self.jump = self.sy // 20 self.gravity = 0 - if (p[2] == self.platformTypeAfterLucky or p[2] == self.platformTypeCastle or p[2] == self.platformTypeRaftcastle) and self.playerCarriesFlag and not p[-2]: + if (p[2] == self.platformTypeAfterLucky or p[2] == self.platformTypeCastle) and self.playerCarriesFlag and not p[-2]: self.playerCarriesFlag = False p[-2] = True self.sandcastles += 1 + elif p[2] == self.platformTypeRaftcastle and self.playerCarriesFlag and not self.raftcastleHasFlag: + self.playerCarriesFlag = False + self.raftcastleHasFlag = True + self.sandcastles += 1 if p[2] > self.platformTypeNormal and p[2] <= self.platformTypeFloating: if p[-1]: if p[2] == self.platformTypeAfterLucky: @@ -232,8 +281,15 @@ class MolpyUp: p[-1] = True def choosePlatformType(self): - platformType = random.randint(0, 1000) - if platformType < 800: + if self.score >= self.scoreTheEnd: + return self.platformTypeTheEnd + platformType = random.randint(0, 999) + if self.score > self.scoreWater: + if platformType < 900: + return self.platformTypeWater + else: + return self.platformTypeRaftcastle + elif platformType < 800: if platformType < 1000 * self.score // self.scoreGrass: if self.score > self.scoreAfterLucky and not self.hadAfterLucky: self.hadAfterLucky = True @@ -241,9 +297,6 @@ class MolpyUp: elif self.score > self.scoreCastle and not self.hadCastle: self.hadCastle = True return self.platformTypeCastle - elif self.score > self.scoreRaftcastle and not self.hadRaftcastle: - self.hadRaftcastle = True - return self.platformTypeRaftcastle else: return self.platformTypeGrass else: @@ -258,40 +311,62 @@ class MolpyUp: check = self.platforms[1][1] - self.cameray if check > self.sy: platformType = self.choosePlatformType() - self.platforms.append([random.randint(0, self.sx * 7 // 8), self.platforms[-1][1] - self.sy // 12, platformType, False, False]) + if platformType == self.platformTypeTheEnd: + if not self.hadTheEnd: + self.platforms.append([self.sx // 2 - self.imgPlatformTheEnd.get_width() // 2, self.platforms[-1][1] - self.sy // 4, self.platformTypeTheEnd, False, False]) + self.platforms.append([self.sx // 2 - self.imgPlatformWonTheGame.get_width() // 2, self.platforms[-1][1] - self.sy * 2 // 3, self.platformTypeWonTheGame, False, False]) + self.hadTheEnd = True + elif platformType == self.platformTypeWater or platformType == self.platformTypeRaftcastle: + self.platforms.append([random.randint(0, self.sx * 7 // 8), self.platforms[-1][1] - self.sy // 8, platformType, False, False]) + else: + self.platforms.append([random.randint(0, self.sx * 7 // 8), self.platforms[-1][1] - self.sy // 12, platformType, False, False]) if platformType <= self.platformTypeNormal: + if platformType == self.platformTypeSand: + self.platforms[-1][-1] = random.randint(0, len(self.imgPlatformSand) - 1) + elif platformType == self.platformTypeGrass: + self.platforms[-1][-1] = random.randint(0, len(self.imgPlatformGrass) - 1) + else: + self.platforms[-1][-1] = random.randint(0, len(self.imgPlatformWater) - 1) x = self.platforms[-1][0] y = self.platforms[-1][1] if platformType == self.platformTypeGrass and self.score > self.scoreSnake and not self.hadSnake: self.items.append([x - 10, y + 9, self.itemTypeSnake, False]) self.hadSnake = True elif platformType == self.platformTypeGrass and self.score > self.scorePrickly and not self.hadPrickly: - self.items.append([x + self.imgPlatformSand.get_width() // 3, y + 8, self.itemTypePrickly, False]) + self.items.append([x + self.imgPlatformSand[0].get_width() // 3, y + 8, self.itemTypePrickly, False]) self.hadPrickly = True else: - check = random.randint(0, 1000) - if check > 900: - itemType = random.randint(0,1000) - if itemType < 100: - self.items.append([x + self.imgPlatformSand.get_width() * 3 // 4, y + 7, self.itemTypeBeanie, False]) - elif itemType < 300 and platformType == self.platformTypeSand: - self.items.append([x + self.imgPlatformSand.get_width() // 4, y + 6, self.itemTypeSandcastle, False]) - elif itemType < 700 and platformType == self.platformTypeSand: - self.items.append([x + self.imgPlatformSand.get_width() // 2, y + 6, self.itemTypeFlag, False]) - elif itemType < 200 and platformType == self.platformTypeGrass: - self.items.append([x + self.imgPlatformSand.get_width() // 2, y + 6, self.itemTypeFlag, False]) - elif itemType < 500 and platformType == self.platformTypeGrass and self.score > self.scorePrickly: - self.items.append([x + self.imgPlatformSand.get_width() // 3, y + 8, self.itemTypePrickly, False]) - elif itemType < 800 and platformType == self.platformTypeGrass and self.score > self.scoreSnake: + check = random.randint(0, 999) + if check > 800: + xx = x + random.randint(0, self.imgPlatformSand[0].get_width() - 40) + itemType = random.randint(0,999) + if itemType < 50: + self.items.append([xx, y + 7, self.itemTypeBeanie, False]) + elif itemType < 150 and platformType == self.platformTypeSand: + self.items.append([xx, y + 7, self.itemTypeSandcastle, False]) + elif itemType < 350 and platformType == self.platformTypeSand: + self.items.append([xx, y + 7, self.itemTypeFlag, False]) + elif itemType < 950 and platformType == self.platformTypeSand: + self.items.append([xx, y + 8, self.itemTypePlantSand, itemType % len(self.imgPlantSand)]) + elif itemType < 100 and platformType == self.platformTypeGrass: + self.items.append([xx, y + 6, self.itemTypeFlag, False]) + elif itemType < 700 and platformType == self.platformTypeGrass: + self.items.append([xx, y + 10, self.itemTypePlantGrass, itemType % len(self.imgPlantGrass)]) + elif itemType < 850 and platformType == self.platformTypeGrass and self.score > self.scorePrickly: + self.items.append([xx, y + 8, self.itemTypePrickly, False]) + elif itemType < 950 and platformType == self.platformTypeGrass and self.score > self.scoreSnake: self.items.append([x - 10, y + 9, self.itemTypeSnake, False]) else: - self.items.append([x, y + 10, self.itemTypeAccelerator, False]) + self.items.append([xx - 5, y + 10, self.itemTypeAccelerator, False]) self.platforms.pop(0) - self.score += 1 + if self.score < self.scoreEpilogue: + self.score += 1 if p[2] == self.platformTypeSand: - self.screen.blit(self.imgPlatformSand, (p[0], p[1] - self.cameray)) + self.screen.blit(self.imgPlatformSand[p[-1]], (p[0], p[1] - self.cameray)) elif p[2] == self.platformTypeGrass: - self.screen.blit(self.imgPlatformGrass, (p[0], p[1] - self.cameray)) + self.screen.blit(self.imgPlatformGrass[p[-1]], (p[0], p[1] - self.cameray)) + elif p[2] == self.platformTypeWater: + self.screen.blit(self.imgPlatformWater[p[-1]], (p[0], p[1] - self.cameray)) elif p[2] == self.platformTypeGrapevine: self.screen.blit(self.imgPlatformGrapevine, (p[0], p[1] - self.cameray)) elif p[2] == self.platformTypeAfterLucky: @@ -303,14 +378,18 @@ class MolpyUp: self.screen.blit(self.imgFlagRight, (p[0] + self.imgPlatformCastle.get_width() - 16, p[1] - 4 - self.cameray)) self.screen.blit(self.imgPlatformCastle, (p[0], p[1] - self.cameray)) elif p[2] == self.platformTypeRaftcastle: - if p[-2]: - self.screen.blit(self.imgFlagRight, (p[0] + self.imgPlatformRaftcastle.get_width() - 115, p[1] - 10 - self.cameray)) + if self.raftcastleHasFlag: + self.screen.blit(self.imgFlagRight, (p[0] + 50, p[1] - 13 - self.cameray)) self.screen.blit(self.imgPlatformRaftcastle, (p[0], p[1] - self.cameray)) elif p[2] == self.platformTypeBreaking: if not p[-1]: self.screen.blit(self.imgPlatformBreaking, (p[0], p[1] - self.cameray)) else: self.screen.blit(self.imgPlatformBroken, (p[0], p[1] - self.cameray)) + elif p[2] == self.platformTypeTheEnd: + self.screen.blit(self.imgPlatformTheEnd, (p[0], p[1] - self.cameray)) + elif p[2] == self.platformTypeWonTheGame: + self.screen.blit(self.imgPlatformWonTheGame, (p[0], p[1] - self.cameray)) for item in self.items: if item[2] == self.itemTypeAccelerator: if item[-1]: @@ -343,6 +422,10 @@ class MolpyUp: imgItem = self.imgFlagRight else: imgItem = None + elif item[2] == self.itemTypePlantSand: + imgItem = self.imgPlantSand[item[-1]] + elif item[2] == self.itemTypePlantGrass: + imgItem = self.imgPlantGrass[item[-1]] if imgItem: self.screen.blit(imgItem, (item[0], item[1] - imgItem.get_height() - self.cameray)) if not item[-1]: @@ -355,7 +438,7 @@ class MolpyUp: self.playerWearsBeanie = True item[-1] = True elif item[2] == self.itemTypeSnake: - if self.playerx + self.imgPlayerRightUp.get_width() // 2 < item[0] + self.imgPlatformGrass.get_width() // 2: + if self.playerx + self.imgPlayerRightUp.get_width() // 2 < item[0] + self.imgPlatformGrass[0].get_width() // 2: self.xmovement = -self.sx // 30 self.direction = 0 self.cameray -= self.sy // 12 @@ -378,7 +461,7 @@ class MolpyUp: def generatePlatforms(self): on = self.sy while on > -self.sy // 6: - x = random.randint(0,self.sx * 8 // 7) + x = random.randint(0, self.sx * 8 // 7) self.platforms.append([x, on, self.choosePlatformType(), 0]) on -= self.sy // 12