当前位置: 首页>>代码示例>>Python>>正文


Python Common.get_font方法代码示例

本文整理汇总了Python中common.Common.get_font方法的典型用法代码示例。如果您正苦于以下问题:Python Common.get_font方法的具体用法?Python Common.get_font怎么用?Python Common.get_font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Common的用法示例。


在下文中一共展示了Common.get_font方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainMenu

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import get_font [as 别名]
class MainMenu(object):

    def __init__(self):
        # common.Common.__init__(self)
        self.common = Common('title_screen.gif')
        self.level_to_load = 1
        self.screen = Screen()

        # self.levels = Levels()
        # self.level = Level1()
        # pg.display.update()

        self.level_sprites = pg.sprite.Group()
        self.prince = Prince()
        # initial_prince_pos =  (580, 85)
        # self.prince.rect.x = initial_prince_pos[0]
        # self.prince.rect.y = initial_prince_pos[1]
        self.level_sprites.add(self.prince)

        surface = pg.display.get_surface()

        # cursor.image, cursor.rect = self.common.get_image(x=0, y=0, width=640, height=480)
        # surface.blit(cursor.image, cursor.rect)
        image = self.common.get_image(x=0, y=0, width=800, height=600, scale_to=1.3)
        surface.blit(image, (0, 0))

        # self.levels = Levels()

        font = self.common.get_font();
        label = font.render("Press space to start!", 1, (255, 255, 255))
        surface.blit(label, (280, 530))

        # self.screen = pg.display.set_mode((800, 600))

        pg.display.update()

        self.events()

    def events(self):

        while True:
            e = pg.event.wait()
            if e.type == pg.QUIT:
                pg.quit()
            elif e.type == pg.KEYDOWN:

                # left = 276, right = 275, up=273, down=274

                # TODO: improve this

                if e.key == K_SPACE:
                    self.load_level(self.level_to_load)

                if e.key == K_LEFT:
                    self.move_left()



        self.levels.level_sprites.update()

        self.levels.level_sprites.draw(self.screen)


    def load_level(self, level):
        # if level == 1:
        self.level = Level1()
        pg.display.update()
        # pass
        # self.level_sprites.update()
        # pg.display.update()
        # self.level.load()

    def move_left(self):
        self.level.move_left()
开发者ID:nicolascarbone,项目名称:prince,代码行数:76,代码来源:main_menu.py

示例2: Game

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import get_font [as 别名]
class Game():

    def __init__(self):

        pg.init()
        # pg.event.set_allowed([pg.KEYDOWN, pg.KEYUP, pg.QUIT])
        pg.display.set_caption('Prince of Persia!')

        self.screen = pg.display.set_mode((800, 600))

        self.level_to_load = 1

        self.level_sprites = pg.sprite.Group()
        self.prince = Prince()
        # self.prince.rect.x = 580
        # self.prince.rect.y = 85
        self.level_sprites.add(self.prince)

        self.common = Common('title_screen.gif')
        image = self.common.get_image(x=0, y=0, width=800, height=600, scale_to=1.3)
        self.screen.blit(image, (0, 0))

        font = self.common.get_font();
        label = font.render("Press space to start!", 1, (255, 255, 255))
        self.screen.blit(label, (280, 530))

        pg.display.flip()

        self.splash_screen()

    def splash_screen(self):
        while True:
            e = pg.event.wait()
            if e.type == pg.QUIT:
                pg.quit()
            elif e.type == pg.KEYDOWN and e.key == K_SPACE:
                self.load_level()
                self.main()

    def next_level(self):
        pass

    def quit_game(self):
        pass

    def main(self):
        clock = pg.time.Clock()
        while True:
            e = pg.event.wait()

            if e.type == pg.QUIT:
                pg.quit()
            elif e.type == pg.KEYDOWN:

                if e.key == K_LEFT:
                    self.move_left()

                self.update()

                # self.level_sprites.update()
                # self.level_sprites.draw(self.screen)
                # self.level.draw(self.screen)
                # self.level.update()

            # last_movement = self.prince.left_movements[-1]
            # self.prince.image = last_movement
            # self.prince.rect.x -= 65
            # self.level_sprites.update()

            clock.tick(60)

            pg.display.flip()


    def update(self):
        self.level.draw(self.screen)
        self.level_sprites.update()
        self.level_sprites.draw(self.screen)


    def load_level(self):
        self.level = Level1()
        position = self.level.get_prince_initial_position()
        self.prince.rect.x = position[0]
        self.prince.rect.y = position[1]
        # self.prince.rect = position
        self.update()

    def move_left(self):
        for mov in self.prince.left_movements[1:]:
            self.prince.image = mov
            self.prince.rect.x -= 55

            self.level_sprites.update()
            self.level_sprites.draw(self.screen)

            # pg.time.delay(50)
            pg.display.flip()
开发者ID:nicolascarbone,项目名称:prince,代码行数:100,代码来源:game.py


注:本文中的common.Common.get_font方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。