from time import time
from random import randint

from pygame import Surface, Color

from antidefense.pgfw.GameChild import GameChild
from antidefense.map.scale.Scale import Scale
from antidefense.map.Layer import Layer
from antidefense.map.Stamps import Stamps

class Map(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.deactivate()
        self.set_surface()
        self.set_dimensions()
        self.subscribe_to(self.get_custom_event_id(), self.respond_to_event)
        self.scale = Scale(self)
        self.stamps = Stamps(self)
        self.reset()

    def deactivate(self):
        self.active = False

    def set_surface(self):
        Surface.__init__(self, self.get_screen().get_size())

    def set_dimensions(self):
        magnitude = self.get_configuration("map", "magnitude")
        self.dimensions = tuple(map(lambda x: x ** magnitude, self.get_size()))

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

    def reset(self):
        self.visible_dimensions = self.dimensions
        self.scale.update()
        self.set_target()
        self.set_target_pixel()
        self.stamps.reset()
        self.current_layer = Layer(self)

    def set_target(self):
        w, h = self.dimensions
        self.target = randint(0, w - 1), randint(0, h - 1)

    def set_target_pixel(self):
        vx, vy = self.visible_dimensions
        x, y = self.target
        w, h = self.get_screen().get_size()
        self.target_pixel = int(float(x) / vx * w), int(float(y) / vy * h)

    def activate(self):
        self.active = True

    def get_zoom_level(self):
        return 1 - float(self.visible_dimensions[0]) / self.dimensions[0]
        
    def update(self):
        if self.active:
            self.clear()
            self.draw()

    def clear(self):
        self.blit(self.current_layer, (0, 0))

    def draw(self):
        self.scale.draw()
        self.get_screen().blit(self, (0, 0))
from pygame import Surface, Color

from antidefense.pgfw.GameChild import GameChild

class Bar(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.config = self.get_configuration("scale")
        self.init_surface()
        self.set_rect()
        self.paint()

    def init_surface(self):
        config = self.config
        Surface.__init__(self, config["bar-dimensions"])
        self.set_alpha(config["bar-alpha"])

    def set_rect(self):
        rect = self.get_rect()
        rect.bottom = self.parent.get_height()
        self.rect = rect

    def paint(self):
        config = self.config
        colors = map(Color, config["colors"])
        w = self.get_width()
        segment_w = w / config["segments"]
        for ii, x in enumerate(range(0, w, segment_w)):
            color = colors[ii % len(colors)]
            self.fill(color, (x, 0, segment_w, self.get_height()))

    def draw(self):
        self.parent.blit(self, self.rect)
from pygame import Surface, Color
from pygame.locals import *

from antidefense.pgfw.GameChild import GameChild
from antidefense.map.scale.Bar import Bar
from antidefense.map.scale.Text import Text

class Scale(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.config = self.get_configuration("scale")
        self.init_surface()
        self.set_rect()
        self.bar = Bar(self)
        self.text = Text(self)

    def init_surface(self):
        config = self.config
        bar_w, bar_h = config["bar-dimensions"]
        h = bar_h + config["font-size"] + config["font-padding"] * 2
        Surface.__init__(self, (bar_w, h), SRCALPHA)
        self.clear()

    def set_rect(self):
        rect = self.get_rect()
        x, y = self.config["offset"]
        rect.left = x
        rect.bottom = self.parent.get_height() - y
        self.rect = rect

    def update(self):
        self.clear()
        self.text.update()
        self.bar.draw()

    def clear(self):
        self.fill((0, 0, 0, 0))

    def draw(self):
        self.parent.blit(self, self.rect)
from math import log

from pygame import Surface, Color
from pygame.font import Font
from pygame.locals import *

from antidefense.pgfw.GameChild import GameChild

class Text(GameChild, Surface):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.config = self.get_configuration("scale")
        self.init_surface()
        self.set_rect()
        self.set_fonts()
        self.text = ""

    def init_surface(self):
        parent = self.parent
        h = parent.get_height() - self.config["bar-dimensions"][1]
        Surface.__init__(self, (self.parent.get_width(), h), SRCALPHA)

    def set_rect(self):
        self.rect = self.get_rect()

    def set_fonts(self):
        config = self.config
        path = self.get_resource("scale", "font-path")
        font = Font(path, config["font-size"])
        font.set_bold(True)
        self.font = font

    def update(self):
        self.set_text()
        self.clear()
        self.write_text()
        self.draw()

    def set_text(self):
        config = self.config
        grandparent = self.parent.parent
        ratio = float(self.get_width()) / grandparent.get_width()
        distance = ratio * grandparent.visible_dimensions[0]
        magnitude = int(log(distance, 10))
        resolution = config["resolution"]
        interval = magnitude / resolution
        prefix = config["prefixes"][interval]
        converted = int(distance / 10 ** (interval * resolution))
        self.text = ("%i %s%s" % (converted, prefix, config["unit"])).decode("utf-8")

    def clear(self):
        self.fill((0, 0, 0))
        self.fill((0, 0, 0, 0))

    def write_text(self):
        self.write_stroke()
        block = self.font.render(self.text, True,
                                 Color(self.config["font-color"]))
        rect = block.get_rect()
        rect.center = self.rect.center
        self.blit(block, rect)

    def write_stroke(self):
        config = self.config
        font = self.font
        text = self.text
        color = Color(config["stroke-color"])
        offset = config["stroke-offset"]
        left, right = [font.render(text, True, color) for _ in range(2)]
        lrect = left.get_rect()
        center = self.rect.center
        lrect.center = center
        lrect.x -= 1
        self.blit(left, lrect)
        rrect = right.get_rect()
        rrect.center = center
        rrect.x += 1
        self.blit(right, rrect)

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