예제 #1
0
파일: scene.py 프로젝트: warnj/cse475-sp17
    def __init__(self, screen):
        super(PlatformingScene, self).__init__(screen)

        self.background_drawn = False
        self.headersize = 30

        self.camera = pygame.rect.Rect(0, 0, game_constants.w,
                                       game_constants.h)
        self.special_chars = SpecialChars()
        self.movelist = []
        self.time_elapsed = 0

        self.health = Health(5)
        self.score = Score(screen)
        self.player = Player(
            (screen.get_width() / 2, screen.get_height() / 2 - 30))
        self.playergroup = RenderUpdatesDraw(self.player)

        self.platforms = {}
        self.platforms[game_constants.h - 80] = [
            general.Box(-10000, game_constants.h - 80, 20000, 16)
        ]

        self.statics = RenderUpdatesDraw()
        self.statics.add(self.platforms.values()[0])
        self.screenstatics = RenderUpdatesDraw()
        self.actives = RenderUpdatesDraw()
        self.powerups = RenderUpdatesDraw()

        self.place_platforms()
        self.player.colliders = self.screenstatics

        self.header = pygame.Surface((screen.get_width(), self.headersize))
        self.header.fill(Color.BLACK)

        self.background = pygame.Surface(screen.get_size()).convert()

        gradiation = 128.0
        for i in xrange(int(gradiation)):
            color = (150 - (i * 150 / gradiation),
                     150 - (i * 150 / gradiation), 200)
            rect = (0, i * game_constants.h / gradiation, game_constants.w,
                    game_constants.h / gradiation + 1)
            self.background.fill(color, rect)

        # Move sprites into or out of 'screenstatics' group based on whether they're in camera
        self.screencheck()

        # fixme: rearchitect this
        self.challenging = False