From: Peter Gerwinski Date: Sat, 31 Mar 2018 11:54:48 +0000 (+0200) Subject: fixed collision mustard, implemented raftcastle X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=2900b811f3f50a5c1e081f0a0162f5b20658c04f;p=ott%2Fmolpy-up fixed collision mustard, implemented raftcastle --- diff --git a/assets/platformRaftcastle.png b/assets/platformRaftcastle.png new file mode 100644 index 0000000..82c1311 Binary files /dev/null and b/assets/platformRaftcastle.png differ diff --git a/assets/raftcastle.xcf.gz b/assets/raftcastle.xcf.gz new file mode 100644 index 0000000..f849259 Binary files /dev/null and b/assets/raftcastle.xcf.gz differ diff --git a/assets/snake.png b/assets/snake.png new file mode 100644 index 0000000..a512026 Binary files /dev/null and b/assets/snake.png differ diff --git a/assets/snake.xcf.gz b/assets/snake.xcf.gz new file mode 100644 index 0000000..da18bf1 Binary files /dev/null and b/assets/snake.xcf.gz differ diff --git a/assets/snakeLeft.png b/assets/snakeLeft.png new file mode 100644 index 0000000..c6d57c8 Binary files /dev/null and b/assets/snakeLeft.png differ diff --git a/assets/snakeRight.png b/assets/snakeRight.png new file mode 100644 index 0000000..46fd14e Binary files /dev/null and b/assets/snakeRight.png differ diff --git a/molpyup.py b/molpyup.py index 9edbf62..d1dfd44 100644 --- a/molpyup.py +++ b/molpyup.py @@ -46,19 +46,23 @@ class MolpyUp: platformTypeGrapevine = 2 platformTypeAfterLucky = 3 platformTypeCastle = 4 - platformTypeFloating = platformTypeCastle - platformTypeBreaking = 5 + platformTypeRaftcastle = 5 + platformTypeFloating = platformTypeRaftcastle + platformTypeBreaking = 6 itemTypeAccelerator = 0 itemTypeBeanie = 1 - itemTypePrickly = 2 - itemTypeSandcastle = 3 - itemTypeFlag = 4 + itemTypeSnake = 2 + itemTypePrickly = 3 + itemTypeSandcastle = 4 + itemTypeFlag = 5 - #scoreSnake = 600 # m1738 - scorePrickly = 696 # m2015 - scoreAfterLucky = 800 # m2315 - scoreCastle = 976 # m2825 + scoreSnake = 1738 + scorePrickly = 2015 + scoreGrass = 2193 + scoreAfterLucky = 2315 + scoreCastle = 2825 + scoreRaftcastle = 3031 def __init__(self): self.sx = 553 @@ -73,6 +77,7 @@ class MolpyUp: self.imgPlatformGrass = pygame.image.load("assets/platformGrass.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() @@ -87,6 +92,9 @@ class MolpyUp: self.imgAccelerator = pygame.image.load("assets/accelerator.png").convert_alpha() self.imgAcceleratorUsed = pygame.image.load("assets/acceleratorUsed.png").convert_alpha() self.imgBeanie = pygame.image.load("assets/beanie.png").convert_alpha() + self.imgSnake = pygame.image.load("assets/snake.png").convert_alpha() + self.imgSnakeLeft = pygame.image.load("assets/snakeLeft.png").convert_alpha() + self.imgSnakeRight = pygame.image.load("assets/snakeRight.png").convert_alpha() self.imgPrickly = pygame.image.load("assets/prickly.png").convert_alpha() self.imgPricklyCurled = pygame.image.load("assets/pricklyCurled.png").convert_alpha() self.imgSandcastle = pygame.image.load("assets/sandcastle.png").convert_alpha() @@ -109,8 +117,11 @@ class MolpyUp: self.xmovement = 0 self.playerWearsBeanie = False self.playerCarriesFlag = False + self.hadSnake = False + 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.generatePlatforms() @@ -118,7 +129,7 @@ class MolpyUp: if not self.jump: self.playery += self.gravity self.gravity += 1 - elif self.jump: + else: self.playery -= self.jump self.jump -= 1 key = pygame.key.get_pressed() @@ -181,15 +192,26 @@ class MolpyUp: def updatePlatforms(self): for p in self.platforms: - rect = pygame.Rect(p[0], p[1], self.imgPlatformSand.get_width(), self.imgPlatformSand.get_height()) - player = pygame.Rect(self.playerx, self.playery, self.imgPlayerRightUp.get_width() - 10, self.imgPlayerRightUp.get_height()) + if p[2] == self.platformTypeGrapevine: + img = self.imgPlatformGrapevine + elif p[2] == self.platformTypeAfterLucky: + img = self.imgPlatformAfterLucky + elif p[2] == self.platformTypeCastle: + img = self.imgPlatformCastle + elif p[2] == self.platformTypeRaftcastle: + 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()) + 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: p[-1] = True else: self.jump = self.sy // 20 self.gravity = 0 - if (p[2] == self.platformTypeAfterLucky or p[2] == self.platformTypeCastle) and self.playerCarriesFlag and not p[-2]: + if (p[2] == self.platformTypeAfterLucky or p[2] == self.platformTypeCastle or p[2] == self.platformTypeRaftcastle) and self.playerCarriesFlag and not p[-2]: self.playerCarriesFlag = False p[-2] = True self.sandcastles += 1 @@ -212,13 +234,16 @@ class MolpyUp: def choosePlatformType(self): platformType = random.randint(0, 1000) if platformType < 800: - if platformType < self.score: + if platformType < 1000 * self.score // self.scoreGrass: if self.score > self.scoreAfterLucky and not self.hadAfterLucky: self.hadAfterLucky = True return self.platformTypeAfterLucky 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: @@ -234,29 +259,33 @@ class MolpyUp: 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]) - check = random.randint(0, 1000) - if check > 900 and platformType <= self.platformTypeNormal: + if platformType <= self.platformTypeNormal: x = self.platforms[-1][0] y = self.platforms[-1][1] - itemType = random.randint(0,1000) - if itemType < 100: - itemType = self.itemTypeBeanie - self.items.append([x + self.imgPlatformSand.get_width() * 3 // 4, y + 6, itemType, False]) - elif itemType < 200 and platformType == self.platformTypeGrass: - itemType = self.itemTypeFlag - self.items.append([x + self.imgPlatformSand.get_width() // 2, y + 6, itemType, False]) - elif itemType < 600 and platformType == self.platformTypeGrass and self.score > self.scorePrickly: - itemType = self.itemTypePrickly - self.items.append([x + self.imgPlatformSand.get_width() // 3, y + 8, itemType, False]) - elif itemType < 300 and platformType == self.platformTypeSand: - itemType = self.itemTypeSandcastle - self.items.append([x + self.imgPlatformSand.get_width() // 4, y + 6, itemType, False]) - elif itemType < 800 and platformType == self.platformTypeSand: - itemType = self.itemTypeFlag - self.items.append([x + self.imgPlatformSand.get_width() // 2, y + 6, itemType, False]) + 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.hadPrickly = True else: - itemType = self.itemTypeAccelerator - self.items.append([x, y + 10, itemType, False]) + 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: + self.items.append([x - 10, y + 9, self.itemTypeSnake, False]) + else: + self.items.append([x, y + 10, self.itemTypeAccelerator, False]) self.platforms.pop(0) self.score += 1 if p[2] == self.platformTypeSand: @@ -273,6 +302,10 @@ class MolpyUp: if p[-2]: 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)) + 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)) @@ -289,6 +322,13 @@ class MolpyUp: imgItem = self.imgBeanie else: imgItem = None + elif item[2] == self.itemTypeSnake: + if item[-1] == -1: + imgItem = self.imgSnakeLeft + elif item[-1] == 1: + imgItem = self.imgSnakeRight + else: + imgItem = self.imgSnake elif item[2] == self.itemTypePrickly: if not item[-1]: imgItem = self.imgPrickly @@ -314,6 +354,17 @@ class MolpyUp: elif item[2] == self.itemTypeBeanie and not self.playerWearsBeanie: 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: + self.xmovement = -self.sx // 30 + self.direction = 0 + self.cameray -= self.sy // 12 + item[-1] = -1 + else: + self.xmovement = self.sx // 30 + self.direction = 0 + self.cameray -= self.sy // 12 + item[-1] = 1 elif item[2] == self.itemTypePrickly: item[-1] = True elif item[2] == self.itemTypeSandcastle and self.playerCarriesFlag: