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.157
216.73.216.157
216.73.216.157
 
June 23, 2019

is pikachu dead

yes and how about that for a brain tickler that what you're seeing all along was a ghost. we used a digital stream of bits that in the future we call blood to recreate everything as a malleable substance that is projected through computers over a massive interstellar network that runs faster than the speed of light in order to simultaneously exist at every moment in time exactly the same way effectively creating a new dimension through which you can experience the timeless joy of video games. you can press a button and watch the impact of your actions instantaneously resonate eternally across an infinite landscape as you the master of a constantly regenerating universe supplant your reality with your imagination giving profoundly new meaning to the phrase what goes around comes around as what comes around is the manifestation of the thoughts you had before you were aware of them. thoughts before they were thought and actions before they were done! it's so revolutionary we saved it for 10,000 years from now but it's all recycled here in the past with you at the helm and the future at the tips of your fingers