Exemplo n.º 1
0
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = Group(self.camera)

        font = spyral.Font(None, FONT_SIZE, FG_COLOR)

        self.title = TextSprite(self.group, font)
        self.title.anchor = 'center'
        self.title.pos = (SIZE[0] / 2, 30)
        self.title.render("N")

        self.block = Sprite(self.group)
        self.block.image = spyral.Image(size=(40, 40))
        self.block.image.fill(FG_COLOR)
        self.block.y = 300

        self.index = 0

        self.set_animation()

        instructions = TextSprite(self.group, font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("n: next example  p: previous example  q: quit")
Exemplo n.º 2
0
 def __init__(self):
     Scene.__init__(self)
     self.camera = self.parent_camera.make_child(SIZE)
     self.group = Group(self.camera)
     
     font = spyral.Font(None, FONT_SIZE, FG_COLOR)
     
     self.title = TextSprite(self.group, font)
     self.title.anchor = 'center'
     self.title.pos = (SIZE[0] / 2, 30)
     self.title.render("N")
     
     self.block = Sprite(self.group)
     self.block.image = spyral.Image(size=(40,40))
     self.block.image.fill(FG_COLOR)
     self.block.y = 300
     
     self.index = 0
     
     self.set_animation()
     
     instructions = TextSprite(self.group, font)
     instructions.anchor = 'midbottom'
     instructions.x = 320
     instructions.y = 470
     instructions.render("n: next example  p: previous example  q: quit")
Exemplo n.º 3
0
class AnimationExamples(Scene):
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = Group(self.camera)

        font = spyral.Font(None, FONT_SIZE, FG_COLOR)

        self.title = TextSprite(self.group, font)
        self.title.anchor = 'center'
        self.title.pos = (SIZE[0] / 2, 30)
        self.title.render("N")

        self.block = Sprite(self.group)
        self.block.image = spyral.Image(size=(40, 40))
        self.block.image.fill(FG_COLOR)
        self.block.y = 300

        self.index = 0

        self.set_animation()

        instructions = TextSprite(self.group, font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("n: next example  p: previous example  q: quit")

    def on_enter(self):
        bg = spyral.Image(size=SIZE)
        bg.fill(BG_COLOR)
        self.camera.set_background(bg)

    def render(self):
        self.group.draw()

    def set_animation(self):
        self.title.render(ANIMATIONS[self.index][0])
        self.block.stop_all_animations()
        self.block.y = 300  # Reset the y-coordinate.
        a = ANIMATIONS[self.index][1] + DELAY
        a.loop = True
        self.block.animate(a)

    def next(self):
        self.index += 1
        self.index %= len(ANIMATIONS)
        self.set_animation()

    def previous(self):
        self.index -= 1
        self.index %= len(ANIMATIONS)
        self.set_animation()

    def update(self, dt):
        for event in self.event_handler.get():
            if event['type'] == 'QUIT':
                spyral.quit()
                sys.exit()
            if event['type'] == 'KEYDOWN':
                if event['ascii'] == 'p':
                    self.previous()
                elif event['ascii'] == 'n':
                    self.next()
                elif event['ascii'] == 'q':
                    spyral.quit()
                    sys.exit()

        self.group.update(dt)
Exemplo n.º 4
0
class AnimationExamples(Scene):
    def __init__(self):
        Scene.__init__(self)
        self.camera = self.parent_camera.make_child(SIZE)
        self.group = Group(self.camera)
        
        font = spyral.Font(None, FONT_SIZE, FG_COLOR)
        
        self.title = TextSprite(self.group, font)
        self.title.anchor = 'center'
        self.title.pos = (SIZE[0] / 2, 30)
        self.title.render("N")
        
        self.block = Sprite(self.group)
        self.block.image = spyral.Image(size=(40,40))
        self.block.image.fill(FG_COLOR)
        self.block.y = 300
        
        self.index = 0
        
        self.set_animation()
        
        instructions = TextSprite(self.group, font)
        instructions.anchor = 'midbottom'
        instructions.x = 320
        instructions.y = 470
        instructions.render("n: next example  p: previous example  q: quit")
                
    def on_enter(self):
        bg = spyral.Image(size=SIZE)
        bg.fill(BG_COLOR)
        self.camera.set_background(bg)
                
    def render(self):
        self.group.draw()
        
    def set_animation(self):
        self.title.render(ANIMATIONS[self.index][0])
        self.block.stop_all_animations()
        self.block.y = 300 # Reset the y-coordinate.
        a = ANIMATIONS[self.index][1] + DELAY
        a.loop = True
        self.block.animate(a)
        
    def next(self):
        self.index += 1
        self.index %= len(ANIMATIONS)
        self.set_animation()
        
    def previous(self):
        self.index -= 1
        self.index %= len(ANIMATIONS)
        self.set_animation()
        
    def update(self, dt):
        for event in self.event_handler.get():
            if event['type'] == 'QUIT':
                spyral.quit()
                sys.exit()
            if event['type'] == 'KEYDOWN':
                if event['ascii'] == 'p':
                    self.previous()
                elif event['ascii'] == 'n':
                    self.next()
                elif event['ascii'] == 'q':
                    spyral.quit()
                    sys.exit()
                    
        self.group.update(dt)