from esp_hadouken.pgfw.Sprite import Sprite

class Toy(Sprite):

    def __init__(self, parent):
        Sprite.__init__(self, parent)
        self.load_from_path(self.get_resource("toy", "path"), True)
        self.set_framerate(self.get_configuration("toy", "framerate"))
from os.path import exists, join, basename
from sys import argv

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]
        installed_path = join(config["resources-install-path"], path)
        if exists(installed_path) and self.use_installed_resource():
            return installed_path
        elif exists(path):
            return path

    def use_installed_resource(self):
        if "-l" in argv:
            return False
        return True

    def get_pause_screen(self):
        return self.get_game().pause_screen

    def get_high_scores(self):
        return self.get_game().high_scores

    def get_glyph_palette(self):
        return self.get_game().glyph_palette

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

    def unsubscribe_from(self, kind, callback):
        self.get_game().delegate.remove_subscriber(kind, callback)

    def is_debug_mode(self):
        return "-d" in argv
from time import time

from pygame.locals import *

from esp_hadouken.pgfw.GameChild import *
from esp_hadouken.pgfw.Input import *

class Timer(GameChild, dict):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.max_time = self.get_configuration("timer", "max-time")
        self.subscribe_to_events()
        self.reset()

    def subscribe_to_events(self):
        self.subscribe(self.respond_to_event)

    def respond_to_event(self, event):
        if event.command == "reset":
            self.reset()

    def reset(self):
        self.clear_current_interval()
        self.concealed = False
        dict.__init__(self, {"octo": 0, "horse": 0, "diortem": 0, "circulor": 0,
                             "tooth": 0})

    def clear_current_interval(self):
        self.start_time = None
        self.pause_length = 0
        self.pause_start_time = None
        self.paused = False
        self.current_level = None

    def start(self, level):
        self.start_time = time()
        self.current_level = level

    def pause(self):
        if self.start_time:
            paused = self.paused
            if self.paused:
                self.pause_length += time() - self.pause_start_time
            else:
                self.pause_start_time = time()
            self.paused = not paused

    def stop(self):
        start = self.start_time
        level = self.current_level
        if None not in (start, level):
            interval = time() - start - self.pause_length
            self[level] += interval
        self.clear_current_interval()

    def total(self):
        if self.concealed:
            return self.max_time
        return sum(self.values())

    def conceal(self):
        self.concealed = True
import pygame
from pygame.locals import *

from GameChild import *

class EventDelegate(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.subscribers = dict()
        self.disable()
        if self.is_debug_mode():
            print "Event ID range: %i - %i" % (NOEVENT, NUMEVENTS)

    def enable(self):
        self.enabled = True

    def disable(self):
        self.enabled = False

    def dispatch_events(self):
        if self.enabled:
            subscribers = self.subscribers
            for event in pygame.event.get():
                kind = event.type
                if kind in subscribers:
                    for subscriber in subscribers[kind]:
                        if self.is_debug_mode():
                            print "Passing %s to %s" % (event, subscriber)
                        subscriber(event)
        else:
            pygame.event.pump()

    def add_subscriber(self, kind, callback):
        if self.is_debug_mode():
            print "Subscribing %s to %i" % (callback, kind)
        subscribers = self.subscribers
        if kind not in subscribers:
            subscribers[kind] = list()
        subscribers[kind].append(callback)

    def remove_subscriber(self, kind, callback):
        self.subscribers[kind].remove(callback)
from pygame import image

from GameChild import *

class PauseScreen(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.load_image()

    def load_image(self):
        self.img = image.load(self.get_resource("pause-image-path"))

    def show(self):
        self.get_screen().blit(self.img, (0, 0))
34.204.193.85
34.204.193.85
34.204.193.85
 
November 9, 2013


Food Spring - Watermelon Stage

Getting the fruit as far as possible is the object of each level, collecting bigger, more valuable guns. The final result is determined by the size of the fruits' collection when the monkey arrives in North America and either survives or perishes in the fruits' attack.

Watermelon Peach
Pineapple Grapes