from os.path import join

from pygame import Rect
from pygame.image import load
from pygame.transform import flip

from dark_stew.pgfw.Sprite import Sprite

class Rod(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_frames() = self.display_surface.get_rect().center
        self.frames = [self.normal_frame]

    def load_frames(self):
        image = load(join(self.parent.sitting_path,
                          self.get_configuration("aphids", "rod-path")))
        self.normal_frame = self.fill_colorkey(image)
        self.mirrored_frame = self.fill_colorkey(flip(image, True, False))

    def load_line(self):
        image = load(join(self.parent.sitting_path,
        self.line = image
        self.line_rect = self.line.get_rect()

    def activate(self, dx, dy, mirror=False): = True
        cx, cy =
        self.rect.topleft = cx + dx, cy + dy
        if mirror:
            self.frames = [self.mirrored_frame]
            self.line_rect.topleft = self.rect.topright
            self.frames = [self.normal_frame]
            self.line_rect.topleft = self.rect.topleft

    def deactivate(self): = False

    def draw(self):
            self.display_surface.blit(self.line, self.line_rect)
from pygame import event, key as keys, mouse
from pygame.locals import *

from GameChild import *
from EventDelegate import *

class Input(GameChild):

    command_event = EventDelegate.command_event
    left_mouse_button = 1

    def __init__(self, game):
        GameChild.__init__(self, game)

    def subscribe_to_events(self):
        self.subscribe_to(KEYDOWN, self.translate_key_press)
        self.subscribe_to(MOUSEBUTTONDOWN, self.translate_mouse_down)
        self.subscribe_to(MOUSEBUTTONUP, self.translate_mouse_up)
        self.subscribe_to(MOUSEMOTION, self.translate_mouse_motion)

    def translate_key_press(self, evt):
        key = evt.key
        config = self.get_configuration()
        if key in config["keys-quit"]:
        if key in config["keys-capture-screen"]:
        if key in config["keys-reset"]:

    def post_command(self, name):
        EventDelegate.post_event(self.command_event, command=name)

    def translate_mouse_down(self, evt):
        if evt.button == self.left_mouse_button:

    def translate_mouse_up(self, evt):
        if evt.button == self.left_mouse_button:

    def translate_mouse_motion(self, evt):
        if mouse.get_pressed()[0]:

    def is_key_pressed(self, identifier):
        poll = keys.get_pressed()
        for key in self.get_configuration()[identifier]:
            if poll[key]:
                return True
import os
import sys
import time

from pygame import image

from GameChild import *
from Input import *

class ScreenGrabber(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribe_to(Input.command_event, self.save_display)

    def save_display(self, event):
        if event.command == "capture-screen":
            directory = self.get_resource("capture-path")
                if not os.path.exists(directory):
                name = self.build_name()
                path = os.path.join(directory, name)
                capture =, path)
                print "Saved screen capture to %s" % directory + name
                print "Couldn't save screen capture to %s, %s" % \
                      (directory, sys.exc_info()[1])

    def build_name(self):
        config = self.get_configuration()
        prefix = config["capture-file-name-format"]
        extension = config["capture-extension"]
        return time.strftime(prefix) + extension
from pygame import display

from GameChild import *

class Display(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)

    def set_screen(self):
        configuration = self.get_configuration()
        self.screen = display.set_mode(configuration["display-dimensions"])

    def set_caption(self):

    def get_screen(self):
        return self.screen

    def get_size(self):
        return self.screen.get_size()
from os.path import exists, join

from pygame import mixer

import Game

class GameChild:

    def __init__(self, parent=None):
        self.parent = parent

    def get_game(self):
        current = self
        while not isinstance(current, Game.Game):
            current = current.parent
        return current

    def get_configuration(self):
        return self.get_game().get_configuration()

    def get_input(self):
        return self.get_game().get_input()

    def get_screen(self):
        return self.get_game().display.get_screen()

    def get_timer(self):
        return self.get_game().timer

    def get_audio(self):
        return self.get_game().audio

    def get_delegate(self):
        return self.get_game().delegate

    def get_resource(self, key):
        config = self.get_configuration()
        path = config[key]
        if exists(path):
            return path
            return join(config["media-install-path"], path)

    def subscribe_to(self, kind, callback):
        self.get_game().delegate.add_subscriber(kind, callback)
September 26, 2017

I made a video about my game Picture Processing for Out of Index 2017! Here is the video along with a transcript.

To save memory, video games are designed to repeat graphics. In raster-based games, image files like textures, tiles and sprites are loaded once into memory and drawn repeatedly by the program to create environments, characters, animations and text. In my puzzle game, 8 by 8 pixel tiles are used to create scenes the player has to recreate. For level 1, the tiles are a cloud, a tree, a mushroom, a character, sky, ground and rock.

An algorithm scrambles the tiles so that each tile is in the wrong memory address at the beginning of a level and the screen looks like a graphics glitch. When level 1 begins, the clouds may be where the trees should be, the mushrooms may be floating in the sky and the character may be switched with rock or the ground. The player's task is to put the tiles where they belong by swapping each tile with a tile in another memory address.

There are five levels, in order of difficulty, based on classic video games or classic video game genres.

The name of this game is taken from the Picture Processing Unit, a microprocessor designed by Nintendo for the Nintendo Entertainment System. The PPU is the hardware component responsible for translating image data into video signals for televisions and screens. It does this with a memory of 8 by 8 pixel tile data, which, along with palette and sprite attribute memory, generates each frame of a video game.

Companies often create lofty, evocative titles for hardware and products. What does the name Picture Processing Unit mean if we consider pictures something independent of a video screen? The phrase picture processing evokes the phrase image processing, a technique used to create applications such as automatic facial and emotion recognition. We often anthropomorphize electronic devices, infusing them with intelligence and souls, forgetting how much more infinitely complex the human mind is compared to a digital processor.

The game is named as a reference to Nintendo's microprocessor because the graphics are tile based, but it is also a reference to the players who are image processors, interpreting a picture from something deterministic into something non-deterministic.

The prototype of this game was created for a game jam called A Game By Its Cover where designers created video games based on imagined Nintendo game cartridges created by visual artists for an exhibition called My Famicase.

Picture Processing is based on one of the imagined cartridges from that exhibition. The cartridge's cover depicts a grid of unordered tiles and is described as a game where one inserts a game cartridge, sees a glitching screen, and meditates about the concept of beauty in imperfection. I added the idea that the player meditates into a state of transcendence until they are able to fix the game's graphics by accessing the memory telepathically.

↠ RSS Feed ↞