from esp_hadouken.pgfw.Sprite import Sprite

class Toy(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_from_path(self.get_resource("toy", "path"), True)
        self.set_framerate(self.get_configuration("toy", "framerate"))
from os.path import exists, join, basename
from sys import argv

from pygame import mixer

import Game

class GameChild:

    def __init__(self, parent=None):
        self.parent = parent

    def get_game(self):
        current = self
        while not isinstance(current, Game.Game):
            current = current.parent
        return current

    def get_configuration(self):
        return self.get_game().get_configuration()

    def get_input(self):
        return self.get_game().get_input()

    def get_screen(self):
        return self.get_game().display.get_screen()

    def get_timer(self):
        return self.get_game().timer

    def get_audio(self):
        return self.get_game().audio

    def get_delegate(self):
        return self.get_game().delegate

    def get_resource(self, key):
        config = self.get_configuration()
        path = config[key]
        installed_path = join(config["resources-install-path"], path)
        if exists(installed_path) and self.use_installed_resource():
            return installed_path
        elif exists(path):
            return path

    def use_installed_resource(self):
        if "-l" in argv:
            return False
        return True

    def get_pause_screen(self):
        return self.get_game().pause_screen

    def get_high_scores(self):
        return self.get_game().high_scores

    def get_glyph_palette(self):
        return self.get_game().glyph_palette

    def subscribe_to(self, kind, callback):
        self.get_game().delegate.add_subscriber(kind, callback)

    def unsubscribe_from(self, kind, callback):
        self.get_game().delegate.remove_subscriber(kind, callback)

    def is_debug_mode(self):
        return "-d" in argv
from time import time

from pygame.locals import *

from esp_hadouken.pgfw.GameChild import *
from esp_hadouken.pgfw.Input import *

class Timer(GameChild, dict):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.max_time = self.get_configuration("timer", "max-time")
        self.subscribe_to_events()
        self.reset()

    def subscribe_to_events(self):
        self.subscribe(self.respond_to_event)

    def respond_to_event(self, event):
        if event.command == "reset":
            self.reset()

    def reset(self):
        self.clear_current_interval()
        self.concealed = False
        dict.__init__(self, {"octo": 0, "horse": 0, "diortem": 0, "circulor": 0,
                             "tooth": 0})

    def clear_current_interval(self):
        self.start_time = None
        self.pause_length = 0
        self.pause_start_time = None
        self.paused = False
        self.current_level = None

    def start(self, level):
        self.start_time = time()
        self.current_level = level

    def pause(self):
        if self.start_time:
            paused = self.paused
            if self.paused:
                self.pause_length += time() - self.pause_start_time
            else:
                self.pause_start_time = time()
            self.paused = not paused

    def stop(self):
        start = self.start_time
        level = self.current_level
        if None not in (start, level):
            interval = time() - start - self.pause_length
            self[level] += interval
        self.clear_current_interval()

    def total(self):
        if self.concealed:
            return self.max_time
        return sum(self.values())

    def conceal(self):
        self.concealed = True
import pygame
from pygame.locals import *

from GameChild import *

class EventDelegate(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribers = dict()
        self.disable()
        if self.is_debug_mode():
            print "Event ID range: %i - %i" % (NOEVENT, NUMEVENTS)

    def enable(self):
        self.enabled = True

    def disable(self):
        self.enabled = False

    def dispatch_events(self):
        if self.enabled:
            subscribers = self.subscribers
            for event in pygame.event.get():
                kind = event.type
                if kind in subscribers:
                    for subscriber in subscribers[kind]:
                        if self.is_debug_mode():
                            print "Passing %s to %s" % (event, subscriber)
                        subscriber(event)
        else:
            pygame.event.pump()

    def add_subscriber(self, kind, callback):
        if self.is_debug_mode():
            print "Subscribing %s to %i" % (callback, kind)
        subscribers = self.subscribers
        if kind not in subscribers:
            subscribers[kind] = list()
        subscribers[kind].append(callback)

    def remove_subscriber(self, kind, callback):
        self.subscribers[kind].remove(callback)
from pygame import image

from GameChild import *

class PauseScreen(GameChild):

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

    def load_image(self):
        self.img = image.load(self.get_resource("pause-image-path"))

    def show(self):
        self.get_screen().blit(self.img, (0, 0))
3.235.65.220
3.235.65.220
3.235.65.220
 
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!