from os.path import join

from pygame import Rect
from pygame.image import load
from pygame.transform import flip

from dark_stew.pgfw.Sprite import Sprite

class Rod(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_frames()
        self.center = self.display_surface.get_rect().center
        self.load_line()
        self.deactivate()
        self.frames = [self.normal_frame]
        self.measure_rect()

    def load_frames(self):
        image = load(join(self.parent.sitting_path,
                          self.get_configuration("aphids", "rod-path")))
        self.normal_frame = self.fill_colorkey(image)
        self.mirrored_frame = self.fill_colorkey(flip(image, True, False))

    def load_line(self):
        image = load(join(self.parent.sitting_path,
                          self.get_configuration("aphids",
                                                 "line-path"))).convert_alpha()
        self.line = image
        self.line_rect = self.line.get_rect()

    def activate(self, dx, dy, mirror=False):
        self.active = True
        cx, cy = self.center
        self.rect.topleft = cx + dx, cy + dy
        if mirror:
            self.frames = [self.mirrored_frame]
            self.line_rect.topleft = self.rect.topright
        else:
            self.frames = [self.normal_frame]
            self.line_rect.topleft = self.rect.topleft

    def deactivate(self):
        self.active = False

    def draw(self):
        if self.active:
            Sprite.draw(self)
            self.display_surface.blit(self.line, self.line_rect)
from pygame import event, key as keys, mouse
from pygame.locals import *

from GameChild import *
from EventDelegate import *

class Input(GameChild):

    command_event = EventDelegate.command_event
    left_mouse_button = 1

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribe_to_events()

    def subscribe_to_events(self):
        self.subscribe_to(KEYDOWN, self.translate_key_press)
        self.subscribe_to(MOUSEBUTTONDOWN, self.translate_mouse_down)
        self.subscribe_to(MOUSEBUTTONUP, self.translate_mouse_up)
        self.subscribe_to(MOUSEMOTION, self.translate_mouse_motion)

    def translate_key_press(self, evt):
        key = evt.key
        config = self.get_configuration()
        if key in config["keys-quit"]:
            self.post_command("quit")
        if key in config["keys-capture-screen"]:
            self.post_command("capture-screen")
        if key in config["keys-reset"]:
            self.post_command("reset")

    def post_command(self, name):
        EventDelegate.post_event(self.command_event, command=name)

    def translate_mouse_down(self, evt):
        if evt.button == self.left_mouse_button:
            self.post_command("grab")

    def translate_mouse_up(self, evt):
        if evt.button == self.left_mouse_button:
            self.post_command("release")

    def translate_mouse_motion(self, evt):
        if mouse.get_pressed()[0]:
            self.post_command("drag")

    def is_key_pressed(self, identifier):
        poll = keys.get_pressed()
        for key in self.get_configuration()[identifier]:
            if poll[key]:
                return True
import os
import sys
import time

from pygame import image

from GameChild import *
from Input import *

class ScreenGrabber(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribe_to(Input.command_event, self.save_display)

    def save_display(self, event):
        if event.command == "capture-screen":
            directory = self.get_resource("capture-path")
            try:
                if not os.path.exists(directory):
                    os.mkdir(directory)
                name = self.build_name()
                path = os.path.join(directory, name)
                capture = image.save(self.get_screen(), path)
                print "Saved screen capture to %s" % directory + name
            except:
                print "Couldn't save screen capture to %s, %s" % \
                      (directory, sys.exc_info()[1])

    def build_name(self):
        config = self.get_configuration()
        prefix = config["capture-file-name-format"]
        extension = config["capture-extension"]
        return time.strftime(prefix) + extension
from pygame import display

from GameChild import *

class Display(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.set_screen()
        self.set_caption()

    def set_screen(self):
        configuration = self.get_configuration()
        self.screen = display.set_mode(configuration["display-dimensions"])

    def set_caption(self):
        display.set_caption(self.get_configuration()["game-title"])

    def get_screen(self):
        return self.screen

    def get_size(self):
        return self.screen.get_size()
from os.path import exists, join

from pygame import mixer

import Game

class GameChild:

    def __init__(self, parent=None):
        self.parent = parent

    def get_game(self):
        current = self
        while not isinstance(current, Game.Game):
            current = current.parent
        return current

    def get_configuration(self):
        return self.get_game().get_configuration()

    def get_input(self):
        return self.get_game().get_input()

    def get_screen(self):
        return self.get_game().display.get_screen()

    def get_timer(self):
        return self.get_game().timer

    def get_audio(self):
        return self.get_game().audio

    def get_delegate(self):
        return self.get_game().delegate

    def get_resource(self, key):
        config = self.get_configuration()
        path = config[key]
        if exists(path):
            return path
        else:
            return join(config["media-install-path"], path)

    def subscribe_to(self, kind, callback):
        self.get_game().delegate.add_subscriber(kind, callback)
216.73.216.13
216.73.216.13
216.73.216.13
 
December 3, 2013

Where in the mind's prism does light shine, inward, outward, or backward, and where in a plane does it intersect, experientially and literally, while possessing itself in a dripping wet phantasm?


Fig 1.1 What happens after you turn on a video game and before it appears?

The taxonomy of fun contains the difference between gasps of desperation and exaltation, simultaneously identical and opposite; one inspires you to have sex, while the other to ejaculate perpetually. A destruction and its procession are effervescent, while free play is an inseminated shimmer hatching inside you. Unlikely to be resolved, however, in such a way, are the climaxes of transitions between isolated, consecutive game states.

You walk through a door or long-jump face first (your face, not Mario's) into a painting. A moment passes for eternity, viscerally fading from your ego, corpus, chakra, gaia, the basis of your soul. It happens when you kill too, and especially when you precisely maim or obliterate something. It's a reason to live, a replicating stasis.


Fig 1.2 Sequence in a video game

Video games are death reanimated. You recurse through the underworld toward an illusion. Everything in a decision and logic attaches permanently to your fingerprint. At the core, you use its energy to soar, comatose, back into the biosphere, possibly because the formal structure of a mind by human standards is useful in the next world.