from random import choice
from lib.pgfw.pgfw.Sprite import Sprite

class Gun(Sprite):

    def __init__(self, parent, path):
        Sprite.__init__(self, parent)
        self.load_from_path(path, True)
        self.set_framerate(self.get_configuration("gun", "framerate"))
        self.reset()

    def reset(self):
        self.hide()
        self.unfollow()

    def hide(self):
        self.visible = False

    def unfollow(self):
        self.following = False

    def show(self):
        self.visible = True

    def follow(self, food):
        self.food = food
        self.following = True

    def update(self):
        if self.visible:
            if self.following:
                self.location.centerx = self.food.location.centerx
            Sprite.update(self)
from os import listdir
from os.path import join

from pygame import Surface

from lib.pgfw.pgfw.GameChild import GameChild
from food_spring.gun.Gun import Gun

class GunLibrary(GameChild, list):

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

    def load_configuration(self):
        config = self.get_configuration("gun")
        self.root = config["path"]

    def set_guns(self):
        for ii in xrange(4):
            self.append(Guns(self, self.get_resource(join(self.root, str(ii)))))


class Guns(GameChild, list):

    def __init__(self, parent, root):
        GameChild.__init__(self, parent)
        for path in sorted(listdir(root)):
            self.append(Gun(self, join(root, path)))
        self.reset()

    def reset(self):
        for gun in self:
            gun.reset()
            gun.unfollow()

    def hide(self, exclude=None):
        for gun in self:
            gun.hide()
        if exclude is not None:
            self[exclude].show()

    def update(self):
        for gun in self:
            gun.update()
from pygame import Surface

from lib.pgfw.pgfw.Animation import Animation
from food_spring.introduction.Epithet import Epithet

class Introduction(Animation):

    def __init__(self, parent):
        Animation.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.audio = self.get_audio()
        self.delegate = self.get_delegate()
        self.audio_path = self.get_resource("introduction", "audio")
        self.set_background()
        self.epithet = Epithet(self)
        self.spanky = parent.spanky
        self.reset()
        self.deactivate()
        self.subscribe(self.respond)

    def set_background(self):
        surface = Surface(self.display_surface.get_size())
        surface.fill((0, 0, 0))
        self.background = surface

    def respond(self, event):
        if self.active:
            if self.delegate.compare(event, "any"):
                self.deactivate()
                self.parent.title.queue_activation()

    def reset(self):
        self.display_surface.blit(self.background, (0, 0))

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

    def activate(self):
        self.active = True
        self.audio.play_bgm(self.audio_path)
        self.spanky.location.midbottom = \
                                       self.display_surface.get_rect().midbottom

    def update(self):
        if self.active:
            self.clear()
            Animation.update(self)
            self.parent.gaia.swapper.update()
            self.epithet.update()
            self.spanky.update()

    def clear(self):
        for rect in (self.parent.gaia.swapper.rect, self.spanky.location):
            self.display_surface.blit(self.background, rect, rect)
        self.epithet.clear()
from random import randint

from pygame import Rect, Surface, Color
from pygame.font import Font

from lib.pgfw.pgfw.GameChild import GameChild
from lib.pgfw.pgfw.Sprite import Sprite

class Epithet(GameChild, Rect):

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

    def load_configuration(self):
        config = self.get_configuration("epithet")
        self.font_path = self.get_resource("display", "font-path")
        self.width = config["width"]
        self.margin = config["margin"]
        self.text = config["text"]
        self.color = config["color"]
        self.i_color = config["i-color"]
        self.t_color = config["t-color"]
        self.font_size = config["font-size"]
        self.it_size = config["it-size"]

    def init_rect(self):
        Rect.__init__(self, 0, 0, self.width, 0)
        self.midtop = self.get_display_surface().get_rect().centerx, self.margin

    def set_glyphs(self):
        glyphs = []
        for ii, character in enumerate(self.text):
            if character != " ":
                color = None
                if character in "IT":
                    size = self.it_size
                    italic = True
                    bold = True
                    if character == "I":
                        color = self.i_color
                    elif character == "T":
                        color = self.t_color
                else:
                    size = self.font_size
                    italic = False
                    bold = False
                glyphs.append(Glyph(self, character, color, size, bold, italic,
                                    ii))
        self.glyphs = glyphs

    def update(self):
        for glyph in self.glyphs:
            glyph.update()

    def clear(self):
        parent = self.parent
        for glyph in self.glyphs:
            for location in glyph.locations:
                parent.display_surface.blit(parent.background, location,
                                            location)


class Glyph(Sprite):

    def __init__(self, parent, character, color, size, bold, italic, ii):
        Sprite.__init__(self, parent, randint(40, 120))
        self.set_frames(character, size, color, bold, italic)
        self.place(ii)
        self.add_location(offset=(-5, 8))

    def set_frames(self, character, size, color, bold, italic):
        color = Color(0, 0, 0)
        background_color = Color(0, 0, 0)
        count = 30
        font = Font(self.parent.font_path, size)
        font.set_italic(italic)
        font.set_bold(bold)
        for ii in xrange(count):
            hue = randint(0, 255)
            color.hsla = hue, 100, 50, randint(30, 100)
            background_hue = hue + 128
            if background_hue > 255:
                background_hue -= 255
            background_color.hsla = background_hue, 100, 50, randint(30, 100)
            frame = font.render(character, True, color, background_color)
            if not ii % (count / 6):
                surface = Surface(frame.get_size())
                surface.set_colorkey((0, 0, 0))
                midpoint = frame.get_width() / 2
                surface.blit(frame, (midpoint, 0))
                surface.blit(frame, (-midpoint, 0))
                frame = surface
            self.add_frame(frame)

    def place(self, ii):
        parent = self.parent
        offset = int(parent.w * float(ii) / (len(parent.text) - 1))
        self.location.center = parent.left + offset, parent.top
216.73.216.161
216.73.216.161
216.73.216.161
 
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!