Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):

        super(GameScene, self).__init__(*args, **kwargs)

        self.image = pyglet.resource.image('res/images/sprites/sprite.png')

        self.tweet_timeout = 1.5

        self.boundaries = [0, 0, 640, 480]

        self.bitmap_font = BitmapFont('res/images/fonts/font.png', 5, 10)
        self.batch = pyglet.graphics.Batch()
        self.tweets = []
        self.letters = []

        self.points = 0
        self.new_points = 0
        self.timeout_label = pyglet.text.Label('0',
                                               font_name='Times New Roman',
                                               font_size=36,
                                               x=630, y=360,
                                               anchor_x='right',
                                               anchor_y='top')
        self.points_label = pyglet.text.Label('0',
                                              font_name='Times New Roman',
                                              font_size=36,
                                              x=630, y=460,
                                              anchor_x='right',
                                              anchor_y='top')

        player_animations = load_animations({
            'idle-right': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/idle-right.png', 1, 6]
            },
            'idle-left': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/idle-left.png',
                 1, 6]},
            'run-right': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/run-right.png',
                 1, 4]},
            'run-left': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/run-left.png',
                 1, 4]},
            'rolling-right': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/rolling-right.png',
                 1, 3]},
            'rolling-left': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/rolling-left.png',
                 1, 3]},
            'dying': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/dying.png',
                 1, 9, 0.12]},
        })

        self.player = Player(320, 0, player_animations,
                             player_animations['idle-right'],
                             batch=self.batch)

        self.bird_animations = load_animations({
            'bird-right': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/bird-right.png',
                 1, 7]},
            'bird-left': {
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/bird-left.png',
                 1, 7]},
        })
        self.background = pyglet.resource.image('res/images/bg/bg1.jpg')

        self.explosion_animation = load_animation({
                'loader': 'grid',
                'parameters':
                ['res/images/sprites/explosion.png', 1, 6]})

        self.sounds = {
            'pickup': pyglet.media.load('res/sfx/pickup.wav',
                                        streaming=False),
        }
Exemplo n.º 2
0
def load_animations(animations_def):

    return {anim: load_animation(data)
            for anim, data in animations_def.items()}