From: b Date: Sat, 28 Mar 2026 08:56:25 +0000 (+0100) Subject: dual game Molpy Up! and Molpy Down! seems ready. X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=5557ddbe77a6eeb47ccb79be79aa51242d5c40df;p=ott%2Fmolpy-up dual game Molpy Up! and Molpy Down! seems ready. --- diff --git a/README b/README index 8a50b9d..91505e2 100644 --- 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 for details. + See for details. * Under Microsoft Windows, download a Python interpreter from , 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 for details. + See for details. In the game, the following keys can be used: - Use the left and right arrow keys to navigate. diff --git a/molpyup.py b/molpyup.py index d6f9039..8358103 100644 --- a/molpyup.py +++ b/molpyup.py @@ -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