from pygame.time import get_ticks

from lib.pgfw.pgfw.GameChild import GameChild

class Timer(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.limit = 300000

    def reset(self):
        self.elapsed = 0

    def start(self):
        self.running = True
        self.last_ticks = get_ticks()

    def stop(self):
        self.running = False

    def get_remaining(self):
        return self.limit - self.elapsed

    def get_ratio_remaining(self):
        return float(self.get_remaining()) / self.limit

    def update(self):
        if self.running:
            ticks = get_ticks()
            self.elapsed += ticks - self.last_ticks
            self.last_ticks = ticks
            if self.elapsed >= self.limit:
from pygame import Surface
from pygame.font import Font
from pygame.draw import line
from pygame.locals import *

from lib.pgfw.pgfw.Game import Game
from food_spring.Types import Types
from food_spring.gaia.Gaia import Gaia
from food_spring.Spanky import Spanky
from food_spring.introduction.Introduction import Introduction
from food_spring.Timer import Timer
from food_spring.title.Title import Title
from food_spring.level.Levels import Levels
from food_spring.home.Home import Home
from food_spring.Siphon import Siphon
from food_spring.gun.GunLibrary import GunLibrary

class FoodSpring(Game):

    def __init__(self):
        Game.__init__(self, type_declarations=Types())
        if self.check_command_line("-mute"):
        self.input.register_any_press_ignore(keys=[K_LALT, K_RALT, K_F4])

    def respond(self, event):
        if, "reset-game"):
            for child in (self.home, self.timer):
      "deactivate", child)
      "reset", child)

    def call(self, method, obj):
        if hasattr(obj, method):
            attribute = getattr(obj, method)
            if callable(attribute):

    def activate(self):

    def set_children(self):
        self.gaia = Gaia(self)
        self.spanky = Spanky(self)
        self.timer = Timer(self)
        self.gun_library = GunLibrary(self)
        self.siphon = Siphon(self)
        self.levels = Levels(self)
        self.home = Home(self)

    def update(self):

    def draw_time(self):
        if self.check_command_line("-timer"):
            surface = Font(None, 18).render(str(self.timer.get_remaining() / 1000),
                                            False, (0, 0, 0),
                                            (255, 255, 255))
            self.get_display_surface().blit(surface, (0, 0))
from os.path import join
from glob import glob

from pygame import Surface
from pygame.image import load

from lib.pgfw.pgfw.Sprite import Sprite

class Spanky(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_from_path(self.get_resource(self.root), True, False)

    def load_configuration(self):
        config = self.get_configuration("spanky")
        self.root = config["path"]
        self.jump_order = config["jump-order"]
        self.jump_framerate = config["jump-framerate"]
        self.wag_order = config["wag-order"]
        self.wag_framerate = config["wag-framerate"]
        self.walk_order = config["walk-order"]
        self.walk_framerate = config["walk-framerate"]

    def set_framesets(self):
        for verb in ("jump", "wag", "walk"):
            self.add_frameset(getattr(self, verb + "_order"),
                              getattr(self, verb + "_framerate"), verb)
from os.path import join
from random import randint, randrange, choice
from math import sin, cos, radians, ceil
from collections import deque

from pygame import Surface, Rect, PixelArray
from pygame.image import load
from pygame.mask import from_surface
from pygame.draw import line, aaline
from pygame.transform import rotate
from pygame.locals import *

from lib.pgfw.pgfw.Animation import Animation
from lib.pgfw.pgfw.Sprite import Sprite
from lib.pgfw.pgfw.GameChild import GameChild

class Siphon(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.time_filter = self.get_game().time_filter
        self.color_index = 0

    def load_configuration(self):
        self.badge_size = 60, 44
        self.stem_width = 30

    def set_colors(self):
        components = self.get_configuration("siphon", "root-colors")
        colors = self.colors = []
        for ii in xrange(0, len(components), 6):
            colors.append((components[ii:ii + 3], components[ii + 3:ii + 6]))

    def set_roots(self):
        roots = self.roots = Roots(self, Roots.HORIZONTAL)
        roots.init_surfaces(Rect(0, 0, self.stem_width, self.badge_size[1]))

    def cancel(self):
        self.contracting = False
        self.releasing = False
        self.release_elapsed = 0
        self.angle_deviation = 0

    def set_nodesets(self):
        interpolator = self.get_game().interpolator
        self.release_nodeset = interpolator.get_nodeset("release")

    def set_score(self):
        self.score = [[0, 0, 0] for _ in xrange(5)]

    def set_badges(self):
        self.badges = [Badge(self.roots, ii, self.badge_size) for ii in \

    def set_badge(self):
        points = self.get_points()
        for ii, score in enumerate((2000, 5000, 10000, 16000)):
            if points < score:

    def get_points(self):
        points = 0
        bases = 100, 200, 400, 800, 1600
        for ii, level in enumerate(self.score):
            base = bases[ii]
            for jj in xrange(max(level)):
                points += base * ((level[0] > jj) + (level[1] > jj) + \
                                  (level[2] > jj))
                base *= .9
        return int(points)

    def set_level(self, index=0):
        self.level = self.parent.levels[index]
        self.planet_rect = self.level.planet.location
        self.color_index = index
        for badge in self.badges:

    def draw_nodes(self):
        roots = self.roots
        for node in roots.get_initial():
            y = self.get_initial_y(
            end = node.length, y
            self.draw_line((0, y), end)
            self.draw_children(node, end)

    def get_initial_y(self, node_id):
        modifier = -1 if node_id % 2 else 1
        return self.roots.rect.h / 2 + modifier * 10 * ((node_id + 1) / 2)

    def draw_line(self, start, end, alpha=180):
        line(self.roots.root_surface, self.get_current_colors()[0], start, end,
        aaline(self.roots.root_surface, (255, 255, 255), start, end, 1)

    def get_current_colors(self):
        return self.colors[self.color_index]

    def draw_children(self, node, start, depth=1):
        for child in node.children:
            end = self.get_offset_point(start, child.angle, child.length, True,
            self.draw_line(start, end)
            self.draw_children(child, end, depth + 1)

    def get_offset_point(self, start, angle, length, deviate=False, depth=1):
        if deviate:
            angle -= self.angle_deviation * (angle - .8 ** depth * angle)
        return int(round(start[0] + cos(radians(angle)) * length)), \
               int(round(start[1] + sin(radians(angle)) * length))

    def add(self, level):
        offset = 70
        length = [40, 52, 66, 84, 100][level]
        for _ in xrange(25):
            parent = self.get_random_parent()
            for _ in xrange(3):
                angle = randint(parent.angle - offset, parent.angle + offset)
                if abs(angle) < 87 and (not parent.children or
                                        abs(parent.children[0].angle - angle) >
                    end = self.get_offset_point(self.get_end(parent), angle,
                    if self.check_end(end):
                        roots = self.roots
                        roots.add(length, angle, parent)
                        return True

    def get_random_parent(self):
        node = self.roots[randrange(0, self.roots.initial_count)]
        while node.children:
            if len(node.children) == 1:
                if randint(0, 1):
            node = choice(node.children)
        return node

    def get_end(self, node):
        path = [node]
        while node.parent is not None:
            node = node.parent
        x, y = node.length, self.get_initial_y(path.pop().id)
        while path:
            node = path.pop()
            x, y = self.get_offset_point((x, y), node.angle, node.length)
        return x, y

    def check_end(self, end):
        roots = self.roots.rect
        planet = self.planet_rect
        offset = end[0] + roots.left - planet.left, \
                 end[1] + -
        if planet.move(-planet.left,
            return self.level.planet.frames[0].get_at(offset)[3] == 255

    def increase_score(self, level):
        self.score[level][randint(0, 2)] += 1

    def resize_roots_rect(self, end):
        roots = self.roots.rect
        if end[0] > roots.w:
            roots.w = end[0]
        if end[1] < 0:
            roots.inflate_ip(0, -end[1] * 2)
        elif end[1] > roots.h:
            roots.inflate_ip(0, (end[1] - roots.h) * 2)

    def contract(self):
        self.contracting = True
        self.releasing = False
        self.charge_elapsed = 0

    def release(self):
        if self.contracting:
            self.contracting = False
            self.releasing = True
            self.release_elapsed = 0

    def update(self):
        if self.contracting or self.releasing:

    def update_angle_deviation(self):
        if self.contracting:
            self.angle_deviation =
        elif self.releasing:
            self.release_elapsed += self.time_filter.get_last_frame_duration()
            if self.release_elapsed > self.release_nodeset.get_length():
                self.releasing = False
                self.angle_deviation = 0
                self.angle_deviation = self.release_nodeset.get_y(
                    self.release_elapsed) *

class Roots(GameChild, list):


    def __init__(self, parent, orientation):
        GameChild.__init__(self, parent)
        self.display_surface = self.get_display_surface()
        self.orientation = orientation
        self.gradient = Gradient(self, 200)

    def add(self, length, angle, parent=None):
        self.append(Node(len(self), length, angle, parent))
        if parent is not None:

    def add_initial(self, length):
        count = self.initial_count = 5
        for ii in xrange(count):
            self.add(length, 0)

    def get_initial(self):
        return self[:self.initial_count]

    def init_surfaces(self, rect):
        surface = self.surface = Surface(rect.size)
        surface.set_colorkey((0, 0, 0))
        self.root_surface = Surface(rect.size)
        self.rect = rect

    def set_badge(self, badge):
        self.badge = badge

    def clear_root_surface(self):
        self.root_surface.fill((0, 0, 0))

    def place(self):
        base = self.parent.level.planet.location
        self.rect.midleft = base.left - self.parent.stem_width + 2, \

    def update(self):
        self.surface.blit(self.root_surface, (0, 0), None, BLEND_MIN)
        self.display_surface.blit(self.surface, self.rect)

class Node:

    def __init__(self, id, length, angle, parent=None):, self.length, self.angle, self.parent = id, length, angle, \
        self.children = []

    def add_child(self, child):

class Gradient(Sprite):

    def __init__(self, parent, framerate):
        Sprite.__init__(self, parent, framerate)

    def set_tiles(self):
        tile_rect = Rect(0, 0, 16, 16)
        colors = self.get_colors()
        tiles = self.tiles = []
        segment_count = len(colors)
        segment_width = int(ceil(float(tile_rect.w) / segment_count))
        for _ in xrange(segment_count):
            frame = Surface(tile_rect.size)
            x = 0
            for color in colors:
                frame.fill(color, (x, 0, segment_width, tile_rect.h))
                x += segment_width
            if self.parent.orientation == Roots.VERTICAL:
                frame = rotate(frame, 90)

    def get_colors(self):
        count = 8
        base_color = Color(*self.parent.parent.get_current_colors()[1])
        bh, bs, bl, ba = base_color.hsla
        bs_step = (100 - bs) / float(count - 1)
        bl_step = (100 - bl) / float(count - 1)
        colors = deque()
        for _ in xrange(count):
            color = Color(0, 0, 0)
            color.hsla = map(int, (bh, min(100, bs), min(100, bl), ba))
            bs += bs_step
            bl += bl_step
        return colors

    def set_frames(self):
        self.display_surface = self.parent.surface
        index = 0 if not self.frames else \
        rect = self.parent.rect
        surface = Surface(rect.size)
        if self.parent.orientation == Roots.VERTICAL:
            surface = rotate(surface, 90)
            rect = surface.get_rect()
        for tile in self.tiles:
            frame = surface.copy()
            for x in xrange(0, rect.w, tile.get_width()):
                for y in xrange(0, rect.h, tile.get_height()):
                    frame.blit(tile, (x, y))
        for _ in xrange(index):

class Badge(Animation):

    def __init__(self, parent, level, size):
        Animation.__init__(self, parent)
        self.level = level
        self.rect = Rect((0, 0), size)
        self.display_surface = self.get_display_surface()
        self.background_color = Color(255, 222, 222)
        self.register(self.shift), 120)

    def set_background(self):
        width = 1
        rect = self.rect
        surface = Surface(rect.size)
        colors = (0, 0, 0), (255, 255, 255)
        for ii, x in enumerate(xrange(0, rect.w, width)):
            surface.fill(colors[ii % 2], (x, 0, width, rect.h))
        self.background = surface
        self.surface = Surface(surface.get_size())

    def set_guns(self):
        width = 0
        margin = 5
        images = []
        for guns in self.parent.parent.parent.gun_library:
            image = guns[self.level].frames[0].copy()
            mask = from_surface(image)
            pixels = PixelArray(image)
            for x in xrange(len(pixels)):
                for y in xrange(len(pixels[0])):
                    if mask.get_at((x, y)):
                        pixels[x][y] = (0, 0, 0)
                        pixels[x][y] = (255, 255, 255)
            del pixels
            width += image.get_width() + margin
        self.img = images[0]
        surface = Surface((width, self.rect.h))
        surface.fill((255, 255, 255))
        x = 0
        for image in images:
            rect = image.get_rect()
            rect.midleft = x, self.rect.h / 2
            if self.level == 0:
                rect.centery += 3
            surface.blit(image, rect)
            x += image.get_width() + margin
        self.gun_surface = surface
        self.gun_rect = surface.get_rect()
        self.gun_rect.right = self.rect.w

    def shift(self):
        rect = self.gun_rect
        rect.move_ip(2, 0)
        if rect.left >= rect.w:
            rect.left -= rect.w

    def place(self):
        if self.parent.orientation == Roots.HORIZONTAL:
            self.rect.midright = self.parent.rect.midleft
            self.rect.midtop = self.parent.rect.midbottom

    def update(self):
        gr = self.gun_rect
        self.background.set_colorkey((255, 255, 255))
        self.surface.blit(self.background, (0, 0))
        self.surface.blit(self.gun_surface, gr, None, BLEND_MIN)
        self.surface.blit(self.gun_surface, gr.move(-gr.w, 0), None, BLEND_MIN)
        self.display_surface.blit(self.surface, self.rect)
        h, s, v, a = self.background_color.hsva
        h += 2
        if h > 360:
            h -= 360
        self.background_color.hsva = h, s, v, a
March 3, 2021

Video 📺

Computers are a gun. They can see the target; they can pull the trigger. Computers were made by the military to blow people's brains out if they stepped out of line. Google Coral is the same technology that pollutes the oceans, and so is the computer I'm using, and so are the platforms I'm using to post this.

Game 🎲

Games are a context in which all play is purposeful. Games expose the fundamentally nihilistic nature of the universe and futility of pursuing any path other than the inevitability of death and the torture of an evil that knows and exploits absolute freedom. Games are not educational; they are education.

Propaganda 🆒

Education is propaganda — ego driven by-product conveying nothing that would enable us to expose that vanities made for gain subject us further to an illusion created by those in control: the illusion that quantity can represent substance and that data or observation can replace meaning. And why say it, or how, without contradicting yourself, that everything, once registered, no longer exists, and in fact never did, exists only in relation to other non-existent things, and when you look, it's not there, not only because it's long vanished, but because where would it be?

fig. 2: Gamer goo is a lubricant — not for your skin, but for facilitating your ability to own the competition (image from Gamer goo review)

As a result of video games, the great Trojan horse 🎠 of imperialist consumerist representationalism, people are divided in halves to encourage them to act according to market ordained impulses, to feign assurance, penetrating themselves deeper into a tyranny from which every action signals allegiance, confusing the world with definitions and borders, constantly struggling to balance or brace themselves against forces that threaten the crumbling stability of their ego.


or example, a cup 🥃 is designed and built to hold something, maintain order and prevent chaos. It keeps water from spilling back to where it belongs, back where it wants to go and gravity wants it to go. The cup is a trap, and it is used to assert dominance over nature, to fill with thoughts about existence, time and self, thoughts regarding dissimilarity between equal parts and patterns that manifest in variation. These ruminations disguised as revelations boil away to reveal isolated and self-aggrandizing thoughts about an analogy fabricated to herald the profundity of one's campaign's propaganda. You have no authentic impulse except to feed a delusion of ultimate and final supremacy. That is why you play games. That is your nature. That is why you eventually smash the cup to bits 💥 or otherwise watch it disintegrate forever because it, by being useful, threatens your facade of ownership and control.

fig. 3: worth1000

The cup is you; it reflects you; it is a lens through which you see yourself; it reassures you, confirming your presence; it says something, being something you can observe. When you move, it moves, and it opens after being closed. You can use it as a vessel for penetration fantasies, keeping you warm and fertile, a fine host for the plague of consciousness, you reptile, you sun scorched transgressor that not only bites the hand that feeds, but buries it deep within a sterile chamber where nothing remains for it as a means of escape except the corpses of others that infringed upon your feeding frenzy.