import sys

import pygame
from pygame import mouse, display, key
from pygame.locals import *

from GameChild import *
from Animation import *
from Audio import *
from Display import *
from Configuration import *
from EventDelegate import *
from Input import *
from ScreenGrabber import *
from Timer import *
from PauseScreen import *
from introduction.Introduction import *
from overworld.Overworld import *
from levels.LevelFactory import *
from ending.Ending import *
from scoreboard.HighScores import *
from scoreboard.GlyphPalette import *

class Game(GameChild, Animation):

    def __init__(self):
        GameChild.__init__(self)
        self.configuration = Configuration()
        Animation.__init__(self, self.configuration["display-frame-duration"])
        pygame.init()
        mouse.set_visible(False)
        self.add_children()
        self.subscribe_to_events()
        self.introduction.activate()
        self.clear_queue()
        self.delegate.enable()

    def add_children(self):
        self.delegate = EventDelegate(self)
        self.display = Display(self)
        self.input = Input(self)
        self.audio = Audio(self)
        self.screen_grabber = ScreenGrabber(self)
        self.timer = Timer(self)
        self.pause_screen = PauseScreen(self)
        self.introduction = Introduction(self)
        self.overworld = Overworld(self)
        self.level_factory = LevelFactory(self)
        self.glyph_palette = GlyphPalette(self)
        self.ending = Ending(self)
        self.high_scores = HighScores(self)

    def subscribe_to_events(self):
        self.subscribe_to(QUIT, self.end)
        self.subscribe_to(Input.command_event, self.end)

    def get_configuration(self):
        return self.configuration

    def get_input(self):
        return self.input

    def sequence(self):
        self.delegate.dispatch_events()
        self.introduction.update()
        self.overworld.update()
        self.level_factory.update()
        display.update()

    def end(self, evt):
        if evt.type == QUIT or evt.command == "quit":
            sys.exit()
        elif evt.command == "skip" and key.get_mods() & KMOD_LSHIFT:
            self.skip_to_ending()

    def skip_to_ending(self):
        self.timer.conceal()
        self.introduction.deactivate()
        self.ending.display()
from pygame import Color

from esp_hadouken.GameChild import *
from esp_hadouken.Font import *

class InputMessage(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.render()
        self.set_rect()

    def render(self):
        config = self.get_configuration()
        size = config["ending-input-message-size"]
        text = config["ending-input-message"]
        color = Color(config["ending-input-message-color"])
        background = Color(config["ending-input-message-bg"])
        self.message = Font(self, size).render(text, True, color, background)

    def set_rect(self):
        relative = self.parent.get_rect()
        rect = self.message.get_rect()
        rect.centerx = relative.centerx
        rect.top = self.get_configuration()["ending-input-message-y"]
        self.rect = rect

    def activate(self):
        self.active = True

    def deactivate(self):
        self.active = False

    def update(self):
        if self.active:
            self.draw()

    def draw(self):
        self.parent.blit(self.message, self.rect)
from pygame import Surface, image

from esp_hadouken.GameChild import *
from esp_hadouken.Input import *
from esp_hadouken.Toy import *
from Score import *
from name_prompt.NamePrompt import *
from InputMessage import *
from esp_hadouken.scoreboard.Scoreboard import *

class Ending(GameChild, Surface):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.display_surface = self.get_screen()
        Surface.__init__(self, self.display_surface.get_size())
        self.add_children()
        self.subscribe_to_events()
        self.set_background()
        self.deactivate()

    def add_children(self):
        self.score = Score(self)
        self.name_prompt = NamePrompt(self)
        self.input_message = InputMessage(self)
        self.scoreboard = Scoreboard(self)

    def subscribe_to_events(self):
        self.subscribe_to(USEREVENT, self.display)
        self.subscribe_to(Input.command_event, self.run_command)

    def display(self, evt=None):
        if not evt or evt.name == "toy-collected":
            self.deactivate()
            self.activate()
            self.activate_initial_widgets()
            self.update()

    def activate(self):
        self.active = True
        self.start_music()

    def activate_initial_widgets(self):
        self.input_message.activate()
        self.name_prompt.activate()
        self.score.activate()

    def deactivate(self):
        self.active = False
        self.deactivate_initial_widgets()
        self.scoreboard.deactivate()

    def deactivate_initial_widgets(self):
        self.input_message.deactivate()
        self.name_prompt.deactivate()
        self.score.deactivate()

    def run_command(self, evt):
        if evt.command == "reset":
            self.deactivate()
        if self.active and evt.command == "advance":
            if self.name_prompt.active:
                self.deactivate_initial_widgets()
                self.update()
                self.get_high_scores().add(self.name_prompt.get_initials())
                self.scoreboard.activate()
            else:
                self.get_input().post_command("reset")

    def set_background(self):
        path = self.get_resource("ending-bg-path")
        background = image.load(path).convert()
        self.background = background

    def set_toy(self):
        toy = Toy(self)
        config = self.get_configuration()
        toy.resize(config["ending-toy-size"])
        toy.place(config["ending-toy-position"])
        toy.show()
        self.toy = toy

    def start_music(self):
        path = self.get_resource("ending-audio-path")
        self.get_audio().play_bgm(path)

    def update(self):
        self.clear()
        self.score.update()
        self.name_prompt.update()
        self.scoreboard.update()
        self.draw()

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

    def draw(self):
        self.display_surface.blit(self, (0, 0))
18.97.14.88
18.97.14.88
18.97.14.88
 
June 29, 2013

A few weeks ago, for Fishing Jam, I made a fishing simulation from what was originally designed to be a time attack arcade game. In the program, Dark Stew, the player controls Aphids, an anthropod who fishes for aquatic creatures living in nine pools of black water.



Fishing means waiting by the pool with the line in. The longer you wait before pulling the line out, the more likely a creature will appear. Aside from walking, it's the only interaction in the game. The creatures are drawings of things you maybe could find underwater in a dream.

The background music is a mix of clips from licensed to share songs on the Free Music Archive. Particularly, Seed64 is an album I used a lot of songs from. The full list of music credits is in the game's README file.

I'm still planning to use the original design in a future version. There would be a reaction-based mini game for catching fish, and the goal would be to catch as many fish as possible within the time limit. I also want to add details and obstacles to the background, which is now a little boring, being a plain, tiled, white floor.

If you want to look at all the drawings or hear the music in the context of the program, there are Windows and source versions available. The source should work on any system with Python and Pygame. If it doesn't, bug reports are much appreciated. Comments are also welcome :)

Dark Stew: Windows, Pygame Source

I wrote in my last post that I would be working on an old prototype about searching a cloud for organisms for Fishing Jam. I decided to wait a while before developing that game, tentatively titled Xenographic Barrier. Its main interactive element is a first-person scope/flashlight, so I'd like to make a Wii version of it.

I'm about to start working on a complete version of Ball & Cup. If I make anything interesting for it, I'll post something. There are a lot of other things I want to write about, like game analyses, my new GP2X and arcades in Korea, and there's still music to release. Lots of fun stuff coming!