]> bicyclesonthemoon.info Git - ott/molpy-up/commitdiff
terminal velocity; platform size table
authorb <rowerynaksiezycu@gmail.com>
Fri, 27 Mar 2026 22:56:28 +0000 (23:56 +0100)
committerb <rowerynaksiezycu@gmail.com>
Fri, 27 Mar 2026 22:56:28 +0000 (23:56 +0100)
molpydown.py
molpyup.py

index 5c383192751b9ec836c1b07c4f306df47375a977..1aec6624410bb50b2bd7aeef44ca606977b22576 100644 (file)
@@ -167,8 +167,37 @@ class MolpyUp:
         self.playerWidth = self.imgPlayerRightUp.get_width()
         self.playerHalfWidth = self.playerWidth // 2
         self.platformSpeed = self.extrax // 10
-        self.platformSandHeight = self.imgPlatformSand[0].get_height()
-        self.platformSandWidth = self.imgPlatformSand[0].get_width()
+        self.platformHeight = [
+            self.imgPlatformSand[0].get_height(),
+            self.imgPlatformGrass[0].get_height(),
+            self.imgPlatformGrapevine.get_height(),
+            self.imgPlatformAfterLucky.get_height(),
+            self.imgPlatformCastle.get_height(),
+            self.imgPlatformWater[0].get_height(),
+            self.imgPlatformRaftcastle.get_height(),
+            self.imgPlatformLuckySleeping.get_height(),
+            self.imgPlatformBreaking.get_height(),
+            self.imgPlatformTheEnd.get_height(),
+            self.imgPlatformWonTheGame.get_height(),
+            self.imgPlatformFrame1.get_height()
+        ]
+        self.platformWidth = [
+            self.imgPlatformSand[0].get_width(),
+            self.imgPlatformGrass[0].get_width(),
+            self.imgPlatformGrapevine.get_width(),
+            self.imgPlatformAfterLucky.get_width(),
+            self.imgPlatformCastle.get_width(),
+            self.imgPlatformWater[0].get_width(),
+            self.imgPlatformRaftcastle.get_width(),
+            self.imgPlatformLuckySleeping.get_width(),
+            self.imgPlatformBreaking.get_width(),
+            self.imgPlatformTheEnd.get_width(),
+            self.imgPlatformWonTheGame.get_width(),
+            self.imgPlatformFrame1.get_width()
+        ]
+        self.dropLimit = 25
+        if self.dropLimit >= self.platformHeight[self.platformTypeSand] + self.playerHeight:
+            self.dropLimit = self.platformHeight[self.platformTypeSand] + self.playerHeight - 1
         self.showArrow = True
         
     def reset(self):
@@ -192,10 +221,6 @@ class MolpyUp:
         self.hadLucky = False
         self.hadTheEnd = False
         self.raftcastleHasFlag = False
-        self.platforms = [
-            [self.sx // 2 - self.imgPlatformWonTheGame.get_width() // 2, self.playery - self.sy // 2, self.platformTypeWonTheGame, False, False, -1, 0, self.imgPlatformWonTheGame.get_width()],
-            [self.sx // 2 - self.imgPlatformTheEnd.get_width() // 2, self.playery + self.sy // 6, self.platformTypeTheEnd, False, False, -1, 0, self.imgPlatformTheEnd.get_width()]
-        ]
         self.generateInitialPlatforms()
         self.items = []
         self.aiNextPlatformOk = False
@@ -356,7 +381,8 @@ class MolpyUp:
          
         if not self.jump:
             self.playery += self.gravity
-            self.gravity += 1
+            if self.gravity < self.dropLimit:
+                self.gravity += 1
         else:
             self.playery -= self.jump
             self.jump -= 1
@@ -519,12 +545,18 @@ class MolpyUp:
     def generateNewPlatform(self):
         platform = False
         platformType = self.choosePlatformType()
+        w = self.platformWidth[platformType]
+        h = self.platformHeight[platformType]
         if platformType == self.platformTypeWater or platformType == self.platformTypeRaftcastle:
-            platform = [random.randint(0, self.sx - self.platformSandWidth), self.platforms[-1][1] + self.sy // 6, platformType, False, False, -1, 0, self.platformSandWidth]
+            x = random.randint(0, self.sx - w)
+            y = self.platforms[-1][1] + self.sy // 6
         elif platformType == self.platformTypeLucky:
-            platform = [0, self.platforms[-1][1] + self.sy // 12, platformType, False, False, -1, False, self.platformSandWidth]
+            x = 0
+            y = self.platforms[-1][1] + self.sy // 12
         else:
-            platform = [random.randint(0, self.sx - self.platformSandWidth), self.platforms[-1][1] + self.sy // 9, platformType, False, False, -1, 0, self.platformSandWidth]
+            x = random.randint(0, self.sx - self.w)
+            y = self.platforms[-1][1] + self.sy // 9,
+        platform = [x, y, platformType, False, False, -1, 0, w, h]
         if platformType <= self.platformTypeNormal:
             if platformType == self.platformTypeSand:
                 platform[4] = random.randint(0, len(self.imgPlatformSand) - 1)
@@ -532,8 +564,6 @@ class MolpyUp:
                 platform[4] = random.randint(0, len(self.imgPlatformGrass) - 1)
             else:
                 platform[4] = random.randint(0, len(self.imgPlatformWater) - 1)
-            x = platform[0]
-            y = platform[1]
             if platformType == self.platformTypeGrass and self.score > self.scoreSnake and not self.hadSnake:
                 platform[5]=self.itemTypeSnake
                 self.items.append([x - 10, y + 9, self.itemTypeSnake, False])
@@ -545,7 +575,7 @@ class MolpyUp:
             elif self.score > 0:
                 check = random.randint(0, 999)
                 if check > 800:
-                    xx = x + random.randint(0, self.platformSandWidth - 40)
+                    xx = x + random.randint(0, w - 40)
                     itemType = random.randint(0,999)
                     if itemType < 50:
                         platform[5]=self.itemTypeBeanie
@@ -586,18 +616,21 @@ class MolpyUp:
                 if self.score > 1:
                     self.score -= 1
                 continue
-            if self.platforms[0][1] - self.cameray < - self.platformSandHeight - self.sy // 6:
+            if self.platforms[0][1] - self.cameray < - self.platformHeight[self.platformTypeSand] - self.sy // 6:
                 self.platforms.pop(0)
                 continue
             break
+        colX = self.playerx % self.sx
+        player = pygame.Rect(colX + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+        if colX > self.sx - self.playerWidth:
+            player2 = pygame.Rect(colX - self.sx + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+        else:
+            player2 = False
         for p in self.platforms:
-            rect = pygame.Rect(p[0], p[1], p[7], self.platformSandHeight)
-            colX = self.playerx % self.sx
-            player = pygame.Rect(colX + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+            rect = pygame.Rect(p[0], p[1], p[7], p[8])
             collision = rect.colliderect(player)
-            if colX > self.sx - self.playerWidth:
-                player = pygame.Rect(colX - self.sx + 15, self.playery, self.playerWidth - 30, self.playerHeight)
-                collision = rect.colliderect(player) or collision
+            if player2:          
+                collision = rect.colliderect(player2) or collision
             if collision and self.gravity:
                 if p[2] == self.platformTypeBreaking:
                     p[4] = True
@@ -670,7 +703,7 @@ class MolpyUp:
             if self.aiDebag:
                 self.screen.blit(self.font.render(str(p[2])+" "+str(p[5])+" "+str(p[6]), -1, (0, 0x57, 0xaf) if self.ai else (0xbb, 0x66, 0x22)), (p[0], p[1] - self.cameray + 16))
         if self.aiDebag:
-            self.screen.blit(self.imgMolpArrow, (self.aiNextPlatform[0] + (self.platformSandWidth-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + 16))
+            self.screen.blit(self.imgMolpArrow, (self.aiNextPlatform[0] + (self.platformWidth[self.platformTypeSand]-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + 16))
 
     def drawAndUpdateItems(self):
         while self.items and self.items[0][1] - self.cameray > self.sy + self.sy // 12:
@@ -746,6 +779,21 @@ class MolpyUp:
                         item[-1] = True
 
     def generateInitialPlatforms(self):
+        self.platforms = [
+            [
+                self.sx // 2 - self.platformWidth[self.platformTypeWonTheGame] // 2,
+                self.playery - self.sy // 2,
+                self.platformTypeWonTheGame, False, False, -1, 0,
+                self.platformWidth[self.platformTypeWonTheGame],
+                self.platformHeight[self.platformTypeWonTheGame]
+            ], [
+                self.sx // 2 - self.platformWidth[self.platformTypeTheEnd] // 2,
+                self.playery + self.sy // 6,
+                self.platformTypeTheEnd, False, False, -1, 0,
+                self.platformWidth[self.platformTypeTheEnd],
+                self.platformHeight[self.platformTypeTheEnd]
+            ]
+        ]
         while self.platforms[-1][1] < self.sy * 10 // 6:
             self.generateNewPlatform()
 
index 4e9f59c56d90aa8e0048522c9a8c32623ddf7c57..9e934baa6d9942329943444c5cc73b01af917374 100644 (file)
@@ -164,8 +164,35 @@ class MolpyUp:
         self.playerWidth = self.imgPlayerRightUp.get_width()
         self.playerHalfWidth = self.playerWidth // 2
         self.platformSpeed = self.extrax // 10
-        self.platformSandHeight = self.imgPlatformSand[0].get_height()
-        self.platformSandWidth = self.imgPlatformSand[0].get_width()
+        self.platformHeight = [
+            self.imgPlatformSand[0].get_height(),
+            self.imgPlatformGrass[0].get_height(),
+            self.imgPlatformGrapevine.get_height(),
+            self.imgPlatformAfterLucky.get_height(),
+            self.imgPlatformCastle.get_height(),
+            self.imgPlatformWater[0].get_height(),
+            self.imgPlatformRaftcastle.get_height(),
+            self.imgPlatformLuckySleeping.get_height(),
+            self.imgPlatformBreaking.get_height(),
+            self.imgPlatformTheEnd.get_height(),
+            self.imgPlatformWonTheGame.get_height()
+        ]
+        self.platformWidth = [
+            self.imgPlatformSand[0].get_width(),
+            self.imgPlatformGrass[0].get_width(),
+            self.imgPlatformGrapevine.get_width(),
+            self.imgPlatformAfterLucky.get_width(),
+            self.imgPlatformCastle.get_width(),
+            self.imgPlatformWater[0].get_width(),
+            self.imgPlatformRaftcastle.get_width(),
+            self.imgPlatformLuckySleeping.get_width(),
+            self.imgPlatformBreaking.get_width(),
+            self.imgPlatformTheEnd.get_width(),
+            self.imgPlatformWonTheGame.get_width()
+        ]
+        self.dropLimit = 25
+        if self.dropLimit >= self.platformHeight[self.platformTypeSand] + self.playerHeight:
+            self.dropLimit = self.platformHeight[self.platformTypeSand] + self.playerHeight - 1
         self.showArrow = True
         
     def reset(self):
@@ -189,7 +216,7 @@ class MolpyUp:
         self.hadLucky = False
         self.hadTheEnd = False
         self.raftcastleHasFlag = False
-        self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, 0, 0, -1, 0, self.platformSandWidth]]
+        self.platforms = [[self.playerx, self.playery + self.sy // 6, self.platformTypeSand, 0, 0, -1, 0, self.platformWidth[self.platformTypeSand], self.platformHeight[self.platformTypeSand]]]
         self.generateInitialPlatforms()
         self.items = []
         self.aiNextPlatformOk = False
@@ -350,7 +377,8 @@ class MolpyUp:
          
         if not self.jump:
             self.playery += self.gravity
-            self.gravity += 1
+            if self.gravity < self.dropLimit:
+                self.gravity += 1
         else:
             self.playery -= self.jump
             self.jump -= 1
@@ -511,19 +539,31 @@ class MolpyUp:
 
     def generateNewPlatform(self):
         platform = False
-        platform2 = False
         platformType = self.choosePlatformType()
+        w = self.platformWidth[platformType]
+        h = self.platformHeight[platformType]
         if platformType == self.platformTypeTheEnd:
-            if not self.hadTheEnd:
-                platform2 = [self.sx // 2 - self.imgPlatformTheEnd.get_width() // 2, self.platforms[-1][1] - self.sy // 4, self.platformTypeTheEnd, False, False, -1, 0, self.imgPlatformTheEnd.get_width()]
-                platform = [self.sx // 2 - self.imgPlatformWonTheGame.get_width() // 2, platform2[1] - self.sy * 2 // 3, self.platformTypeWonTheGame, False, False, -1, 0, self.imgPlatformWonTheGame.get_width()]
+            if self.hadTheEnd:
+                return
+            elif platform[-1][2] == self.platformTypeTheEnd:
                 self.hadTheEnd = True
+                platformType = platformWonTheGame
+                w = self.platformWidth[platformType]
+                h = self.platformHeight[platformType]
+                y = self.platforms[-1][1] - self.sy * 2 // 3
+            else:
+                y = self.platforms[-1][1] - self.sy // 4
+            x = self.sx // 2 - w // 2
         elif platformType == self.platformTypeWater or platformType == self.platformTypeRaftcastle:
-            platform = [random.randint(0, self.sx - self.platformSandWidth), self.platforms[-1][1] - self.sy // 8, platformType, False, False, -1, 0, self.platformSandWidth]
+            x = random.randint(0, self.sx - w)
+            y = self.platforms[-1][1] - self.sy // 8
         elif platformType == self.platformTypeLucky:
-            platform = [0, self.platforms[-1][1] - self.sy // 12, platformType, False, False, -1, False, self.platformSandWidth]
+            x = 0
+            y = self.platforms[-1][1] - self.sy // 12
         else:
-            platform = [random.randint(0, self.sx - self.platformSandWidth), self.platforms[-1][1] - self.sy // 12, platformType, False, False, -1, 0, self.platformSandWidth]
+            x = random.randint(0, self.sx - w)
+            y = self.platforms[-1][1] - self.sy // 9
+        platform = [x, y, platformType, False, False, -1, 0, w, h]
         if platformType <= self.platformTypeNormal:
             if platformType == self.platformTypeSand:
                 platform[4] = random.randint(0, len(self.imgPlatformSand) - 1)
@@ -531,8 +571,6 @@ class MolpyUp:
                 platform[4] = random.randint(0, len(self.imgPlatformGrass) - 1)
             else:
                 platform[4] = random.randint(0, len(self.imgPlatformWater) - 1)
-            x = platform[0]
-            y = platform[1]
             if platformType == self.platformTypeGrass and self.score > self.scoreSnake and not self.hadSnake:
                 platform[5]=self.itemTypeSnake
                 self.items.append([x - 10, y + 9, self.itemTypeSnake, False])
@@ -544,7 +582,7 @@ class MolpyUp:
             elif self.score > 0:
                 check = random.randint(0, 999)
                 if check > 800:
-                    xx = x + random.randint(0, self.platformSandWidth - 40)
+                    xx = x + random.randint(0, w - 40)
                     itemType = random.randint(0,999)
                     if itemType < 50:
                         platform[5]=self.itemTypeBeanie
@@ -573,8 +611,6 @@ class MolpyUp:
                     else:
                         platform[5]=self.itemTypeAccelerator
                         self.items.append([xx - 5, y + 10, self.itemTypeAccelerator, False])
-        if platform2 != False:
-            self.platforms.append(platform2)
         if platform != False:
             self.platforms.append(platform)
 
@@ -588,14 +624,17 @@ class MolpyUp:
             self.platforms.pop(0)
             if self.score < self.scoreEpilogue:
                 self.score += 1
+        colX = self.playerx % self.sx
+        player = pygame.Rect(colX + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+        if colX > self.sx - self.playerWidth:
+            player2 = pygame.Rect(colX - self.sx + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+        else:
+            player2 = False
         for p in self.platforms:
-            rect = pygame.Rect(p[0], p[1], p[7], self.platformSandHeight)
-            colX = self.playerx % self.sx
-            player = pygame.Rect(colX + 15, self.playery, self.playerWidth - 30, self.playerHeight)
+            rect = pygame.Rect(p[0], p[1], p[7], p[8])
             collision = rect.colliderect(player)
-            if colX > self.sx - self.playerWidth:
-                player = pygame.Rect(colX - self.sx + 15, self.playery, self.playerWidth - 30, self.playerHeight)
-                collision = rect.colliderect(player) or collision
+            if player2:          
+                collision = rect.colliderect(player2) or collision
             if collision and self.gravity and self.playery < (p[1] - self.cameray):
                 if p[2] == self.platformTypeBreaking:
                     p[4] = True
@@ -668,7 +707,7 @@ class MolpyUp:
             if self.aiDebag:
                 self.screen.blit(self.font.render(str(p[2])+" "+str(p[5])+" "+str(p[6]), -1, (0, 0x57, 0xaf) if self.ai else (0xbb, 0x66, 0x22)), (p[0], p[1] - self.cameray + 16))
         if self.aiDebag:
-            self.screen.blit(self.imgMolpArrow, (self.aiNextPlatform[0] + (self.platformSandWidth-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + 16))
+            self.screen.blit(self.imgMolpArrow, (self.aiNextPlatform[0] + (self.platformWidth[self.platformTypeSand]-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + 16))
 
     def drawAndUpdateItems(self):
         while self.items and self.items[0][1] - self.cameray > self.sy + self.sy // 12: