from esp_hadouken.pgfw.GameChild import GameChild
from esp_hadouken.title.background.Sky import Sky
from esp_hadouken.title.background.Mask import Mask

class Background(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent) = Sky(self)
        self.mask = Mask(self)

    def update(self):
from pygame import Surface, Color, PixelArray
from pygame.image import load

from esp_hadouken.pgfw.GameChild import GameChild

class Mask(Surface, GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_screen()
        self.transparent_color = 0xFF00FF

    def init_surface(self):
        Surface.__init__(self, self.display_surface.get_size())
        self.blit(load(self.vector_path).convert(), (0, 0))

    def load_configuration(self):
        get = self.get_resource
        config = self.get_configuration("title")
        self.vector_path = get("title", "mask-vector-path")
        self.vector_color = Color(config["mask-vector-colors"][2])
        self.foreground_path = get("title", "mask-foreground-path")

    def modify(self):
        pixels = PixelArray(self)
        white = 0xFFFFFF
        pixels.replace(white, self.vector_color)
        reference = PixelArray(load(self.foreground_path).convert())
        for ii, column in enumerate(reference):
            for jj, pixel in enumerate(column):
                if pixel == 0xFFFFFF:
                    pixels[ii][jj] = self.transparent_color

    def update(self):

    def draw(self):
        self.display_surface.blit(self, (0, 0))
from random import choice

from pygame import Color, PixelArray

from esp_hadouken.pgfw.GameChild import GameChild

class Blinker(GameChild):

    def __init__(self, parent, initial_freq, max_freq):
        GameChild.__init__(self, parent)
        self.frequency = initial_freq
        self.max_freq = max_freq
        self.iterations = 0

    def set_palettes(self):
        config = self.get_configuration("sprite")
        self.inner_palette = map(
            self.translate_hex_color, config["inner-palette"])
        self.outer_palette = map(
            self.translate_hex_color, config["outer-palette"])
        self.palette = (Color("black"), Color("white"))

    def translate_hex_color(self, color):
        return Color(color + "ff")

    def build_palette(self):
        return (choice(self.inner_palette), choice(self.outer_palette))

    def paint(self):
        image = self.parent.image
        pixels = PixelArray(image)
        old_palette = self.palette
        new_palette = self.build_palette()
        pixels.replace(old_palette[0], new_palette[0])
        pixels.replace(old_palette[1], new_palette[1])
        self.palette = new_palette

    def blink(self):
        iterations = self.iterations + 1
        if 1.0 / iterations <= self.frequency:
            iterations = 0
        self.iterations = iterations
from math import floor
import copy

import pygame

from esp_hadouken.sprite.Blinker import Blinker
from esp_hadouken.pgfw.GameChild import GameChild

class Sprite(GameChild):

    def __init__(self, parent, image_path, display_surface, bounds=(None, None),
                 wrap=(False, False), initial_blink_freq=0, max_blink_freq=1):
        GameChild.__init__(self, parent)
        self.image_path = image_path
        self.display_surface = display_surface
        self.bounds = bounds
        self.wrap = wrap
        self.restricted_areas = []
        self.blinker = Blinker(self, initial_blink_freq, max_blink_freq)

    def add_image(self):
        image = pygame.image.load(self.image_path).convert_alpha()
        self.rect = image.get_rect()
        self.old_rect = self.rect
        self.image = image

    def paint(self):

    def move(self, x=0, y=0):
        self.old_rect = copy.copy(self.rect)
        if isinstance(x, tuple) or isinstance(x, list):
            x, y = x[0], x[1]
        if x < 0:
            x = floor(x)
        if y < 0:
            y = floor(y)
        rect = self.rect + x, + y)
        self.rect = self.accommodate_wrapping(rect)

    def place(self, x=None, y=None):
        rect = self.rect
        if type(x) is tuple or type(x) is list:
            x, y = x[0], x[1]
        if x is None:
            x = rect.left
        if y is None:
            y =
        self.rect.topleft = x, y

    def accommodate_wrapping(self, rect):
        horizontal, vertical = self.wrap
        scope = self.display_surface.get_rect()
        if vertical:
            if < -rect.h:
       += scope.h
            elif > scope.h:
       -= scope.h
        if horizontal:
            if rect.left < 0:
                rect.left += scope.w - rect.w - 1
            elif rect.right > scope.w:
                rect.right -= scope.w - rect.w - 1
        return rect

    def add_restricted_areas(self, rects):
        if type(rects) is not list:
            rects = [rects]
        self.restricted_areas += rects

    def flip(self):
        self.image = pygame.transform.flip(self.image, True, False)

    def resize(self, size):
        self.image = pygame.transform.scale(self.image, size)

    def show(self):
        self.visible = True

    def hide(self):
        self.visible = False

    def set_blink_frequency(self, frequency):
        self.blinker.frequency = frequency

    def update(self):
        if self.visible:

    def draw(self):
        self.display_surface.blit(self.image, self.rect)

    def erase(self):
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 ↞