]> bicyclesonthemoon.info Git - ott/molpy-up/commitdiff
bottom platform; platform add / remove conditions
authorb <rowerynaksiezycu@gmail.com>
Sat, 28 Mar 2026 08:16:22 +0000 (09:16 +0100)
committerb <rowerynaksiezycu@gmail.com>
Sat, 28 Mar 2026 08:16:22 +0000 (09:16 +0100)
assets/platformFrame1.png
molpyup.py

index 591ff890515eec01b55c8eb0204826117372fdea..56fd419b93a1f2dcdce5c5996480207879c60c62 100644 (file)
Binary files a/assets/platformFrame1.png and b/assets/platformFrame1.png differ
index 57f5f8f707a1215818466d3c2fb616ba746eddc1..d6f90393ad6c1473bd2359c6b797375ed5ad05fa 100644 (file)
@@ -244,6 +244,7 @@ class MolpyUp:
         self.pause = False
         if self.filename:
             self.restoreGame (self.filename)
+        self.playerLowestY = self.playery
 
     def saveGame(self):
         self.filename = datetime.datetime.now().strftime("%Y%m%d-%H%M%S.molpyup")
@@ -398,6 +399,8 @@ class MolpyUp:
          
         if not self.jump:
             self.playery += self.gravity
+            if self.playery > self.playerLowestY:
+                self.playerLowestY = self.playery
             if self.gravity < self.dropLimit:
                 self.gravity += 1
         else:
@@ -484,11 +487,12 @@ class MolpyUp:
             self.aiNextPlatformOk = False
         
         if self.molpyDown:
-            if self.playery - self.cameray >= self.sy // 3:
-                if self.jump:
-                    self.cameray += self.sy // 120
-                else:
-                    self.cameray += self.sy // 180
+            if self.playerLowestY - self.cameray >= self.sy // 2:
+                self.cameray += self.sy // 60
+            if self.hadTheEnd:
+                bottom = self.platforms[0][1] + self.platforms[0][8] - self.sy
+                if self.cameray > bottom:
+                    self.cameray = bottom
         else:
             if self.playery - self.cameray <= self.sy // 3:
                 self.cameray -= self.sy // 60
@@ -603,8 +607,9 @@ class MolpyUp:
         if platformType == self.platformTypeFrame1:
             if self.hadTheEnd:
                 return
+            self.hadTheEnd = True
             x = 0
-            y = self.sy * 2 // 3
+            y = self.sy // 3
         elif platformType == self.platformTypeTheEnd:
             if self.hadTheEnd:
                 return
@@ -681,22 +686,24 @@ class MolpyUp:
             if len(self.platforms) < 1:
                 return
             if self.molpyDown:
-                if self.platforms[0][1] - self.cameray < self.sy * 7 // 6:
+                if (self.platforms[0][1] - self.cameray < self.sy * 7 // 6) and not self.hadTheEnd:
                     self.generateNewPlatform()
                     if self.score > 1:
                         self.score -= 1
                     continue
-                if self.platforms[-1][1] - self.cameray < - self.platformHeight[self.platformTypeSand] - self.sy // 6:
+                if self.platforms[-1][1] - self.cameray < - self.platforms[-1][8] - self.sy // 6:
                     self.platforms.pop()
                     continue
-                break
             else:
-                if self.platforms[0][1] - self.cameray <= self.sy + self.sy // 12:
-                    break
-                self.generateNewPlatform()
-                self.platforms.pop(0)
-                if self.score < self.scoreEpilogue:
-                    self.score += 1
+                if (self.platforms[-1][1] - self.cameray > - self.platforms[-1][8] -  self.sy // 6) and not self.hadTheEnd:
+                    self.generateNewPlatform()
+                    if self.score < self.scoreEpilogue:
+                        self.score += 1
+                    continue
+                if self.platforms[0][1] - self.cameray > self.sy + self.sy // 12:
+                    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:
@@ -704,11 +711,15 @@ class MolpyUp:
         else:
             player2 = False
         for p in self.platforms:
-            rect = pygame.Rect(p[0], p[1], p[7], p[8])
+            rect = (
+                pygame.Rect(p[0], p[1] + p[8] // 2, p[7], p[8] // 2) if p[2] == self.platformTypeFrame1 else
+                pygame.Rect(p[0], p[1], p[7], p[8])
+            )
             collision = rect.colliderect(player)
             if player2 != False:
                 collision = rect.colliderect(player2) or collision
             if collision and self.gravity:
+                self.playerLowestY = self.playery
                 if p[2] == self.platformTypeBreaking:
                     p[4] = True
                 else:
@@ -772,8 +783,8 @@ 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] + (p[7]-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + self.aiNextPlatform[8]))
+        if self.aiDebag and self.aiNextPlatformOk:
+            self.screen.blit(self.imgMolpArrow, (self.aiNextPlatform[0] + (self.aiNextPlatform[7]-self.playerWidth)//2, self.aiNextPlatform[1] - self.cameray + self.aiNextPlatform[8]))
 
     def drawAndUpdateItems(self):
         if self.molpyDown: