import random
class MolpyUp:
+
+ platformTypeSand = 0
+ platformTypeGrass = 1
+ platformTypeNormal = platformTypeGrass
+ platformTypeGrapevine = 2
+ platformTypeAfterLucky = 3
+ platformTypeCastle = 4
+ platformTypeFloating = platformTypeCastle
+ platformTypeBreaking = 5
+
+ itemTypeAccelerator = 0
+ itemTypeBeanie = 1
+ itemTypePrickly = 2
+ itemTypeSandcastle = 3
+ itemTypeFlag = 4
+
+ #scoreSnake = 600 # m1738
+ scorePrickly = 696 # m2015
+ scoreAfterLucky = 800 # m2315
+ scoreCastle = 976 # m2825
+
def __init__(self):
self.sx = 553
self.sy = 395
self.screen = pygame.display.set_mode((self.sx, self.sy))
pygame.font.init()
self.font = pygame.font.SysFont("xkcd,sans", 25)
+ self.clock = pygame.time.Clock()
self.xmovementmax = 10
- self.platformTypeSand = 0
- self.platformTypeGrass = 1
- self.platformTypeFloating = 2
- self.platformTypeBreaking = 3
- self.itemTypeAccelerator = 0
- self.itemTypeBeanie = 1
- self.itemTypeSandcastle = 2
- self.itemTypeFlag = 3
self.imgPlatformSand = pygame.image.load("assets/platformSand.png").convert_alpha()
self.imgPlatformGrass = pygame.image.load("assets/platformGrass.png").convert_alpha()
- self.imgPlatformFloating = pygame.image.load("assets/platformFloating.png").convert_alpha()
+ self.imgPlatformAfterLucky = pygame.image.load("assets/platformAfterLucky.png").convert_alpha()
+ self.imgPlatformCastle = pygame.image.load("assets/platformCastle.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.imgPlayerRightUp = pygame.image.load("assets/playerRightUp.png").convert_alpha()
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.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()
self.imgFlagLeft = pygame.image.load("assets/flagLeft.png").convert_alpha()
self.imgFlagLeftDown = pygame.image.load("assets/flagLeftDown.png").convert_alpha()
self.xmovement = 0
self.playerWearsBeanie = False
self.playerCarriesFlag = False
- self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, False]]
+ self.hadAfterLucky = False
+ self.hadCastle = False
+ self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, False, False]]
self.generatePlatforms()
def updatePlayer(self):
if self.xmovement > -self.xmovementmax:
self.xmovement -= 1
self.direction = 1
- elif key[K_PLUS]:
+ 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))
- elif key[K_MINUS]:
+ 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))
else:
def updatePlatforms(self):
for p in self.platforms:
- rect = pygame.Rect(p[0], p[1], self.imgPlatformSand.get_width() - 10, self.imgPlatformSand.get_height())
+ 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 rect.colliderect(player) and self.gravity and self.playery < (p[1] - self.cameray):
- if p[2] != self.platformTypeBreaking:
+ if p[2] == self.platformTypeBreaking:
+ p[-1] = True
+ else:
self.jump = self.sy // 20
self.gravity = 0
- else:
- p[-1] = 1
- if p[2] == self.platformTypeFloating:
- if p[-1] == 1:
+ 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
+ if p[2] > self.platformTypeNormal and p[2] <= self.platformTypeFloating:
+ if p[-1]:
+ if p[2] == self.platformTypeAfterLucky:
+ img = self.imgPlatformAfterLucky
+ elif p[2] == self.platformTypeCastle:
+ img = self.imgPlatformCastle
+ else:
+ img = self.imgPlatformGrapevine
p[0] += self.extrax // 10
- if p[0] + self.imgPlatformFloating.get_width() > self.sx + self.extrax:
- p[-1] = 0
+ if p[0] + img.get_width() > self.sx + self.extrax:
+ p[-1] = False
else:
p[0] -= self.extrax // 10
if p[0] <= 0:
- p[-1] = 1
+ p[-1] = True
def choosePlatformType(self):
platformType = random.randint(0, 1000)
if platformType < 800:
if platformType < self.score:
- return self.platformTypeGrass
+ 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
+ else:
+ return self.platformTypeGrass
else:
return self.platformTypeSand
elif platformType < 900:
- return self.platformTypeFloating
+ return self.platformTypeGrapevine
else:
return self.platformTypeBreaking
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])
+ 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.platformTypeGrass:
+ if check > 900 and 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])
self.screen.blit(self.imgPlatformSand, (p[0], p[1] - self.cameray))
elif p[2] == self.platformTypeGrass:
self.screen.blit(self.imgPlatformGrass, (p[0], p[1] - self.cameray))
- elif p[2] == self.platformTypeFloating:
- self.screen.blit(self.imgPlatformFloating, (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:
+ if p[-2]:
+ self.screen.blit(self.imgFlagRight, (p[0] + 47, p[1] - 12 - self.cameray))
+ self.screen.blit(self.imgPlatformAfterLucky, (p[0], p[1] - self.cameray))
+ elif p[2] == self.platformTypeCastle:
+ 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.platformTypeBreaking:
- if not p[3]:
+ 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))
imgItem = self.imgBeanie
else:
imgItem = None
+ elif item[2] == self.itemTypePrickly:
+ if not item[-1]:
+ imgItem = self.imgPrickly
+ else:
+ imgItem = self.imgPricklyCurled
elif item[2] == self.itemTypeSandcastle:
imgItem = self.imgSandcastle
if item[-1]:
elif item[2] == self.itemTypeBeanie and not self.playerWearsBeanie:
self.playerWearsBeanie = True
item[-1] = True
+ elif item[2] == self.itemTypePrickly:
+ item[-1] = True
elif item[2] == self.itemTypeSandcastle and self.playerCarriesFlag:
self.playerCarriesFlag = False
item[-1] = True
def waitForIt(self, its):
run = False
while not run:
+ self.clock.tick(self.speed)
event = pygame.event.poll()
if event.type == KEYDOWN:
key = pygame.key.get_pressed()
self.waitForIt([K_RETURN])
def run(self):
- clock = pygame.time.Clock()
self.reset()
while True:
self.screen.fill((255,255,255))
- clock.tick(self.speed)
+ self.clock.tick(self.speed)
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()