コード例 #1
0
    def __init__(self, title=None):
        self.title = "New Game" if not title else title
        self._running = True
        self._display_surf = None
        self.size = self.width, self.height = 400, 640

        self.faixa = Object(10, self.height, (self.width / 2) - 5, 0)

        # Player object
        self.carro = Player(PLAYER_WIDTH, PLAYER_HEIGHT, PLAYER_WIDTH,
                            self.height - PLAYER_HEIGHT,
                            os.path.join("image", "carro.png"))
        self.carro.scale_image()

        # Enemy object
        self.enemy = Enemy(ENEMY_WIDTH, ENEMY_HEIGHT,
                           random.randint(0, self.width - ENEMY_WIDTH),
                           -ENEMY_HEIGHT, os.path.join("image", "inimigo.png"))
        self.enemy.scale_image()
        self.enemy.rotate_image(angle=180)

        # Key event
        self.car_key = None

        # Clock
        self.clock = pygame.time.Clock()