from random import randrange
from os import listdir
from os.path import join

from pygame import image

from xenographic_wall.pgfw.GameChild import GameChild
from xenographic_wall.world.mushrooms.Mushroom import Mushroom

class Mushrooms(GameChild, list):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.subscribe_to(self.get_custom_event_id(), self.respond_to_event)
        self.load_images()
        self.reset()

    def respond_to_event(self, evt):
        if self.is_command(evt, "reset-game"):
            self.reset()

    def load_images(self):
        images = []
        root = self.get_resource("mushrooms", "path")
        files = self.get_configuration("mushrooms", "images")
        for path in listdir(root):
            parent = join(root, path)
            images.append(
                (image.load(join(parent, files[0])).convert_alpha(),
                 image.load(join(parent, files[1])).convert_alpha()))
        self.images = images

    def reset(self):
        self.populate()

    def populate(self):
        images = self.images
        count = self.get_configuration().get("mushrooms", "count")
        group_count = len(images)
        list.__init__(self, [[] for _ in range(group_count)])
        for ii in range(count):
            self.add_mushroom(ii % group_count)

    def add_mushroom(self, group):
        mushroom = Mushroom(self, group, self.images[group])
        self[group].append(mushroom)
        return mushroom

    def replace_mushroom(self, mushroom):
        group = mushroom.group
        self[group].remove(mushroom)
        self.add_mushroom(group)

    def update(self):
        for group in self:
            for mushroom in group:
                mushroom.update()
from time import time
from collections import deque

from pygame import Surface, Color, mouse, draw

from xenographic_wall.pgfw.GameChild import *
from xenographic_wall.world.scope.chain.Chain import Chain

class Scope(GameChild):

    transparent_color = Color("magenta")

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.subscribe_to(self.get_custom_event_id(), self.respond_to_event)
        self.chain = Chain(self)
        self.deactivate()
        self.reset()

    def activate(self):
        self.active = True

    def deactivate(self):
        self.active = False

    def respond_to_event(self, evt):
        if self.active:
            is_command = self.is_command
            if is_command(evt, "mouse-down-left"):
                self.respond_to_set()
            if is_command(evt, "mouse-down-right"):
                self.respond_to_set_and_reel()
            if is_command(evt, "reel"):
                self.respond_to_reel()

    def respond_to_set(self):
        if not self.flash_start:
            self.place()

    def hide(self):
        self.chain.hide()

    def collide_click(self):
        return self.chain.collidepoint(self.parent.get_mouse_pos())

    def respond_to_set_and_reel(self):
        if not self.flash_start:
            if self.chain.is_hidden() or not self.collide_click():
                self.place()
            self.activate_flash()

    def place(self):
        self.chain.place(self.parent.get_mouse_pos())

    def activate_flash(self):
        self.flash_start = time()
        self.chain.set_color_to_flash()
#         self.show()

    def show(self):
        self.chain.show()

    def respond_to_reel(self):
        self.activate_flash()

    def reset(self):
        chain = self.chain
        chain.reset()
        self.deactivate_flash()
        chain.hide()

    def deactivate_flash(self):
        self.flash_start = None
        self.chain.set_color_to_default()

    def update(self):
        if self.active:
            self.update_flash()
            self.chain.update()

    def update_flash(self):
        start = self.flash_start
        config = self.get_configuration().get_section("scope")
        chain = self.chain
        if start:
            if time() - start > config["flash-length"]:
                self.deactivate_flash()
                chain.set_color_to_default()
            else:
                chain.rotate_colors()
from collections import deque

from pygame import Rect, Color, mouse

from xenographic_wall.pgfw.GameChild import GameChild
from xenographic_wall.world.scope.chain.Ring import Ring

class Chain(GameChild, Rect):

    transparent_color = Color("green")
    
    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.init_rect()
        self.set_rings()
        self.subscribe_to(self.get_custom_event_id(), self.respond_to_event)
        self.reset()

    def init_rect(self):
        width = self.get_configuration("scope", "diameter")
        Rect.__init__(self, 0, 0, width, width)

    def set_rings(self):
        rings = []
        for ii in range(self.get_configuration("scope", "ring-count")):
            rings.append(Ring(self, ii))
        self.rings = rings

    def respond_to_event(self, evt):
        if self.parent.active:
            if self.is_command(evt,"mouse-scroll-up"):
                self.glow()
            if self.is_command(evt, "mouse-scroll-down"):
                self.darken()

    def glow(self):
        max_alpha = 255
        rings = list(reversed(self.rings))
        threshold = max_alpha / len(rings)
        for ii, ring in enumerate(rings):
            if ii == 0 or rings[ii - 1].get_alpha() >= threshold:
                alpha = ring.get_alpha() + self.get_glow_step()
                if alpha > max_alpha:
                    alpha = max_alpha
                ring.set_alpha(alpha)

    def get_glow_step(self):
        return self.get_configuration("scope", "glow-step")

    def darken(self):
        for ring in self.rings:
            alpha = ring.get_alpha() - self.get_glow_step()
            if alpha < 0:
                alpha = 0
            ring.set_alpha(alpha)

    def reset(self):
        self.hide()
        self.set_color_to_default()

    def hide(self):
        for ring in self.rings:
            ring.set_alpha(0)

    def show(self):
        for ring in self.rings:
            ring.set_alpha(255)

    def place(self, pos):
        self.center = pos
        for ring in self.rings:
            ring.rect.center = pos

    def set_color_to_default(self):
        self.colors = deque(map(Color,
                                self.get_configuration("scope", "colors")))
        self.update_colors()

    def update_colors(self):
        for ii, ring in enumerate(self.rings):
            ring.set_color(self.colors[ii])

    def set_color_to_flash(self):
        self.colors = deque(map(Color,
                                self.get_configuration("scope", "flash-colors")))
        self.update_colors()

    def rotate_colors(self):
        self.colors.rotate(1)
        self.update_colors()

    def is_hidden(self):
        for ring in self.rings:
            if ring.get_alpha() > 0:
                return False
        return True

    def update(self):
        for ring in self.rings:
            ring.update()
3.140.195.140
3.140.195.140
3.140.195.140
 
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.