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


Python Loader.load_font方法代码示例

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


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

示例1: GameBoard

# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load_font [as 别名]
class GameBoard(object):
    def __init__(self):
        self.loader = Loader()
        self.desk = self.loader.load_image("back.png")
        self.back = self.desk.copy()

        self.cards1 = self.loader.load_image("cards1.png",True)
        self.cards2 = self.loader.load_image("cards2.png",True)
        
        self.card_back = self.loader.load_image("card.png",True)
        self.card_images = []
        for i in range(18):
            self.card_images.append(self.loader.load_image("img%d.png" % (i+1)))

        self.gfxcards = []
        self.gfxcards_hidden = []
        self.delay = 0

        self.title_fnt = self.loader.load_font("KLEPTOMA.TTF", 50) 
        self.text_fnt = self.loader.load_font("scribble.TTF", 24) 
        self.small_text_fnt = self.loader.load_font("scribble.TTF", 15) 

        self.START_SCREEN = 0
        self.GAME_PLAY = 1
        self.GAME_OVER = 2

        self.card_snd = self.loader.load_sound("card.wav")

        self.goto_start()

    def goto_start(self):
        self.render_start()
        self.state = self.START_SCREEN

    def goto_gameover(self,result):
        self.render_gameover(result)
        self.state = self.GAME_OVER

    def goto_game(self):
        self.state = self.GAME_PLAY
        self.back.blit(self.desk,(0,0))

    def _title(self,text,y,x=400):
        f = self.title_fnt
        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (x+4,y+4)
        self.back.blit(t,r.topleft)

        t = f.render(text, True, (255,255,0))
        r = t.get_rect()
        r.center = (x,y)
        self.back.blit(t,r.topleft)

    def _text(self,text,y,x=400):
        f = self.text_fnt        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (x+2,y+2)
        self.back.blit(t,r.topleft)
        t = f.render(text, True, (255,255,255))
        r = t.get_rect()
        r.center = (x,y)
        self.back.blit(t,r.topleft)

    def _text2(self,text,y):
        f = self.small_text_fnt        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (400+2,y+2)
        self.back.blit(t,r.topleft)
        t = f.render(text, True, (255,255,255))
        r = t.get_rect()
        r.center = (400,y)
        self.back.blit(t,r.topleft)
                
    def render_start(self):
        self.back.blit(self.desk,(0,0))

        r = self.cards1.get_rect()
        r.center = (400,340-10)
        self.back.blit(self.cards1,r.topleft)

        r = self.cards2.get_rect()
        r.bottomleft = (-30,620)
        self.back.blit(self.cards2,r.topleft)
        
        y = 120-10
        self._title("- Guaduelo -",y); y+=50
        self._text("Pincha en cualquier sitio para comenzar",y)
              
        y = 480
        r = 20
        #self._text2("Coding and graphics by John Eriksson",y); y+=r
        #self._text2("Photos by Jenny Eriksson",y); y+=r
        #self._text2("Testing by Jenny and Pelle Eriksson",y); y+=r
        #self._text2("Toys from Pelle and Rasmus collections",y); y+=r
        #self._text2("Fonts by Simsjeedy and Jakob Fischer",y); y+=r

#.........这里部分代码省略.........
开发者ID:guadalinex,项目名称:guaduelo,代码行数:103,代码来源:gameboard.py

示例2: SidePanel

# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load_font [as 别名]
class SidePanel(object):
    def __init__(self):
        
        self.x = 800
        
        self.loader = Loader()   

        self.fonts = []
        self.fonts.append(self.loader.load_font("scribble.TTF", 38)) 
        self.fonts.append(self.loader.load_font("scribble.TTF", 23)) 
        self.fonts.append(self.loader.load_font("scribble.TTF", 18)) 

        self.side = self.loader.load_image("side.png",True)
        self.back = self.side.copy()
        self.text(0,"Score",30)
        
        self.robot = self.loader.load_image("oliver.png",True)
        self.player1 = self.loader.load_image("julia.png",True)
        self.both = self.loader.load_image("both_win.png",True)
        
        self.signs = {}
        self.signs["1"] = self.loader.load_image("unknown.png",True)
        self.signs["2"] = self.loader.load_image("known.png",True)
        self.signs["11"] = self.loader.load_image("unknown_unknown.png",True)
        self.signs["12"] = self.loader.load_image("unknown_known.png",True)
        self.signs["22"] = self.loader.load_image("known_known.png",True)
                
        self.win = self.loader.load_image("win.png",True)
        self.player1_score = 0
        self.robot_score = 0
        self.games_stat = 0
        self.player_stat = 0
        self.robot_stat = 0
        self.ai_level = 0
        
        self.update_score()
        self.update_stats()
        self.show_player1(False)
        #self.show_robot(False,0,0)
    
    def clear_gfx_area(self):
        r = pygame.Rect(29,185,169,302)
        self.back.blit(self.side,r.topleft,r)
        #pygame.draw.rect(self.back, (0,0,0), r, 1) 
        
    def show_winner(self):
        if self.player1_score > self.robot_score:
            self.show_player1(True)
            return 1
        elif self.player1_score < self.robot_score:
            self.show_robot(True, 0, 0)
            return 2
        else:
            self.show_both()
            return 0

    def show_both(self):
        self.clear_gfx_area()
        
        r = self.player1.get_rect()
        r.center = (90,330)

        self.back.blit(self.both,r.topleft)

    def show_player1(self,win):
        self.clear_gfx_area()
        
        r = self.player1.get_rect()
        r.center = (110,340-10)

        self.back.blit(self.player1,r.topleft)

        if win:
            self.back.blit(self.win,(90,227-10))
            
    def show_player2(self,win):
        self.clear_gfx_area()
        
        r = self.robot.get_rect()
        r.center = (110,340-10)

        self.back.blit(self.robot,r.topleft)

        if win:
            self.back.blit(self.win,(90,227-10))

    def show_robot(self,win,card1,card2):
        self.clear_gfx_area()
        
        r = self.player1.get_rect()
        r.center = (110,340)

        self.back.blit(self.robot,r.topleft)
        
        if card1 and not card2:
            i = self.signs["%d" % card1]                
            r = i.get_rect()
            r.center = (110,255)
            self.back.blit(i,r.topleft)
        elif card1 and card2:
#.........这里部分代码省略.........
开发者ID:gianasista,项目名称:playground,代码行数:103,代码来源:sidepanel.py

示例3: GameBoard

# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load_font [as 别名]
class GameBoard(object):
    def __init__(self):
        self.loader = Loader()
        self.desk = self.loader.load_image("back.png")
        self.back = self.desk.copy()

        self.cards1 = self.loader.load_image("cards1.png",True)
        self.cards2 = self.loader.load_image("cards2.png",True)
        
        self.card_back = self.loader.load_image("card.png",True)
        self.card_mouse_over = self.loader.load_image("card_mouse_over.png", True)
        self.card_images_first = []
        self.card_images_second = []
        for i in range(18):
            self.card_images_first.append(self.loader.load_image("img%d_1.png" % (i+1)))
            self.card_images_second.append(self.loader.load_image("img%d_2.png" % (i+1)))

        self.gfxcards = []
        self.gfxcards_hidden = []
        self.delay = 0

        self.title_fnt = self.loader.load_font("KLEPTOMA.TTF", 60) 
        self.text_fnt = self.loader.load_font("scribble.TTF", 24) 
        self.small_text_fnt = self.loader.load_font("scribble.TTF", 15) 

        self.START_SCREEN = 0
        self.GAME_PLAY = 1
        self.GAME_OVER = 2

        self.card_snd = self.loader.load_sound("card.wav")

        self.goto_start()

    def goto_start(self):
        self.render_start()
        self.state = self.START_SCREEN

    def goto_gameover(self,result):
        self.render_gameover(result)
        self.state = self.GAME_OVER

    def goto_game(self):
        self.state = self.GAME_PLAY
        self.back.blit(self.desk,(0,0))

    def _title(self,text,y,x=400):
        f = self.title_fnt
        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (x+4,y+4)
        self.back.blit(t,r.topleft)

        t = f.render(text, True, (255,255,0))
        r = t.get_rect()
        r.center = (x,y)
        self.back.blit(t,r.topleft)

    def _text(self,text,y,x=400):
        f = self.text_fnt        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (x+2,y+2)
        self.back.blit(t,r.topleft)
        t = f.render(text, True, (255,255,255))
        r = t.get_rect()
        r.center = (x,y)
        self.back.blit(t,r.topleft)

    def _text2(self,text,y):
        f = self.small_text_fnt        
        t = f.render(text, True, (0,0,0))
        r = t.get_rect()
        r.center = (400+2,y+2)
        self.back.blit(t,r.topleft)
        t = f.render(text, True, (255,255,255))
        r = t.get_rect()
        r.center = (400,y)
        self.back.blit(t,r.topleft)
                
    def render_start(self):
        self.back.blit(self.desk,(0,0))

        r = self.cards1.get_rect()
        r.center = (400,340-10)
        self.back.blit(self.cards1,r.topleft)

        r = self.cards2.get_rect()
        r.bottomleft = (-30,620)
        self.back.blit(self.cards2,r.topleft)
        
        y = 120-10
        self._title("- Memory-",y); y+=50
        self._text("Click anywhere to start",y)
              
        y = 480
        r = 20
        self._text2("Persoenliches Memory fuer Julia und Oliver",y); y+=r
        self._text2("fuer Ihre Hochzeit am 15.09.2012",y); y+=r
        
#.........这里部分代码省略.........
开发者ID:gianasista,项目名称:playground,代码行数:103,代码来源:gameboard.py


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