from pygame import Surface

from dark_stew.pgfw.GameChild import GameChild
from dark_stew.water.Layer import Layer

class Water(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.load_configuration()
        self.set_background()
        self.add_layers()

    def load_configuration(self):
        config = self.get_configuration("water")
        self.opacity = config["opacity"]
        self.speed = config["speed"]
        self.color = config["color"]

    def set_background(self):
        background = Surface(self.display_surface.get_size())
        background.fill(self.color)
        self.background = background

    def add_layers(self):
        layers = []
        for ii, opacity in enumerate(self.opacity):
            layers.append(Layer(self, opacity, self.speed[ii], ii * 16))
        self.layers = layers

    def update(self):
        for layer in self.layers:
            layer.update()
        self.draw()

    def draw(self):
        self.display_surface.blit(self.background, (0, 0))
        for layer in reversed(self.layers):
            layer.draw()
from pygame import Surface
from pygame.image import load

from dark_stew.pgfw.GameChild import GameChild

class Layer(GameChild, Surface):

    def __init__(self, parent, opacity, speed, base_offset):
        GameChild.__init__(self, parent)
        self.opacity = opacity
        self.speed = speed
        self.base_offset = base_offset
        self.display_surface = self.get_display_surface()
        self.transparent_color = (255, 0, 255)
        self.offset = 0
        self.set_tile()
        self.init_surface()
        self.paint()

    def set_tile(self):
        path = self.get_resource("water", "tile-path")
        self.tile = load(path).convert_alpha()

    def init_surface(self):
        padding = self.tile.get_width()
        width, height = self.parent.parent.size
        Surface.__init__(self, (width + padding, height + padding))
        transparent_color = self.transparent_color
        self.fill(transparent_color)
        self.set_colorkey(transparent_color)
        self.set_alpha(self.opacity)
        self.padding = padding

    def paint(self):
        tile = self.tile
        for x in xrange(0, self.get_width(), tile.get_width()):
            for y in xrange(0, self.get_height(), tile.get_height()):
                self.blit(tile, (x, y))

    def update(self):
        offset = self.offset - self.speed
        padding = self.padding
        if offset < -padding:
            offset += padding
        self.offset = offset

    def draw(self):
        rect = self.parent.parent.move([int(self.offset)] * 2)
        rect.top += self.base_offset
        self.display_surface.blit(self, rect)
from math import sqrt
from os import listdir
from os.path import isdir, join
from re import match

from dark_stew.pgfw.GameChild import GameChild
from dark_stew.pool.Pool import Pool

class Pools(GameChild, list):

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

    def add_pools(self):
        width = self.parent.w
        step = int(float(width) / sqrt(self.count_pools()))
        ii = 0
        for x in xrange(step / 2, width, step):
            for y in xrange(step / 2, width, step):
                self.append(Pool(self, (x, y), ii))
                ii += 1
        self.step = step

    def count_pools(self):
        count = 0
        root = self.get_resource("pool", "water-path")
        for name in listdir(root):
            if match("^[0-9]", name):
                count += 1
        return count

    def update(self):
        for pool in self:
            pool.update()
from os.path import join

from dark_stew.pgfw.Sprite import Sprite

class Ring(Sprite):

    def __init__(self, parent, index):
        Sprite.__init__(self, parent)
        self.index = index
        self.display_surface = self.get_display_surface()
        self.load_from_path(self.build_path(), transparency=True, ppa=False)
        self.rect.center = parent.center

    def build_path(self):
        return join(self.get_resource("pool", "ring-path"),
                    str(self.index) + ".png")

    def draw(self):
        x, y = self.rect.topleft
        frame = self.get_current_frame()
        surface = self.display_surface
        for dx, dy in self.parent.parent.parent.get_corners():
            surface.blit(frame, (x + dx, y + dy))
from os.path import join

from pygame import Surface
from pygame.image import load

from dark_stew.pgfw.Sprite import Sprite

class Water(Sprite):

    def __init__(self, parent, index):
        Sprite.__init__(self, parent)
        self.index = index
        self.display_surface = self.get_display_surface()
        self.transparent_color = (255, 0, 255)
        self.load_configuration()
        self.load_groove()
        self.set_framerate(self.framerate)
        self.load_from_path(join(self.frames_root, str(index)),
                            transparency=True, ppa=False)
        self.rect.center = parent.center

    def load_configuration(self):
        config = self.get_configuration("pool")
        self.framerate = config["framerate"]
        self.frames_root = self.get_resource("pool", "water-path")
        self.groove_path = self.get_resource(join(config["water-path"],
                                                  config["groove-path"]))

    def load_groove(self):
        image = load(join(self.groove_path, str(self.index) + ".png"))
        surface = Surface(image.get_size())
        transparent_color = self.transparent_color
        surface.fill(transparent_color)
        surface.set_colorkey(transparent_color)
        surface.blit(image, (0, 0))
        self.groove = surface

    def draw(self):
        x, y = self.rect.topleft
        frame = self.get_current_frame()
        surface = self.display_surface
        groove = self.groove
        for dx, dy in self.parent.parent.parent.get_corners():
            surface.blit(frame, (x + dx, y + dy))
            surface.blit(groove, (x + dx, y + dy))
3.84.186.122
3.84.186.122
3.84.186.122
 
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!


↠ RSS Feed ↞