from os import listdir
from os.path import join

from pygame.mixer import Channel, Sound, music, find_channel

from GameChild import *
from Input import *

class Audio(GameChild):

    current_channel = None
    paused = False
    muted = False

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.delegate = self.get_delegate()
        self.load_fx()
        self.subscribe(self.respond)

    def load_fx(self):
        fx = {}
        if self.get_configuration().has_option("audio", "sfx-path"):
            root = self.get_resource("audio", "sfx-path")
            if root:
                for name in listdir(root):
                    fx[name.split(".")[0]] = Sound(join(root, name))
        self.fx = fx

    def respond(self, event):
        if self.delegate.compare(event, "mute"):
            self.mute()

    def mute(self):
        self.muted = True
        self.set_volume()

    def unmute(self):
        self.muted = False
        self.set_volume()

    def set_volume(self):
        volume = int(not self.muted)
        music.set_volume(volume)
        if self.current_channel:
            self.current_channel.set_volume(volume)

    def play_bgm(self, path, stream=False):
        self.stop_current_channel()
        if stream:
            music.load(path)
            music.play(-1)
        else:
            self.current_channel = Sound(path).play(-1)
        self.set_volume()

    def stop_current_channel(self):
        music.stop()
        if self.current_channel:
            self.current_channel.stop()
        self.current_channel = None
        self.paused = False

    def play_fx(self, name, panning=.5):
        if not self.muted:
            channel = find_channel(True)
            if panning != .5:
                offset = 1 - abs(panning - .5) * 2
                if panning < .5:
                    channel.set_volume(1, offset)
                else:
                    channel.set_volume(offset, 1)
            channel.play(self.fx[name])

    def pause(self):
        channel = self.current_channel
        paused = self.paused
        if paused:
            music.unpause()
            if channel:
                channel.unpause()
        else:
            music.pause()
            if channel:
                channel.pause()
        self.paused = not paused

    def is_bgm_playing(self):
        current = self.current_channel
        if current and current.get_sound():
            return True
        return music.get_busy()
from lib.pgfw.pgfw.Configuration import TypeDeclarations

class Types(TypeDeclarations):

    additional_defaults = {

        "gaia": {"path": "path",

                 "int": "offset"},

        "introduction": {"int": ["segments", "transition"]},

        "epithet": {"int": ["width", "margin", "font-size", "it-size",
                            "outline-flash"],

                    "float": "scramble",

                    "int-list": ["color", "i-color", "t-color"]},

        "spanky": {"path": "path",

                   "int-list": ["jump-order", "jump-framerate", "wag-order",
                                "wag-framerate", "walk-order",
                                "walk-framerate"]},

        "title": {"path": "background"},

        "home": {"path": ["static-environment-path", "audio"],

                 "int": ["food-inactive-x", "food-inactive-y", "food-active-y",
                         "food-margin", "tv-edge"],

                 "float": "food-step"},

        "collection": {"int-list": ["coordinates", "size"]},

        "view": {"int": ["hue-shift", "alpha-step"],

                 "path": "path",

                 "int-list": "coordinates"},

        "level": {"int": ["stall", "fall-pause", "entrance-offset"],

                  "path": "audio",

                  "int-list": "background-color",

                  "float": ["gravity", "entrance-speed"],

                  "float-list": "velocity"},

        "door": {"int": "x",

                 "path": "path"},

        "exit-arrow": {"int": ["width", "height", "overlap", "arrow-count",
                               "frame-count", "interval", "saturation",
                               "offset", "fade-in", "fade-out", "alpha"],

                       "int-list": "hue"},

        "land": {"int": ["horizon", "gradient", "x-step", "height"],

                 "float": ["spacing-factor", "velocity-ratio",
                           "altitude-ratio", "fade-speed"]},

        "planet": {"path": "path",

                   "int": ["interval", "shifts", "offset"]},

        "moon": {"path": "path",

                 "int": "margin",

                 "float": "tint-level",

                 "int-list": ["count", "interval"]},

        "stars": {"int-list": ["count", "size", "saturation"]},

        "gun": {"path": "path",

                "int": "framerate"},

        "drop": {"float": "spawn-decrease",

                 "int": ["consecutive", "speed", "first-spawn", "blob-length"]},

        "food": {"path": ["path", "mouth-bg-path", "upper-jaw-path",
                          "lower-jaw-path"],

                 "int": ["offset", "crouch", "mouth-bg-alpha", "mouth-gap",
                         "blink-rate", "freeze-length"],

                 "int-list": ["angle-range", "mouth-offset", "mouth-size",
                              "mouth-bg-shrink", "drop-velocity"],

                 "float": ["dx", "dx-boost"]},

        "platform": {"int": ["height", "first-gap", "buffer", "thickness"],

                     "int-list": ["gap", "width"]},

        "obstacle": {"int": "blink-rate"},

        "missile": {"int": ["margin", "delay", "angle"],

                    "int-list": "count",

                    "float": ["chance", "peak", "speed"]},

        "hurdle": {"int-list": ["count", "first-range", "margin"],

                   "int": ["delay", "pause"],

                   "float": ["chance", "speed"]},

        "spikes": {"int": "delay",

                   "float": ["speed", "chance"]},

        "fireball": {"int": ["delay", "peak"],

                     "int-list": "count",

                     "float": ["chance", "speed"]},

        "window": {"path": "path",

                   "int": ["alpha", "remain-length", "margin"],

                   "float": "fade-step"},

        "siphon": {"int-list": "root-colors"},
        
        }
54.156.67.164
54.156.67.164
54.156.67.164
 
July 19, 2017


f1. BOSS

Games are corrupt dissolutions of nature modeled on prison, ordering a census from the shadows of a vile casino, splintered into shattered glass, pushing symbols, rusted, stale, charred, ultraviolet harbingers of consumption and violence, badges without merit that host a disease of destruction and decay.

You are trapped. You are so trapped your only recourse of action is to imagine an escape route and deny your existence so fully that your dream world becomes the only reality you know. You are fleeing deeper and deeper into a chasm of self-delusion.

While you're dragging your listless, distending corpus from one cell to another, amassing rewards, upgrades, bonuses, achievements, prizes, add-ons and status boosts in rapid succession, stop to think about what's inside the boxes because each one contains a vacuous, soul-sucking nightmare.

Playing can be an awful experience that spirals one into a void of harm and chaos, one so bad it creates a cycle between the greater and lesser systems, each breaking the other's rules. One may succeed by acting in a way that ruins the world.

May 19, 2013

Welcome! I will be posting here about open-source games and music I am making for free online distribution. Most recently, I made Ball & Cup for Ludum Dare 26, a game I will work on more in June. After finishing, if it's fun, I will build an arcade cabinet for it! Next week, I am joining the 7-Day Fishing Jam to develop an A-life prototype about searching a cloud of noise for organisms.

Before Ball & Cup, I was adding features like vehicle engines, new graphics and effects and detailed scoring to an updated version of E.S.P. Hadouken, currently a prototype about navigating five psychic hadoukens to save your Game Boy. The new version will be similar with a clearer story and more ways to judge your performance. I plan on finishing it after making a public version of Ball & Cup.

I will also upload some digital albums soon. One, Man's Womb, is a solo collection of chiptunes from Emoticon Vs. Rainbow, an online racing/rhythm game. The other, Tor Ghul/Spin Ghul is a guitar and synth record recorded with my friends last summer. The recording and sequencing are finished for both -- I just have to make their web pages and artwork and package them for downloading.

Later, I hope to write about games in their early stages, an abstract action-RPG called Panopticon: Swarm, a massively multiplayer exploration, voting, post-catastrophic city simulation, Vomit Inspector and a mobile mini-game compilation project that includes an external digital pet raising and social networking mode. I also plan to post analyses of games I'm playing as a design exercise and for fun.

I will write about more game stuff like arcade trips, game jams and electronics! Plus whatever I haven't thought of! If you use RSS, subscribe to my feed!


↠ RSS Feed ↞