]> bicyclesonthemoon.info Git - ott/molpy-up/commitdiff
dual game Molpy Up! and Molpy Down! seems ready.
authorb <rowerynaksiezycu@gmail.com>
Sat, 28 Mar 2026 08:56:25 +0000 (09:56 +0100)
committerb <rowerynaksiezycu@gmail.com>
Sat, 28 Mar 2026 08:56:25 +0000 (09:56 +0100)
README
molpyup.py

diff --git a/README b/README
index 8a50b9d9420625eefc412f0cbc4a25c2cc4d8136..91505e2821cc2990e1d94ed7058119ebc2da76b8 100644 (file)
--- a/README
+++ b/README
@@ -17,14 +17,14 @@ and the pygame library.
 
  * Under Apple MacOS, type "sudo easy_install pygame".
    To run the game, type "python molpyup.py".
-   See <http://forums.xkcd.com/viewtopic.php?p=4331564#p4331564> for details.
+   See <http://1190.bicyclesonthemoon.info/ott/view?p=4331564#p4331564> for details.
 
  * Under Microsoft Windows, download a Python interpreter from
    <https://www.python.org/downloads/>, and install it.
    Then type "py -m pip install -U pygame --user" in a command line
    to install the pygame library.
    To run the game, click on "molpyup.py"
-   See <http://forums.xkcd.com/viewtopic.php?p=4331549#p4331549> for details.
+   See <http://1190.bicyclesonthemoon.info/ott/view?p=4331549#p4331549> for details.
 
 In the game, the following keys can be used:
  - Use the left and right arrow keys to navigate.
index d6f90393ad6c1473bd2359c6b797375ed5ad05fa..83581036520464fda8a9f85859e3d74b88a25321 100644 (file)
@@ -85,8 +85,8 @@ class MolpyUp:
     scoreTheEnd     = 3089
     scoreEpilogue   = 3094
 
-    def __init__(self, molpyDown = False):
-        self.molpyDown = molpyDown
+    def __init__(self):
+        self.molpyDown = False
         self.relativeX=0
         self.sx = 553
         self.sy = 395
@@ -331,7 +331,11 @@ class MolpyUp:
             platformY = p[1]
             platformScore = 0
            
-            if (platformY < maxY) or (p[2] == self.platformTypeBreaking):
+            if (
+                (p[2] == self.platformTypeBreaking) or
+                (platformY < maxY) or
+                (platformY - self.cameray > self.sy)
+            ):
                 platformScore = float("-Inf")
                 p[6] = platformScore
                 continue
@@ -364,6 +368,8 @@ class MolpyUp:
                 platformScore = float("-Inf")
             platformScore *= 4 
            
+            if self.molpyDown:
+                distY = -distY
             if distY > 16:
                 platformScore += distY + distX // 2
             else:
@@ -487,7 +493,7 @@ class MolpyUp:
             self.aiNextPlatformOk = False
         
         if self.molpyDown:
-            if self.playerLowestY - self.cameray >= self.sy // 2:
+            if self.playerLowestY - self.cameray >= self.sy // 3:
                 self.cameray += self.sy // 60
             if self.hadTheEnd:
                 bottom = self.platforms[0][1] + self.platforms[0][8] - self.sy
@@ -615,7 +621,7 @@ class MolpyUp:
                 return
             elif self.platforms[-1][2] == self.platformTypeTheEnd:
                 self.hadTheEnd = True
-                platformType = platformWonTheGame
+                platformType = self.platformTypeWonTheGame
                 w = self.platformWidth[platformType]
                 h = self.platformHeight[platformType]
                 y = self.sy * 2 // 3
@@ -691,7 +697,7 @@ class MolpyUp:
                     if self.score > 1:
                         self.score -= 1
                     continue
-                if self.platforms[-1][1] - self.cameray < - self.platforms[-1][8] - self.sy // 6:
+                if self.platforms[-1][1] - self.cameray < - self.platforms[-1][8]:
                     self.platforms.pop()
                     continue
             else:
@@ -782,7 +788,7 @@ class MolpyUp:
                     (p[0], p[1] - self.cameray)
                 )
             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))
+                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 + p[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]))
 
@@ -926,10 +932,14 @@ class MolpyUp:
         self.waitForIt([K_RETURN])
 
     def run(self):
-        if len(sys.argv) > 1:
-            self.filename = sys.argv[1]
-        else:
-            self.filename = None
+        self.filename = None
+        for s in sys.argv[1:]:
+            if s.startswith('-'):
+                if s in ('-d', '--down'):
+                    self.molpyDown = True
+            elif self.filename is None:
+                self.filename = sys.argv[1]
+        
         self.reset()
         while True:
             self.screen.fill((255,255,255))
@@ -973,6 +983,8 @@ class MolpyUp:
                             self.molpyDown = not self.molpyDown
                             self.modeText = "Molpy " + ('Down!' if self.molpyDown else 'Up!')
                             self.hadTheEnd = False
+                            if self.score < 1:
+                                self.score = 1
                             for p in self.platforms:
                                 if p[2] == (self.platformTypeFrame1 if self.molpyDown else self.platformTypeWonTheGame):
                                     self.hadTheEnd = True