from pygame import Rect

from _send.pgfw.GameChild import GameChild
from _send.field.sideline.background.Background import Background

class Sideline(GameChild, Rect):

    def __init__(self, parent, is_lower=False):
        GameChild.__init__(self, parent)
        self.is_lower = is_lower
        self.proportion = self.get_configuration("sideline", "proportion")
        self.init_rect()
        self.background = Background(self)

    def init_rect(self):
        display_surface = self.get_display_surface()
        width = display_surface.get_width()
        height = display_surface.get_height() * self.proportion
        Rect.__init__(self, (0, 0, width, height))
        if self.is_lower:
            self.bottom = display_surface.get_rect().bottom

    def refresh(self):
        self.background.refresh()

    def update(self):
        self.background.update()
from pygame import Surface

from _send.pgfw.GameChild import GameChild

class Filter(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        Surface.__init__(self, self.parent.parent.size)

    def paint(self):
        pass
from pygame.transform import flip
from pygame import Surface

from _send.pgfw.Sprite import Sprite

class Cloth(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.scroll_speed = self.get_configuration("cloth", "scroll-speed")

    def refresh(self):
        self.set_references()
        self.set_frames()

    def set_references(self):
        self.fields = self.parent.parent.parent
        self.tartans = self.get_game().tartans

    def set_frames(self):
        name = self.fields.get_current_field().name
        self.clear_frames()
        self.remove_locations()
        sideline = self.parent.parent
        tile = self.tartans[name]
        if tile.get_width() == 0:
            tile.generate(store=True)
        if sideline.is_lower:
            tile = flip(tile, False, True)
        frame_h = tile.get_height()
        while frame_h < sideline.h:
            frame_h += tile.get_height()
        frame = Surface((sideline.w, frame_h))
        for x in xrange(0, frame.get_width(), tile.get_width()):
            for y in xrange(0, frame.get_height(), tile.get_height()):
                frame.blit(tile, (x, y))
        self.add_frame(frame)
        if sideline.is_lower:
            self.location.bottomleft = sideline.bottomleft
            self.add_location(offset=(0, self.location.h))
        else:
            self.location.topleft = sideline.topleft
            self.add_location(offset=(0, -self.location.h))

    def update(self):
        sideline = self.parent.parent
        is_lower = sideline.is_lower
        self.move(dy=(self.scroll_speed, -self.scroll_speed)[is_lower])
        if is_lower and self.location.bottom < sideline.top:
            self.move(dy=self.location.h)
        elif not is_lower and self.location.top > sideline.bottom:
            self.move(dy=-self.location.h)
        ds = self.display_surface
        ds.set_clip(sideline)
        Sprite.update(self)
        ds.set_clip(None)
from _send.pgfw.GameChild import GameChild
from _send.field.sideline.background.Filter import Filter
from _send.field.sideline.background.Cloth import Cloth

class Background(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.filter = Filter(self)
        self.cloth = Cloth(self)

    def refresh(self):
        self.cloth.refresh()

    def update(self):
        self.cloth.update()
from random import random

from pygame.mixer import Sound

from _send.pgfw.GameChild import GameChild

class Static(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.load_configuration()

    def load_configuration(self):
        self.frequency = self.get_configuration("static", "frequency")
        self.sound = Sound(self.get_resource("static", "path"))
        self.sound.set_volume(self.get_configuration("static", "volume"))

    def update(self):
        if random() < self.frequency:
            self.play()

    def play(self):
        channel = self.sound.play()
        if channel:
            self.parent.set_random_panning(channel)
from random import random, choice

from pygame import Surface, Color
from pygame.font import Font
from pygame.mixer import Sound

from _send.pgfw.GameChild import GameChild
from _send.title.Static import Static
from _send.title.Track import Track
from _send.tartan.Tartan import Tartan, Stripe
from _send.Arrow import Arrow

class Title(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.compare = self.get_delegate().compare
        self.fields = self.get_game().fields
        self.load_tracks()
        self.static = Static(self)
        self.set_backgrounds()
        self.set_current_background()
        self.deactivate()
        self.subscribe(self.respond)
        self.arrow = Arrow(self, (150, 39), (120, 280), 100, 12, 4, Arrow.RIGHT)
        self.arrow.location.center = self.display_surface.get_rect().center

    def load_tracks(self):
        get_resource = self.get_resource
        config = self.get_configuration("title")
        self.lead_track = Track(self, get_resource("title", "lead-audio"),
                                config["lead-volume"])
        self.beat_track = Track(self, get_resource("title", "beat-audio"),
                                config["beat-volume"])
        self.audio = Sound(get_resource("title", "audio"))

    def set_backgrounds(self):
        backgrounds = self.backgrounds = []
        for palette in self.get_configuration("title", "palette").split("/"):
            tartan = Tartan(self)
            tartan.sett = []
            tartan.palette = {}
            tartan.thread_size = 4
            tartan.sett_width = 0
            tartan.asymmetric = False
            for ii, entry in enumerate(palette.split(",")):
                color, ratio = entry.split()
                width = int(round(float(ratio) * 2))
                tartan.sett_width += width
                tartan.sett.append(Stripe(ii, width))
                tartan.palette[ii] = Color("#%sFF" % color)
            tartan.generate(1, True)
            ox, oy = self.get_configuration("title", "background-offset")
            backgrounds.append(Surface(self.display_surface.get_size()))
            for x in xrange(ox, backgrounds[-1].get_width(),
                            tartan.get_width()):
                for y in xrange(oy, backgrounds[-1].get_height(),
                                tartan.get_height()):
                    backgrounds[-1].blit(tartan, (x, y))

    def set_current_background(self):
        self.current_background = choice(self.backgrounds)

    def deactivate(self):
        self.audio.stop()
        self.active = False

    def respond(self, event):
        compare = self.compare
        if self.active and compare(event, "advance"):
            self.deactivate()
            self.fields.load()
        elif compare(event, "reset-game"):
            self.deactivate()
            self.set_current_background()
            self.activate()

    def activate(self):
        # self.lead_track.play()
        # self.beat_track.play()
        self.active = True
        self.audio.play(-1)

    def update(self):
        if self.active:
            self.lead_track.update()
            self.beat_track.update()
            # self.static.update()
            if random() < .35:
                self.set_current_background()
            self.display_surface.blit(self.current_background, (0, 0))
            self.arrow.update()

    def set_random_panning(self, channel):
        offset = (random() - .5) * 2
        if offset < 0:
            volume = 1, 1 + offset
        else:
            volume = 1 - offset, 1
        channel.set_volume(*volume)
44.201.64.238
44.201.64.238
44.201.64.238
 
June 29, 2013

A few weeks ago, for Fishing Jam, I made a fishing simulation from what was originally designed to be a time attack arcade game. In the program, Dark Stew, the player controls Aphids, an anthropod who fishes for aquatic creatures living in nine pools of black water.



Fishing means waiting by the pool with the line in. The longer you wait before pulling the line out, the more likely a creature will appear. Aside from walking, it's the only interaction in the game. The creatures are drawings of things you maybe could find underwater in a dream.

The background music is a mix of clips from licensed to share songs on the Free Music Archive. Particularly, Seed64 is an album I used a lot of songs from. The full list of music credits is in the game's README file.

I'm still planning to use the original design in a future version. There would be a reaction-based mini game for catching fish, and the goal would be to catch as many fish as possible within the time limit. I also want to add details and obstacles to the background, which is now a little boring, being a plain, tiled, white floor.

If you want to look at all the drawings or hear the music in the context of the program, there are Windows and source versions available. The source should work on any system with Python and Pygame. If it doesn't, bug reports are much appreciated. Comments are also welcome :)

Dark Stew: Windows, Pygame Source

I wrote in my last post that I would be working on an old prototype about searching a cloud for organisms for Fishing Jam. I decided to wait a while before developing that game, tentatively titled Xenographic Barrier. Its main interactive element is a first-person scope/flashlight, so I'd like to make a Wii version of it.

I'm about to start working on a complete version of Ball & Cup. If I make anything interesting for it, I'll post something. There are a lot of other things I want to write about, like game analyses, my new GP2X and arcades in Korea, and there's still music to release. Lots of fun stuff coming!