explanation
authorFrank DeMarco <frank.s.demarco@gmail.com>
Sun, 25 May 2014 19:01:25 +0000 (04:01 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Sun, 25 May 2014 19:01:25 +0000 (04:01 +0900)
config
lake_of_heavenly_wind/LakeOfHeavenlyWind.py
resource/Book-of-Changes
resource/high-scores

diff --git a/config b/config
index b0c17e4..87d5b6e 100644 (file)
--- a/config
+++ b/config
@@ -2,7 +2,7 @@
 contact-name = Frank DeMarco
 license = Public Domain
 contact-email = frank.s.demarco@gmail.com
-title = Lake of Heavenly Wind
+title = Wind from Heaven's Lake
 url = http://A-O.in/
 summary = Consult the oracle while protecting your pulp supply!
 platform = Linux
index 9b3344a..3b32a87 100644 (file)
@@ -16,6 +16,7 @@ from pygame.locals import *
 from lake_of_heavenly_wind.pgfw.Game import Game
 from lake_of_heavenly_wind.pgfw.GameChild import GameChild
 from lake_of_heavenly_wind.pgfw.Sprite import Sprite
+from lake_of_heavenly_wind.pgfw.Animation import Animation
 
 class LakeOfHeavenlyWind(Game):
 
@@ -44,27 +45,68 @@ class Book(GameChild, list):
         for block in codecs.open(path, "r", "utf-8").read().split("\n\n"):
             self.append(Hexagram(self, block))
 
+    def hide_indicators(self):
+        for hexagram in self:
+            hexagram.indicator.hide()
+
+    def hide_explanations(self):
+        for hexagram in self:
+            hexagram.explanation.hide()
+
+    def are_indicators_hidden(self):
+        return all(hexagram.indicator.is_hidden() for hexagram in self)
+
     def update(self):
         for hexagram in self:
             hexagram.update()
 
 
-class Hexagram(Sprite):
+class Hexagram(GameChild):
 
     def __init__(self, parent, block):
-        Sprite.__init__(self, parent, 4000)
+        GameChild.__init__(self, parent)
         lines = self.lines = block.split("\n")
-        font = Font(self.get_resource("display", "font"), 14)
-        for line in map(unicode, lines):
-            frame = Surface((640, 16), SRCALPHA)
-            caption = font.render(line, True, (102, 102, 102))
-            rect = caption.get_rect()
-            rect.center = frame.get_rect().center
-            frame.blit(caption, rect)
-            self.add_frame(frame)
-        self.location.center = self.parent.parent.game_screen.link.background. \
-                               location.center
-        self.hide()
+        self.index = [int(ch) for ch in lines[0]]
+        font_path = self.get_resource("display", "font")
+        font = Font(font_path, 10)
+        explanation = self.explanation = Sprite(self, 4000)
+        for line in map(unicode, lines[1:]):
+            if line:
+                frame = Surface((640, 16), SRCALPHA)
+                spaced = line[0]
+                for ch in line[1:]:
+                    spaced += " " + ch
+                caption = font.render(spaced, True, (102, 102, 102))
+                rect = caption.get_rect()
+                rect.center = frame.get_rect().center
+                frame.blit(caption, rect)
+                explanation.add_frame(frame)
+        explanation.location.center = self.parent.parent.game_screen.link. \
+                                  background.location.center
+        explanation.hide(),
+        indicator = self.indicator = Sprite(self, 500)
+        font = Font(font_path, 36)
+        font.set_italic(True)
+        indicator.add_frame(font.render(lines[1][0], True, (31, 31, 31)))
+        blank = Surface(indicator.location.size)
+        blank.set_colorkey((0, 0, 0))
+        indicator.add_frame(blank)
+        rect = self.parent.parent.game_screen.oracle.screens[0].get_rect()
+        indicator.location.center = 32 + rect.centerx, 16 + rect.centery
+        indicator.add_location(offset=(self.get_display_surface(). \
+                                       get_width() - rect.centerx * 2 - 64, 0))
+        indicator.hide()
+
+    def show_indicator(self):
+        self.indicator.unhide()
+
+    def show_explanation(self):
+        self.explanation.get_current_frameset().reset()
+        self.explanation.unhide()
+
+    def update(self):
+        self.explanation.update()
+        self.indicator.update()
 
 
 class HighScores(GameChild):
@@ -130,10 +172,10 @@ class Title(GameChild):
         caption = self.caption = Sprite(self, 5000)
         font = Font(self.get_resource("display", "font"), 12)
         color = Color(0, 0, 0)
-        if random() < .15:
-            texts = ["Pleasure in Strong Penetration", u"兌 乾 巽"]
+        if random() < .92:
+            texts = ["Wind from Heaven's Lake", u"澤 天 風"]
         else:
-            texts = ["Lake of Heavenly Wind", u"澤 天 風"]
+            texts = ["Pleasure in Strong Penetration", u"兌 乾 巽"]
         for text in texts:
             spaced = text[0]
             for ch in text[1:]:
@@ -279,6 +321,7 @@ class GameScreen(GameChild):
         self.pulp.health += 1.0 / 6
         if self.pulp.health > .9999:
             self.pulp.health = .9999
+        self.parent.book.hide_indicators()
 
     def freeze(self):
         self.frozen = True
@@ -300,10 +343,15 @@ class GameScreen(GameChild):
         self.paddles.explode_mines()
         self.paddles.reset_position()
         self.oracle.animals.hide()
+        for hexagram in self.parent.book:
+            if not hexagram.is_hidden():
+                hexagram.halt()
 
     def respond(self, event):
         if self.active and self.ending and self.game_over_elapsed > 3000 and \
                self.delegate.compare(event, "any"):
+            self.parent.book.hide_explanations()
+            self.parent.book.hide_indicators()
             self.deactivate()
             self.parent.title.activate(int(round(self.pulp.score)))
 
@@ -312,8 +360,11 @@ class GameScreen(GameChild):
             self.display_surface.blit(self.background, (0, 0))
             if self.introducing:
                 font = Font(self.get_resource("display", "font"), 10)
-                text = font.render("W  A  V  E     " + str(self.wave), True,
-                                   (31, 31, 31))
+                text = "WAVE " + str(self.wave)
+                spaced = text[0]
+                for ch in text[1:]:
+                    spaced += "  " + ch
+                text = font.render(spaced, True, (31, 31, 31))
                 rect = text.get_rect()
                 rect.center = self.display_surface.get_rect().centerx, 260
                 self.display_surface.blit(text, rect)
@@ -430,6 +481,7 @@ class Pulp(GameChild, Surface):
                         break
                 if self.health < 0:
                     self.parent.end()
+                    break
         for phage in outgoing:
             self.parent.rails.phages.remove(phage)
         for explosion in self.explosions:
@@ -862,17 +914,22 @@ class Rails(GameChild, list):
     def set_deviation(self):
         self.deviation = choice(self.deviations)
         self.set_background()
-        print self.deviation.name
 
     def reset(self):
-        self.spawn_rate = .02
+        self.spawn_rate = .008
+        self.phage_step = .0025
         self.clear_phages()
 
     def clear_phages(self):
         self.phages = []
 
     def increase_spawn_rate(self):
-        self.spawn_rate += self.spawn_rate * .2
+        if self.spawn_rate < .065:
+            self.spawn_rate += self.spawn_rate * .3
+            self.phage_step += self.phage_step * .05
+        else:
+            self.spawn_rate += 1e-3 / self.spawn_rate
+            self.phage_step += 3e-7 / self.phage_step
 
     def set_background(self):
         end = self.parent.link.background.location.bottom
@@ -938,7 +995,7 @@ class Phage(GameChild):
         return self.body[0].location.bottomright
 
     def update(self):
-        step = .0045 * self.health
+        step = self.parent.phage_step * self.health
         self.t += step
         yr = self.yr
         for ii, segment in sorted(enumerate(self.body), key=lambda b: b[0],
@@ -946,14 +1003,15 @@ class Phage(GameChild):
             dx = self.parent.deviation.get_y(self.t - ii * step) * \
                  self.parent.stray * self.rail.get_modifier()
             segment.location.center = self.rail.x + dx, \
-                                      yr[1] - (yr[1] - yr[0]) * (self.t - step * ii)
+                                      yr[1] - (yr[1] - yr[0]) * (self.t - \
+                                                                 step * ii)
             segment.update()
 
 
-class Oracle(GameChild):
+class Oracle(Animation):
 
     def __init__(self, parent):
-        GameChild.__init__(self, parent)
+        Animation.__init__(self, parent)
         self.time_filter = self.get_game().time_filter
         self.display_surface = self.get_display_surface()
         screens = self.screens = []
@@ -972,19 +1030,32 @@ class Oracle(GameChild):
             lines.append(line)
         self.animals = Animals(self)
         self.coins = [Coin(self, ii) for ii in xrange(3)]
+        self.register(self.display_indicator)
         self.clear()
 
+    def display_indicator(self):
+        self.clear_screens()
+        self.parent.parent.book.hide_explanations()
+        response = choice(self.parent.parent.book)
+        response.show_indicator()
+        response.show_explanation()
+        response.explanation.halt()
+
+    def clear_screens(self):
+        for screen in self.screens:
+            screen.fill(screen.get_at((0, 0)))
+
     def clear(self):
         self.hexagram = []
         self.flips = 0
         self.flip_elapsed = 0
         self.wait_elapsed = 0
         self.waiting = False
-        for screen in self.screens:
-            screen.fill(screen.get_at((0, 0)))
+        self.clear_screens()
         for coin in self.coins:
             coin.hide()
         self.animals.hide()
+        self.halt()
 
     def update(self):
         if not self.parent.is_frozen() and not self.waiting:
@@ -994,6 +1065,13 @@ class Oracle(GameChild):
                     coin.set_frameset(0)
             if len(self.hexagram) == 6:
                 self.clear()
+                self.parent.parent.book.hide_indicators()
+                for hexagram in self.parent.parent.book:
+                    explanation = hexagram.explanation
+                    if not explanation.is_hidden():
+                        frameset = explanation.get_current_frameset()
+                        frameset.current_index = frameset.length() - 1
+                        hexagram.explanation.play()
                 self.parent.increase_wave()
                 self.flip_elapsed = 0
             else:
@@ -1007,6 +1085,9 @@ class Oracle(GameChild):
                         self.hexagram.append(Result(self.coins))
                         if len(self.hexagram) == 3:
                             self.animals.send(self.hexagram)
+                        elif len(self.hexagram) == 6:
+                            self.play(self.display_indicator, delay=1000,
+                                      play_once=True)
                         self.flips = 0
                         self.waiting = True
         elif self.waiting:
@@ -1015,10 +1096,11 @@ class Oracle(GameChild):
                 self.waiting = False
                 self.wait_elapsed = 0
         ow, oh = 32, 16
-        for ii, result in enumerate(self.hexagram):
-            screen = self.screens[ii / 3]
-            screen.blit(self.lines[result.get_line_index()],
-                        (6, 5 + (ii % 3) * 16))
+        if self.parent.parent.book.are_indicators_hidden():
+            for ii, result in enumerate(self.hexagram):
+                screen = self.screens[ii / 3]
+                screen.blit(self.lines[result.get_line_index()],
+                            (6, 5 + (ii % 3) * 16))
         for ii, screen in enumerate(self.screens):
             rect = screen.get_rect()
             if ii == 0:
@@ -1028,6 +1110,7 @@ class Oracle(GameChild):
             self.display_surface.blit(screen, rect)
         for coin in self.coins:
             coin.update()
+        Animation.update(self)
 
 
 class Animals(GameChild, list):
@@ -1062,7 +1145,6 @@ class Animals(GameChild, list):
         self.hide()
 
     def hide(self):
-        print "hide"
         self.in_motion = None
         for animal in self:
             animal.hide()
@@ -1088,7 +1170,6 @@ class Animals(GameChild, list):
                     location.centerx += paddles.paddle_length + paddles.margin
             if self.in_motion.location.colliderect(paddles.paddles.location):
                 paddles.arrange_graticules(self.index(self.in_motion) + 1)
-                print "collide"
                 self.hide()
             else:
                 self.in_motion.move(dy=4)
index 4878d15..74e8d59 100644 (file)
@@ -1,70 +1,81 @@
+111111
 乾 - STRONG
 HEAVEN ABOVE / HEAVEN BELOW
 VAST IS THE GREAT AND ORIGINATING POWER
 ALL THINGS OWE TO IT THEIR BEGINNING
-THE CLOUDS MOVE AND THE RAIN IS DISTRIBUTED
-THE CONDITIONS OF GREAT HARMONY ARE PRESERVED IN UNION
+CLOUDS MOVE AND THE RAIN IS DISTRIBUTED
+CONDITIONS OF GREAT HARMONY ARE PRESERVED IN UNION
 EVERYTHING OBTAINS ITS CORRECT NATURE
 AS APPOINTED BY THE MIND OF HEAVEN
 
+000000
 坤 - THE EARTH
 EARTH ABOVE / EARTH BELOW
 COMPLETE IS THE GREAT AND ORIGINATING CAPACITY
 ALL THINGS OWE TO IT THEIR BIRTH
-THE VARIOUS THINGS AND CREATURES
-OBTAIN BY IT THEIR FULL DEVELOPMENT
+AND OBTAIN BY IT THEIR FULL DEVELOPMENT
 FOLLOW TO FIND YOUR PROPER LORD
 LIKE A MILD AND DOCILE MARE
 
+100010
 震 - SHAKE
 WATER ABOVE / THUNDER BELOW
-A PLANT STRUGGLES WITH DIFFICULTY OUT OF THE EARTH
+A PLANT STRUGGLES OUT OF THE EARTH
 RISING GRADUALLY ABOVE THE SURFACE
 A STATE EMERGES FROM A CONDITION OF DISORDER
 CONSEQUENT ON A GREAT REVOLUTION
 LET THERE BE PRUDENCE AND CAUTION
 WITH UNSWERVING ADHERENCE TO THE RIGHT
 
+010001
 蒙 - COVER
 MOUNTAIN ABOVE / HEAVEN BELOW
-PLANTS ARE STRUGGLING FROM BENEATH THE SURFACE.
-THE METHOD OF DEALING WITH THE YOUNG AND IGNORANT IS TO NOURISH THE CORRECT.
-THIS ACCOMPLISHES THE SERVICE OF THE SAGE.
+PLANTS ARE STRUGGLING FROM BENEATH THE SURFACE
+THE METHOD OF DEALING WITH THE YOUNG AND IGNORANT
+IS TO NOURISH THE CORRECT
+THIS ACCOMPLISHES THE SERVICE OF THE SAGE
 
-需 - NECESSITY
+111010
+需 - WAITING
 WATER ABOVE / HEAVEN BELOW
-PERIL IS IN FRONT.
-IT IS RIGHT TO NOT BE STRAIGHTENED OR REDUCED TO EXTREMITY.
-IT WILL BE ADVANTAGEOUS TO CROSS THE GREAT STREAM.
-GOING FORWARD WILL BE FOLLOWED BY MERITORIOUS ACHIEVEMENT.
+PERIL IS IN FRONT
+AVOID BEING STRAIGHTENED OR REDUCED TO EXTREMITY
+IT WILL BE ADVANTAGEOUS TO CROSS THE GREAT STREAM
+PROGRESS WILL BE FOLLOWED BY ACHIEVEMENT
 
+010111
 訟 - LITIGATION
 HEAVEN ABOVE / WATER BELOW
-THOUGH THERE IS SINCERITY IN ONE'S CONTENTION,
-ONE WILL YET MEET WITH OPPOSITION AND OBSTRUCTION.
-CONTENTION IS NOT A THING TO BE CARRIED ON TO EXTREMITY.
-ONE ATTEMPTING TO GO THROUGH THE GREAT STREAM WOULD END UP IN AN ABYSS.
-IF ONE CHERISHES AN APPREHENSIVE CAUTION, THERE WILL BE GOOD FORTUNE.
+THOUGH THERE IS SINCERITY IN ONE'S CONTENTION
+ONE WILL MEET WITH OPPOSITION AND OBSTRUCTION
+CONTENTION IS NOT TO BE CARRIED TO EXTREMITY
+IF ONE CHERISHES AN APPREHENSIVE CAUTION
+ONE WILL AVOID FALLING INTO THE ABYSS
 
+010000
 師 - MODEL
 EARTH ABOVE / WATER BELOW
-THE MULTITUDE OF THE HOST.
-WHEN A MOVER IS ABLE TO USE THE MULTITUDE WITH MORAL CORRECTNESS,
-ONE MAY ATTAIN ROYAL INFLUENCE.
-ACTION GIVES RISE TO PERILS.
-HOWEVER, IT IS IN ACCORDANCE WITH THE BEST SENTIMENTS OF HUMANKIND.
-ONE MAY BY SUCH ACTION DISTRESS THE MULTITUDE,
-BUT THEY WILL CONTINUE TO FOLLOW.
+WHEN A MOVER USES THE MULTITUDE WITH MORALITY
+HE OR SHE MAY ATTAIN INFLUENCIAL CONTROL
+ACTION GIVES RISE TO PERILS
+IT IS, HOWEVER, IN ACCORDANCE
+WITH THE BEST SENTIMENTS OF HUMANKIND
+ONE MAY BY SUCH ACTION DISTRESS THE MULTITUDE
+BUT ITS MEMBERS WILL CONTINUE TO FOLLOW
 
+000010
 比 - ASSOCIATION
 WATER ABOVE / EARTH BELOW
-WE SEE IN ASSOCIATION INFERIORS DOCILELY FOLLOWING THEIR SUPERIOR.
-LET THE PRINCIPAL PARTY REEXAMINE ONESELF BY DIVINATION,
-WHETHER HIS VIRTUE BE GREAT, UNINTERMITTING, AND FIRM.
+INFERIORS DOCILELY FOLLOW THEIR SUPERIOR
+THE HARMONY OF UNION
+IS SECURED BY THE SOVEREIGN AUTHORITY OF ONE
+LET THE MASTER BE REEXAMINED BY DIVINATION
+WHETHER HIS OR HER VIRTUE BE UNINTERMITTING
 
+111011
 小畜 - SMALL RESTRAINT
 WIND ABOVE / HEAVEN BELOW
-YOUR WILL WILL HAVE FREE COURSE.
-WE SEE DENSE CLOUDS, BUT NO RAIN COMING FROM OUR BORDERS IN THE WEST.
-SMALL RESTRAINT PRESENTS STRENGTH AND FLEXIBILITY.
-BENEFICIAL INFLUENCE HAS NOT YET BEEN DISPLAYED.
+WE SEE DENSE CLOUDS BUT NO RAIN
+BENEFICIAL INFLUENCE HAS NOT YET BEEN DISPLAYED
+SMALL RESTRAINT CANNOT LONG BE SUCCESSFUL
+AGAINST THE STRENGTH OF HEAVEN
index 40a3646..03ac34d 100644 (file)
 1034
 978
 964
+554
+92
+192
+169
+85
+83
+84
+98
+82
+1815
+185
+1151
+1442
+1680