from os.path import join

from lib.pgfw.pgfw.Sprite import Sprite

class Background(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_from_path(join(self.get_resource("door", "path"),
                                 str(self.parent.parent.index),
                                 "background.png"), True, True)
        self.location.bottom = self.parent.parent.platforms[0].location.top
        self.reset()

    def reset(self):
        self.location.left = self.parent.foreground.location.right

    def update(self):
        self.move(-self.parent.parent.velocity[0])
        Sprite.update(self)
from os.path import join

from lib.pgfw.pgfw.Sprite import Sprite

class Foreground(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_configuration()
        index = str(self.parent.parent.index)
        self.load_from_path(self.get_resource(join(self.root, index,
                                                   "foreground.png")), True,
                            True)
        self.location.bottom = self.parent.parent.platforms[0].location.top
        self.reset()

    def reset(self):
        self.location.left = self.x

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

    def update(self):
        self.move(-self.parent.parent.velocity[0])
        Sprite.update(self)
from random import randint, random

from lib.pgfw.pgfw.GameChild import GameChild
from food_spring.level.obstacle.Missile import Missile
from food_spring.level.obstacle.Hurdle import Hurdle
from food_spring.level.obstacle.Spikes import Spikes
from food_spring.level.obstacle.Fireball import Fireball

class Obstacles(GameChild, dict):

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

    def load_configuration(self):
        config = self.get_configuration
        self.missile_chance = config("missile", "chance")
        self.missile_count = config("missile", "count")
        self.blink_rate = config("obstacle", "blink-rate")
        self.hurdle_count = config("hurdle", "count")
        self.hurdle_chance = config("hurdle", "chance")
        self.hurdle_first = config("hurdle", "first-range")
        self.hurdle_margin = config("hurdle", "margin")
        self.spikes_chance = config("spikes", "chance")
        self.fireball_chance = config("fireball", "chance")
        self.fireball_count = config("fireball", "count")

    def init_dict(self):
        missiles = [Missile(self) for _ in xrange(self.missile_count[1])]
        hurdles = [Hurdle(self) for _ in xrange(self.hurdle_count[1])]
        fireballs = [Fireball(self) for _ in xrange(self.fireball_count[1])]
        dict.__init__(self, {"missile": missiles, "spikes": [Spikes(self)],
                             "hurdle": hurdles, "fireball": fireballs})

    def reset(self):
        for obstacle in self.get_obstacles():
            obstacle.reset()

    def get_obstacles(self, exclude=[]):
        if isinstance(exclude, str):
            exclude = [exclude]
        for kind in set(("hurdle", "fireball", "spikes",
                         "missile")).difference(exclude):
            for obstacle in self[kind]:
                yield obstacle

    def update(self):
        if self.parent.is_going():
            self.spawn_missiles()
            self.spawn_hurdles()
            self.spawn_spikes()
            self.spawn_fireballs()
        for obstacle in self.get_obstacles():
            obstacle.update()

    def spawn_missiles(self):
        if all(not missile.is_flying() for missile in self["missile"]):
            if random() < self.missile_chance:
                for ii in xrange(randint(*self.missile_count)):
                    self["missile"][ii].queue_fly()

    def spawn_hurdles(self):
        if all(not hurdle.is_playing(hurdle.enter) and \
               not hurdle.is_playing(hurdle.exit) for \
               hurdle in self["hurdle"]):
            if random() < self.hurdle_chance:
                dy = randint(*self.hurdle_first)
                for ii in xrange(randint(*self.hurdle_count)):
                    self["hurdle"][ii].queue_entrance(dy)
                    dy += randint(*self.hurdle_margin)

    def spawn_spikes(self):
        if not self["spikes"][0].is_playing(self["spikes"][0].slide):
            if random() < self.spikes_chance:
                self["spikes"][0].queue_slide()

    def spawn_fireballs(self):
        if all(not fireball.is_playing(fireball.spew) for fireball in \
               self["fireball"]):
            if random() < self.fireball_chance:
                for ii in xrange(randint(*self.fireball_count)):
                    self["fireball"][ii].queue_spew()
from pygame import Surface

from lib.pgfw.pgfw.Sprite import Sprite

class Hurdle(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_configuration()
        self.set_frames()
        self.register(self.enter, self.exit)
        self.reset()

    def load_configuration(self):
        config = self.get_configuration("hurdle")
        self.delay = config["delay"]
        self.speed = config["speed"]
        self.pause = config["pause"]

    def set_frames(self):
        surface = Surface((32, 8))
        surface.fill((255, 255, 0))
        self.add_frame(surface, omit=True)
        self.add_frameset(0, name="entered")
        blank = Surface(self.location.size)
        blank.set_colorkey((0, 0, 0))
        self.add_frame(blank, omit=True)
        self.add_frameset([0, 1], self.parent.blink_rate, "queued")

    def reset(self):
        self.halt(self.enter)
        self.halt(self.exit)
        self.active = False
        self.queue_reset = False
        self.location.centerx = self.display_surface.get_rect().left
        self.set_frameset("queued")

    def queue_entrance(self, dy):
        self.location.centery = self.parent.parent.platforms[0].location.top - \
                                dy
        self.active = True
        self.play(self.enter, delay=self.delay)

    def enter(self):
        self.set_frameset("entered")
        self.move(self.speed, 0)
        if self.location.centerx >= self.display_surface.get_rect().centerx:
            self.halt(self.enter)
            self.play(self.exit, delay=self.pause)

    def exit(self):
        self.move(self.speed, 0)
        if self.location.right >= self.display_surface.get_rect().right:
            self.queue_reset = True

    def update(self):
        if self.active:
            if self.is_playing(self.enter, include_delay=True) or \
               self.is_playing(self.exit):
                if self.location.colliderect(self.parent.parent.food):
                    self.parent.parent.food.freeze()
            Sprite.update(self)
        if self.queue_reset:
            self.reset()
3.137.213.128
3.137.213.128
3.137.213.128
 
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!