from esp_hadouken import levels

from Road import *

class Void(levels.Void.Void):

    def __init__(self, parent):
        levels.Void.Void.__init__(self, parent)
        self.read_configuration()
        self.road = Road(self)

    def read_configuration(self):
        config = self.get_configuration()
        prefix = "diortem-level-"
        self.padding = config[prefix + "void-padding"]
        self.segment_width_range = config[prefix + "segment-width-range"]
        self.segment_height_range = config[prefix + "segment-height-range"]
        self.shift_range = config[prefix + "shift-range"]
        self.leg_range = config[prefix + "leg-range"]
        self.scroll_speed = config[prefix + "scroll-speed"]

    def update_area(self):
        self.road.update()
from random import randint

from pygame import Surface, Color, Rect

from esp_hadouken.GameChild import *
from Segment import *

class Road(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.init_surface()
        self.set_background()
        self.set_x_range()
        self.generate_segments()

    def init_surface(self):
        parent = self.parent
        width = parent.get_width()
        padding = parent.padding
        bandit_height = parent.parent.bandit.rect.h
        height = parent.get_height() - sum(padding) - bandit_height
        rect = Rect(0, padding[0] + bandit_height, width, height)
        Surface.__init__(self, rect.size)
        self.convert()
        self.rect = rect

    def set_background(self):
        background = Surface(self.get_size())
        background.fill(self.parent.opaque_color)
        background.convert()
        self.background = background

    def set_x_range(self):
        max_seg = self.parent.segment_width_range[1]
        self.x_range = max_seg / 2, self.get_width() - max_seg / 2

    def generate_segments(self):
        self.segments = []
        self.leg = Leg(self)
        y = self.get_height()
        while y > 0:
            self.add_segment(y)
            y -= self.segments[0].rect.h

    def add_segment(self, bottom=None):
        leg = self.leg
        segments = self.segments
        if leg.is_complete():
            leg = Leg(self)
        if bottom is None:
            bottom = segments[0].rect.top
        x = segments[0].rect.centerx if segments else 0
        segments.insert(0, Segment(self, leg, bottom, x))
        leg.advance()
        self.leg = leg

    def update(self):
        self.set_clip()
        self.clear()
        self.update_segments()
        self.draw()

    def set_clip(self):
        parent = self.parent
        y = parent.get_clip().top - parent.padding[0] - parent.parent.bandit.rect.h
        Surface.set_clip(self, Rect((0, y), parent.get_clip().size))

    def clear(self):
        self.blit(self.background, (0, 0))

    def update_segments(self):
        if self.segments[0].rect.top >= -self.parent.segment_height_range[1]:
            self.add_segment()
        for segment in self.segments:
            if segment.rect.top > self.get_height():
                self.segments.remove(segment)
            else:
                segment.update()

    def draw(self):
        self.parent.blit(self, self.rect)


class Leg:

    dirs = [-1, 1]

    def __init__(self, road):
        self.road = road
        self.length = randint(*road.parent.leg_range)
        self.direction = self.dirs[randint(0, len(self.dirs) - 1)]
        self.index = 0

    def advance(self):
        self.index += 1
        self.shift = randint(*self.road.parent.shift_range) * self.direction

    def change_direction(self):
        dirs = self.dirs
        direction = self.direction
        if direction == dirs[0]:
            direction = dirs[1]
        else:
            direction = dirs[0]
        self.direction = direction

    def is_complete(self):
        return self.index >= self.length
from operator import sub
from random import randint

from pygame import Surface, Rect, Color, transform, draw

from esp_hadouken.GameChild import *

class Segment(GameChild):

    def __init__(self, parent, leg, bottom, x):
        GameChild.__init__(self, parent)
        self.init_rect(leg, bottom, x)
        self.color = parent.parent.transparent_color

    def init_rect(self, leg, bottom, x):
        parent = self.parent
        rect = Rect(0, 0, 0, randint(*parent.parent.segment_height_range))
        x_range = parent.x_range
        if x is None:
            x = randint(*x_range)
        else:
            x += leg.direction * randint(*parent.parent.shift_range)
        if x < x_range[0] or x > x_range[1]:
            leg.change_direction()
            if x < x_range[0]:
                x = x_range[0]
            else:
                x = x_range[1]
        rect.centerx = x
        rect.bottom = bottom
        self.rect = rect

    def update(self):
        self.update_width()
        self.recenter()
        self.scroll()
        self.draw()

    def update_width(self):
        parent = self.parent
        rect = self.rect
        pos = float(rect.bottom) / parent.get_height()
        centerx = rect.centerx
        width_r = parent.parent.segment_width_range
        rect.w = pos * -sub(*width_r) + width_r[0]
        rect.centerx = centerx

    def recenter(self):
        rect = self.rect
        right_bound = self.parent.get_width()
        if rect.left < 0:
            rect.left = 0
        elif rect.right > right_bound:
            rect.right = right_bound

    def scroll(self):
        self.rect.top += self.parent.parent.scroll_speed

    def draw(self):
        draw.rect(self.parent, self.color, self.rect)
from random import randint

from pygame import Surface, Color

from esp_hadouken.levels.Void import *
from Barrier import *

class Gauntlet(Void):

    step_count = 0

    def __init__(self, parent):
        Void.__init__(self, parent)
        self.read_configuration()
        self.set_area()
        self.generate_barriers()

    def read_configuration(self):
        config = self.get_configuration()
        prefix = "horse-level-"
        self.padding = config[prefix + "void-padding"]
        self.size_range = config[prefix + "size-range"]
        self.step_limit = config[prefix + "step-limit"]

    def set_area(self):
        self.set_y_range()
        y_range = self.y_range
        height = y_range[1] - y_range[0]
        area = Surface((self.parent.get_width(), height)).convert()
        self.area_bg = Surface(area.get_size()).convert()
        self.area = area

    def set_y_range(self):
        padding = self.padding
        start = self.parent.bandit.rect.h + padding[0]
        end = self.get_height() - padding[1]
        self.y_range = start, end

    def generate_barriers(self):
        self.barriers = barriers = []
        y = 0
        while y < self.area.get_height():
            sibling = None if not barriers else barriers[-1]
            barriers.append(Barrier(self, y, sibling))
            y += barriers[-1].get_height()

    def update_area(self):
        self.update_step_count()
        self.clear_area()
        self.update_barriers()
        self.draw_area()

    def update_step_count(self):
        count = self.step_count + 1
        if count > self.step_limit:
            count = 0
            self.toggle_barrier_headings()
        self.step_count = count

    def toggle_barrier_headings(self):
        for barrier in self.barriers:
            barrier.toggle_heading()

    def clear_area(self):
        self.area.blit(self.area_bg, (0, 0))

    def update_barriers(self):
        for barrier in self.barriers:
            barrier.update()

    def draw_area(self):
        self.blit(self.area, (0, self.y_range[0]))
3.239.59.31
3.239.59.31
3.239.59.31
 
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!