Example #1
0
class MenuBackground(TiledImage):
    bg_color = 255, 200, 0
    image = Animation.frameproperty("anim")
    speed = -20

    def __init__(self):
        self.anim = CoinAnimation(500)
        self.rect = self.image.get_rect()
        self.rect.width *= 2
        self.rect.height *= 2
        self.offset = 0

    def update(self, dt):
        self.anim.update(dt)

        self.offset += self.speed * (dt / 1000.0)
        self.rect.x = self.rect.y = self.offset

    def draw(self, surf, rect=None):
        if rect is None:
            rect = surf.get_rect()

        surf.fill(self.bg_color)

        # draw the image twice, once offset
        orig_rect = self.rect
        TiledImage.draw(self, surf, rect)
        self.rect = self.rect.move(self.rect.width / 2, self.rect.height / 2)
        TiledImage.draw(self, surf, rect)
        self.rect = orig_rect
Example #2
0
class MenuBackground(TiledImage):
    bg_color = 255, 200, 0
    image = Animation.frameproperty("anim")
    speed = -20

    def __init__(self):
        self.anim = CoinAnimation(500)
        self.rect = self.image.get_rect()
        self.rect.width *= 2
        self.rect.height *= 2
        self.offset = 0

    def update(self, dt):
        self.anim.update(dt)

        self.offset += self.speed * (dt / 1000.0)
        self.rect.x = self.rect.y = self.offset

    def draw(self, surf, rect=None):
        if rect is None:
            rect = surf.get_rect()

        surf.fill(self.bg_color)

        # draw the image twice, once offset
        orig_rect = self.rect
        TiledImage.draw(self, surf, rect)
        self.rect = self.rect.move(self.rect.width / 2, self.rect.height / 2)
        TiledImage.draw(self, surf, rect)
        self.rect = orig_rect
Example #3
0
    def setup(self):
        if not hasattr(self.app, "scores"):
            self.app.scores = Score()

        self.title = load_image("logo")

        font = pygame.font.Font(None, 60)
        font.set_italic(True)
        self.inst = font.render("Press <SPACE> to Start", True, self.fg_color, self.bg_color)

        font.set_italic(False)
        self.score = font.render("Hiscore: %05d" % self.app.scores.hiscore, True, self.fg_color, self.bg_color)

        self.anim = CoinAnimation(duration=100000)
        self.background = MenuBackground()

        play_song("title")
Example #4
0
 def __init__(self):
     self.anim = CoinAnimation(500)
     self.rect = self.image.get_rect()
     self.rect.width *= 2
     self.rect.height *= 2
     self.offset = 0
Example #5
0
 def __init__(self):
     self.anim = CoinAnimation(500)
     self.rect = self.image.get_rect()
     self.rect.width *= 2
     self.rect.height *= 2
     self.offset = 0