from random import randint
from operator import sub

from pygame import Surface

from esp_hadouken.GameChild import *

class Barrier(GameChild, Surface):

    dir_r, dir_l = 1, -1

    def __init__(self, parent, y, sibling=None):
        GameChild.__init__(self, parent)
        self.y = y
        self.sibling = sibling
        self.init_surface()

    def init_surface(self):
        size = self.determine_size()
        Surface.__init__(self, (size, size))
        self.fill(self.parent.transparent_color)
        self.set_rect()

    def determine_size(self):
        parent = self.parent
        size_range = parent.size_range
        pos = float(self.y) / -sub(*parent.y_range)
        return pos * -sub(*size_range) + size_range[0]

    def set_rect(self):
        rect = self.get_rect()
        rect.top = self.y
        sibling = self.sibling
        if not sibling:
            growth = self.dir_r
            rect.top = self.y
            rect.left = self.generate_initial_x()
        else:
            growth = sibling.growth
            if growth == self.dir_r:
                rect.left = sibling.rect.right
                if rect.right > self.parent.get_width():
                    growth = self.dir_l
                    rect.right = sibling.rect.left
            if growth == self.dir_l:
                rect.right = sibling.rect.left
                if rect.left < 0:
                    growth = self.dir_r
                    rect.left = sibling.rect.right
        self.growth = growth
        self.rect = rect
        self.x = rect.left
        self.set_heading()
        self.set_step()

    def generate_initial_x(self):
        parent = self.parent
        return randint(0, parent.get_width() - parent.size_range[0])

    def set_heading(self):
        if self.rect.centerx > self.parent.get_width() / 2:
            heading = self.dir_l
        else:
            heading = self.dir_r
        self.heading = heading

    def set_step(self):
        parent = self.parent
        center = parent.get_width() / 2
        rnge = abs((self.rect.centerx - center) * 2)
        self.step = float(rnge) / parent.step_limit

    def toggle_heading(self):
        heading = self.heading
        if heading == self.dir_l:
            heading = self.dir_r
        else:
            heading = self.dir_l
        self.heading = heading

    def update(self):
        self.move()
        self.draw()

    def move(self):
        self.x += self.heading * self.step
        self.rect.left = self.x
        
    def draw(self):
        self.parent.area.blit(self, self.rect)
from esp_hadouken.levels.Level import *
from Gauntlet import *

class Horse(Level):

    def __init__(self, parent):
        Level.__init__(self, parent)

    def set_void(self):
        self.void = Gauntlet(self)
from random import randint
from operator import sub

from pygame import draw

from esp_hadouken.GameChild import *

class Bubble(GameChild):

    def __init__(self, parent, y=None):
        GameChild.__init__(self, parent)
        self.y = y
        self.set_x()

    def set_x(self):
        self.x = self.parent.get_width() / 2

    def update(self):
        self.y += self.parent.scroll_speed
        self.set_radius()

    def set_radius(self):
        parent = self.parent
        radius_range = parent.radius_range
        pos = float(self.y) / -sub(*parent.y_range)
        self.radius = int(pos * -sub(*radius_range) + radius_range[0])

    def draw(self):
        parent = self.parent
        center = self.x, self.y
        draw.circle(parent.area, parent.transparent_color, center, self.radius)
from random import randint

from pygame import Color, Surface

from esp_hadouken import levels
from Bubble import *

class Void(levels.Void.Void):

    def __init__(self, parent):
        levels.Void.Void.__init__(self, parent)
        self.iterations = 0
        self.read_configuration()
        self.set_area()
        self.show()

    def read_configuration(self):
        config = self.get_configuration()
        self.switch_frequency = config["tooth-level-switch-frequency"]
        self.scroll_speed = config["tooth-level-scroll-speed"]
        self.padding = config["tooth-level-void-padding"]
        self.radius_range = config["tooth-level-radius-range"]
        self.spawn_range = config["tooth-level-spawn-range"]

    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
        self.generate_bubbles()

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

    def generate_bubbles(self):
        self.bubbles = []
        y = self.get_height()
        while y > -self.radius_range[0]:
            self.add_bubble(y)
            y -= self.next_spawn + self.radius_range[0]

    def add_bubble(self, y=None):
        if y is None:
            y = -self.radius_range[0]
        self.bubbles.insert(0, Bubble(self, y))
        self.next_spawn = randint(*self.spawn_range)

    def toggle(self):
        if self.visible:
            self.hide()
        else:
            self.show()

    def show(self):
        self.visible = True

    def hide(self):
        self.visible = False

    def update_area(self):
        self.update_bubbles()
        iterations = self.iterations + 1
        if 1.0 / iterations <= self.switch_frequency:
            self.toggle()
            iterations = 0
        if self.visible:
            self.clear_area()
            self.draw_area()
        self.iterations = iterations

    def update_bubbles(self):
        bubbles = self.bubbles
        radius_range = self.radius_range
        if bubbles[0].y - radius_range[0] > self.next_spawn:
            self.add_bubble()
        for bubble in bubbles:
            if bubble.y > self.y_range[1] + radius_range[1]:
                bubbles.remove(bubble)
            else:
                bubble.update()

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

    def draw_area(self):
        self.draw_bubbles()
        self.blit(self.area, (0, self.y_range[0]))

    def draw_bubbles(self):
        for bubble in self.bubbles:
            bubble.draw()
3.135.249.190
3.135.249.190
3.135.249.190
 
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!