from xenographic_wall.pgfw.Configuration import TypeDeclarations
from xenographic_wall.pgfw.Game import Game
from xenographic_wall.Introduction import Introduction
from xenographic_wall.world.World import World

class XenographicWall(Game):

    def __init__(self):
        Game.__init__(self, type_declarations=Types())
        self.introduction.activate()

    def set_children(self):
        Game.set_children(self)
        self.introduction = Introduction(self)
        self.world = World(self)

    def update(self):
        self.introduction.update()
        self.world.update()


class Types(TypeDeclarations):

    additional_defaults = \
        {"intro": \
         {"path": ["mask", "cord", "starfield", "sunburst"],
          "int": ["frame-duration", "starfield-max-alpha",
                  "prompt-visible-frames", "reset-delay"],
          "int-list": ["cord-y-range", "zoom-upper-left",
                       "zoom-region-dimensions"],
          "float": ["cord-speed", "zoom-step-ratio", "sunburst-delay",
                    "zoom-delay", "starfield-fade-step"]},
         "scope": \
         {"int": ["diameter", "ring-count", "flash-length"],
          "list": ["colors", "flash-colors"],
          "float": ["glow-step"]},
         "world": \
         {"path": "audio",
          "int-list": ["dimensions", "frame-border", "scroll-speed"]},
         "mushrooms": \
         {"int": "count", "list": "images", "path": "path"},
         "creature": \
         {"path": "root"}}
from pygame import mouse, Color, Surface, Rect

from xenographic_wall.pgfw.GameChild import GameChild
from xenographic_wall.world.scope.Scope import Scope
from xenographic_wall.world.mushrooms.Mushrooms import Mushrooms
from xenographic_wall.creatures.Creatures import Creatures

class World(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.init_surface()
        self.deactivate()
        self.initialize_clip()
        self.scope = Scope(self)
        self.mushrooms = Mushrooms(self)
        self.set_frame()
        self.subscribe_to(self.get_custom_event_id(), self.respond_to_event)
        self.creatures = Creatures(self)
        self.reset()

    def init_surface(self):
        size = self.get_configuration().get("world", "dimensions")
        Surface.__init__(self, size)

    def deactivate(self):
        self.active = False

    def respond_to_event(self, evt):
        if self.is_command(evt, "cancel-introduction"):
            self.activate()
        elif self.is_command(evt, "reset-game"):
            self.reset()

    def activate(self):
        self.active = True
        self.scope.activate()
        self.get_audio().play_bgm(self.get_resource("world", "audio"))
        mouse.set_pos(self.get_screen().get_rect().center)

    def get_mouse_pos(self):
        pos = mouse.get_pos()
        clip = self.get_clip()
        return pos[0] + clip.left, pos[1] + clip.top

    def initialize_clip(self):
        clip = Rect((0, 0), self.get_screen().get_size())
        clip.center = self.get_rect().center
        self.set_clip(clip)

    def set_frame(self):
        border = self.get_configuration("world", "frame-border")
        screen = self.get_screen()
        frame = Rect((0, 0), screen.get_size())
        frame.w -= border[0]
        frame.h -= border[1]
        frame.center = screen.get_rect().center
        self.frame = frame

    def reset(self):
        self.deactivate()
        self.scope.reset()
        self.initialize_clip()
        self.creatures.reset()

    def update(self):
        if self.active:
            self.clear()
            self.update_clip()
            self.scope.update()
            self.mushrooms.update()
            self.creatures.update()
            self.draw()

    def clear(self):
        self.fill(Color("black"))

    def update_clip(self):
        x, y = mouse.get_pos()
        frame = self.frame
        move = self.move_clip
        dx, dy = 0, 0
        if not frame.collidepoint((x, y)):
            if y < frame.top:
                dy = y - frame.top
            elif y > frame.bottom:
                dy = y - frame.bottom
            if x < frame.left:
                dx = x - frame.left
            elif x > frame.right:
                dx = x - frame.right
            mx, my = self.get_configuration("world", "scroll-speed")
            move(dx / mx, dy / my)

    def move_clip(self, x=0, y=0):
        clip = self.get_clip()
        bound = self.get_rect()
        original_center = clip.center
        clip.top += y
        if clip.top < bound.top:
            clip.top = bound.top
        elif clip.bottom > bound.bottom:
            clip.bottom = bound.bottom
        clip.left += x
        if clip.left < bound.left:
            clip.left = bound.left
        elif clip.right > bound.right:
            clip.right = bound.right
        self.set_clip(clip)
        new_center = clip.center
        return new_center[0] - original_center[0], \
               new_center[1] - original_center[1]

    def draw(self):
        screen = self.get_screen()
        screen.blit(self, (0, 0), self.get_clip())
from random import randrange

from pygame import Surface, Color, Rect

from xenographic_wall.pgfw.GameChild import GameChild

class Mushroom(GameChild, Surface):

    transparent_color = Color("magenta")

    def __init__(self, parent, group, images):
        GameChild.__init__(self, parent)
        self.group = group
        self.images = images
        self.init_surface()
        self.place()
        self.eaten = False
        self.bitten = False

    def init_surface(self):
        image = self.images[0]
        Surface.__init__(self, image.get_size())
        self.clear()
        self.set_colorkey(self.transparent_color)
        self.blit(image, (0, 0))

    def clear(self):
        self.fill(self.transparent_color)

    def place(self):
        world = self.parent.parent
        size = self.get_size()
        x_bound = world.get_width() - size[0]
        y_bound = world.get_height() - size[1]
        self.rect = Rect((randrange(0, x_bound), randrange(0, y_bound)), size)

    def eat(self):
        self.eaten = True

    def bite(self):
        self.clear()
        self.blit(self.images[1], (0, 0))
        self.bitten = True
        sound = self.get_configuration("mushrooms", "bite-sound")
        self.get_audio().play_fx(sound, self.get_x_ratio())

    def get_x_ratio(self):
        return float(self.rect.centerx) / self.parent.parent.get_width()
        
    def update(self):
        self.draw()

    def draw(self):
        self.parent.parent.blit(self, self.rect)
44.210.21.70
44.210.21.70
44.210.21.70
 
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.