from esp_hadouken.levels.Level import *
from void.Void import *

class Circulor(Level):

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

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

from pygame import draw

from esp_hadouken.GameChild import *

class Wave(GameChild):

    def __init__(self, parent, orientation, bottom):
        GameChild.__init__(self, parent)
        self.orientation = orientation
        self.bottom = bottom
        self.edge = 0 if orientation == parent.orient_left else \
                    parent.get_width()
        self.set_base_length()
        self.update()

    def set_base_length(self):
        self.base_length = randint(*self.parent.parent.base_range)

    def get_top(self):
        return self.vertices[0][1]

    def get_bottom(self):
        return self.vertices[1][1]

    def update(self):
        self.bottom += self.parent.parent.scroll_speed
        self.set_height()
        self.set_vertices()
        self.draw()

    def get_pos(self):
        return float(self.bottom) / self.parent.get_height()

    def set_height(self):
        height_r = self.parent.parent.height_range
        self.height = self.get_pos() * -sub(*height_r) + height_r[0]

    def set_vertices(self):
        height = self.height
        edge = self.edge
        base_length = self.base_length
        bottom = self.bottom
        peak_x = height if self.orientation == self.parent.orient_left else \
                 edge - height
        base_top = edge, bottom - base_length
        base_bottom = edge, bottom
        peak = peak_x, bottom - base_length / 2
        self.vertices = base_top, base_bottom, peak

    def draw(self):
        parent = self.parent
        draw.polygon(parent, parent.parent.opaque_color, self.vertices)
from esp_hadouken import levels

from Waves import *

class Void(levels.Void.Void):

    def __init__(self, parent):
        levels.Void.Void.__init__(self, parent)
        self.read_configuration()
        self.waves = Waves(self)

    def read_configuration(self):
        config = self.get_configuration()
        prefix = "circulor-level-"
        self.height_range = config[prefix + "height-range"]
        self.base_range = config[prefix + "base-range"]
        self.scroll_speed = config[prefix + "scroll-speed"]
        self.padding = config[prefix + "void-padding"]

    def update_area(self):
        self.waves.update()
from pygame import Surface, Rect

from esp_hadouken.GameChild import *
from Wave import *

class Waves(GameChild, Surface):

    orient_left, orient_right = range(2)

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

    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.transparent_color)
        background.convert()
        self.background = background

    def generate_waves(self):
        self.waves = waves = []
        while not waves or waves[0].get_bottom() < 0:
            self.add_wave()

    def add_wave(self):
        waves = self.waves
        if not waves:
            bottom = self.get_height()
            orientation = self.orient_right
        else:
            bottom = waves[0].get_top()
            orientation = not waves[0].orientation
        waves.insert(0, Wave(self, orientation, bottom))

    def update(self):
        self.set_clip()
        self.clear()
        self.update_waves()
        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_waves(self):
        waves = self.waves
        if waves[0].get_bottom() > 0:
            self.add_wave()
        for wave in waves:
            if wave.get_top() > self.get_height():
                waves.remove(wave)
            else:
                wave.update()

    def draw(self):
        self.parent.blit(self, self.rect)
from esp_hadouken.pgfw.GameChild import GameChild
from esp_hadouken.overworld.Background import Background
from esp_hadouken.overworld.wall.Wall import Wall
from esp_hadouken.Toy import Toy
from esp_hadouken.dot.Dot import Dot

class Overworld(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.delegate = self.get_delegate()
        self.load_configuration()
        self.set_children()
        self.subscribe(self.respond)
        self.place_toy()
        self.reset()
        self.deactivate()

    def load_configuration(self):
        config = self.get_configuration("overworld")
        self.toy_position = config["toy-position"]
        self.audio_path = self.get_resource("overworld", "audio-path")
        self.dot_position = config["dot-position"]

    def set_children(self):
        self.background = Background(self)
        self.toy = Toy(self)
        self.wall = Wall(self)
        self.dot = Dot(self)

    def respond(self, event):
        compare = self.delegate.compare
        if compare(event, "reset-game"):
            self.deactivate()
            self.reset()
        elif compare(event, "main-menu-selection", option="play"):
            self.activate()

    def deactivate(self):
        self.active = False

    def activate(self):
        self.active = True
        self.start_music()

    def start_music(self):
        self.get_audio().play_bgm(self.audio_path)

    def place_toy(self):
        rect = self.toy.rect
        rect.top = self.toy_position
        rect.centerx = self.display_surface.get_rect().centerx

    def reset(self):
        self.place_dot()

    def place_dot(self):
        rect = self.dot.rect
        rect.top = self.dot_position
        rect.centerx = self.display_surface.get_rect().centerx

    def update(self):
        if self.active:
            self.background.update()
            self.toy.update()
            self.wall.update()
            self.dot.update()
216.73.216.56
216.73.216.56
216.73.216.56
 
August 12, 2013

I've been researching tartan/plaid recently for decoration in my updated version of Ball & Cup, now called Send. I want to create the atmosphere of a sports event, so I plan on drawing tartan patterns at the vertical edges of the screen as backgrounds for areas where spectator ants generate based on player performance. I figured I would make my own patterns, but after browsing tartans available in the official register, I decided to use existing ones instead.

I made a list of the tartans that had what I thought were interesting titles and chose 30 to base the game's levels on. I sequenced them, using their titles to form a loose narrative related to the concept of sending. Here are three tartans in the sequence (levels 6, 7 and 8) generated by an algorithm I inferred by looking at examples that reads a tartan specification and draws its pattern using a simple dithering technique to blend the color stripes.


Acadia


Eve


Spice Apple

It would be wasting an opportunity if I didn't animate the tartans, so I'm thinking about animations for them. One effect I want to try is making them look like water washing over the area where the ants are spectating. I've also recorded some music for the game. Here are the loops for the game over and high scores screens.

Game Over

High Scores