• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python font.init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygame.font.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __init__

    def __init__(self, pygameWindow,gameVariable,images):

        # bool hodnoty
        self.notOver = True
        self.startGame = False
        self.closeGame = False
        self.loadGame = False

        self.gameVariable = gameVariable

        # okno
        self.window = pygameWindow
        self.images = images

        #velkosti

        self.rectWidth = pygameWindow.get_width() / 3
        self.rectHeight = pygameWindow.get_height()  / 10

        self.rectX = (pygameWindow.get_width() / 2) - (self.rectWidth / 2)


        # Rect(top,left, width, height)
        self.nazovHryRect = Rect(0,0,self.window.get_width(),pygameWindow.get_height()/3)
        self.newGameRect = Rect(self.rectX, 150, self.rectWidth, self.rectHeight)
        self.loadGameRect = Rect(self.rectX, 250, self.rectWidth, self.rectHeight)
        self.exitRect = Rect(self.rectX, 350, self.rectWidth, self.rectHeight)

        # font a texty
        font.init()
        self.font = font.SysFont("norasi",int(self.rectHeight/2))

        #iniclializacia lablov
        self._initLabel()
开发者ID:salian2,项目名称:Semestralka-UNIX,代码行数:34,代码来源:Menu.py


示例2: __init__

    def __init__(self, size, tilesize=100, message_font=None, glyph_font=None, margin=50, circle=False, tile_cls=None):
        Board.__init__(self, size, tile_cls)

        font.init()
        message_font      = message_font or (None, 60)
        glyph_font        = glyph_font or (None, 70)
        self.message_font = font.Font(message_font[0], message_font[1])
        self.glyph_font   = font.Font(glyph_font[0], glyph_font[1])
        n                 = tilesize + 1
        self.margin       = margin
        self.scr          = display.set_mode((size[0]*n + margin*2, size[1]*n + margin*2))
        self.scr.fill(white)
        self.sfc = Surface(self.scr.get_size())
        self.sfc = self.sfc.convert()
        self.sfc.fill(white)

        self.scr.blit(self.sfc, (0,0))
        self.tilesize  = tilesize
        self.circle    = circle
        self.tile_locs = [[ (iround(margin+x+tilesize/2) , iround(margin+y+tilesize/2))
                              for x in range(0, size[0]*n, n)]
                              for y in range(0, size[1]*n, n)]
        for tile in self:
            self.mkgui_tile(tile.loc)

        self.scr.blit(self.sfc, (0,0))
        display.flip()
开发者ID:akulakov,项目名称:pygame-games,代码行数:27,代码来源:board.py


示例3: __init__

    def __init__(self, display_w, display_h):
        pygame.init()
        mixer.init()
        font.init()

        # check if the mixer was successfully initialized
        if mixer.get_init() is None:
            print("Failed to initialize the audio mixer module.")

        if font.get_init() is None:
            print("Failed to initialize the font module.")

        self.fps = 120
        self.world = None
        self.gui = Gui(self)

        # Create screen display with 32 bits per pixel, no flags set
        self.display = pygame.display.set_mode((display_w, display_h), pygame.HWSURFACE, 32)
        self.delta_time = 0.0
        self.debug = False
        self.paused = False

        self.print_fps = False

        self.worlds = list()

        self.game = None
开发者ID:Unit978,项目名称:luminescence_standalone,代码行数:27,代码来源:engine.py


示例4: test_font_file_not_found

    def test_font_file_not_found(self):
        # A per BUG reported by Bo Jangeborg on pygame-user mailing list,
        # http://www.mail-archive.com/[email protected]/msg11675.html

        pygame_font.init()
        self.failUnlessRaises(IOError,
                              pygame_font.Font,
                              'some-fictional-font.ttf', 20)
开发者ID:AjithPanneerselvam,项目名称:Gamepy,代码行数:8,代码来源:font_test.py


示例5: __init__

 def __init__(self, text, location, color=(0, 0, 0)):
     if not font.get_init():
         font.init()
     self.fnt = font.Font(ui_enums.DEFAULT_FONT, ui_enums.DEFAULT_FONT_SIZE)
     self.srf = self.fnt.render(text, 1, color)
     self.color = color
     self.location = location
     self.update()
开发者ID:ROBOMonkeys,项目名称:tower-defense-game,代码行数:8,代码来源:interfaces.py


示例6: __init__

    def __init__(self, game):
        self.game = game
        self.viewport = None
        display.init()
        font.init()
        self.fonter = font.SysFont('monospace', 16)

        self.screen = display.set_mode((config.screenW, config.screenH), DOUBLEBUF, 32)
        display.set_caption("Smash the tanks!")
开发者ID:ZhanruiLiang,项目名称:GeoTank,代码行数:9,代码来源:render.py


示例7: defaultbox

def defaultbox(screen, orect, text):

    irect = (tuple(i + BORDERW for i in orect[0]),
             tuple(b - 2 * BORDERW for b in orect[1]))
    fontupleft = tuple(i + 2 for i in irect[0])
    font.init()
    fontobj = font.Font(FONTFILE, FONTSIZE)
    textbox(screen, orect, irect, fontupleft, fontobj, text,
            borderc=BORDERC, boxc=BOXC, textc=TEXTC)
开发者ID:brentnewey,项目名称:Sokoban,代码行数:9,代码来源:inputbox.py


示例8: Init

def Init():
    global font_path
    global basic_font
    global rendered_text
    global huge_font
    font.init()
    basic_font = font.Font(font_path, 32)
    huge_font = font.Font(font_path, 64)
    rendered_text = None
开发者ID:smitnich,项目名称:Crop-Puzzle-Game,代码行数:9,代码来源:TextHandler.py


示例9: main

def main():
    print "#"*31
    print "### Welcome to MindMixer ###"
    print "####### Version 0.1beta #######"
    print """Have a look at the sourcecode!
Change stuff to suit your needs!
The program will hopefully be
self explaining. Hafe fun!"""
    print "#"*31
    selftests()
    global N
    while 1:
        print "(Hint: while training, you can hit SPACE to abort)"
        print "Hit '"+KEYLEFT+"' if the",str(N)+". previous image is identical to the one shown"
        print "Hit '"+KEYRIGHT+"' if the",str(N)+". previous sound is identical to the one heard"
        while 1:
            print "Ready to train with N=%i?" %(N),
            if ask():
                break
            else:
                print "Do you wish to train with N set to a different value? Choosing 'No' exits the program.",
                if ask():
                    n = int(raw_input("Ok, enter the desired value here: "))
                    while n < 1:
                        print "N must be 1 or higher!"
                        n = int(raw_input("Enter a value higher than 1: "))
                    N = n
                else:
                    print "bye"
                    sys.exit(1)
                
        display.init()
        display.set_mode(RESOLUTION, FULLSCREEN)
        font.init()
        mixer.init(44100)
        event.set_grab(True)
        mouse.set_visible(False)
        trials = gentrials()
        for trial in trials:
            if not trial.runtrial():
                break
        display.quit()
        vis = 0.0
        acu = 0.0
        for trial in trials:
            if trial.result[0]:
                vis+=1
            if trial.result[1]:
                acu+=1
        vp = (vis/(MINTRIALS+N))*100
        ap = (acu/(MINTRIALS+N))*100
        message = "percentage in visual modality:%i\npercentage in acoustic modality:%i\n" %(int(vp),int(ap))
        print message
        if vp >= UPPERTH and ap >= UPPERTH:
            N+=1
        elif (vp < LOWERTH or ap < LOWERTH) and N > 1:
            N-=1
开发者ID:sfavors3,项目名称:MindMixer,代码行数:57,代码来源:mindmixer.py


示例10: __init__

	def __init__(self):
		print '%s here' % self.__name__()
		if android:
			android.init()
			android.map_key(android.KEYCODE_MENU, K_ESCAPE)

		init()
		display.set_mode((X_MAX, Y_MAX))

		font.init()

		self.location = Location(self.location_index)
开发者ID:wannadie,项目名称:ideaman,代码行数:12,代码来源:general.py


示例11: __init__

	def __init__( self, screen, message, position, allowed_keys = [], background = (255, 255, 255), text = (255, 0, 0) ):
		pyfont.init()
		self.screen = screen
		self.message = message
		self.position = position
		if allowed_keys:
			self.allowed_keys = allowed_keys
		self.colours = {
			'screen': background,
			'text': text
		}
		self.font = pyfont.Font( None, 36 )
开发者ID:hjpotter92,项目名称:laser-snake,代码行数:12,代码来源:input.py


示例12: __init__

 def __init__(self,service,folder):
   logging.debug('RoomBerry __init__')
   pg.init()
   pg.display.set_caption(CAPTION)
   pg.display.set_mode(SCREEN_SIZE)
   self.__screen = pg.display.get_surface()
   self.__screenRect = self.__screen.get_rect()
   logging.debug('Roomberry __init__ freetype init')
   pgfont.init()
   logging.debug('Roomberry __init__ freetype sysfont')
   logging.debug('Font size')
   # Wish me luck
   self.__roomFolder=service.calendar(folder)
开发者ID:Harlequeen,项目名称:RoomBerry,代码行数:13,代码来源:RoomBerry.py


示例13: __init__

	def __init__(self,string,window):
		font.init()
		self.text = string
        	self.myfont = font.SysFont("Arial", 20)
        	self.render_font = self.myfont.render(string, 1, C.black)
		w = self.render_font.get_width()
		h = self.render_font.get_height()
		self.winh = window.get_height()
		self.rect = Rect(0,self.winh,w,h)
		
		self.movein = False
		self.moveout = False
		self.hold = False
		self.hold_start = 0
开发者ID:kxtells,项目名称:Maze,代码行数:14,代码来源:cMsg.py


示例14: _textDimensions

    def _textDimensions(self, text, size: "points", fontFamily: str) -> (int, int):
        '''Determines the width of rendered text on a specific device. Don't
        call this directly; use a function to normalize Dip and font such that
        no errors would be raised.'''

        # FUTURE: factor in weight

        print("Calculating...")  # DEBUG
        fonts.init()
        font = fonts.SysFont(fontFamily, size)

        width, height = font.size(text)

        return (width, height)
开发者ID:qguv,项目名称:aguille,代码行数:14,代码来源:android.py


示例15: __init__

    def __init__(self, screen, boxw=BOXW, boxh=BOXH, borderw=BORDERW,
                 boxc=BOXC, borderc=BORDERC, textc=TEXTC, fontfile=FONTFILE,
                 fontsize=FONTSIZE, fontspace=FONTSPACE, transtable=None,
                 cb=None, cbargs=None):
        self.__dict__.update(locals())
        self.inupleft = ((screen.get_width() - boxw) / 2,
                         (screen.get_height() - boxh) / 2)
        self.outupleft = tuple(i - borderw for i in self.inupleft)
        self.fontupleft = tuple(i + boxh / 10 for i in self.inupleft)
        self.irect = (self.inupleft, (boxw, boxh))
        self.orect = (self.outupleft,
                      tuple(b + 2 * borderw for b in (boxw, boxh)))

        font.init()
        self.fontobj = font.Font(fontfile, fontsize)
        pygame.key.set_repeat(250, 50)
开发者ID:brentnewey,项目名称:Sokoban,代码行数:16,代码来源:inputbox.py


示例16: __init__

 def __init__(self):
     """
     Initialize the Tic Tac Toe game by initializing the base PygameApp
     class, but with a specific size and title, then override some of
     the default behaviors.
     """
     backgroundsurface = pygame.image.load("./tictactoe/tictactoe.png")
     # call the pygameapp base initializer, using the size of the image
     super(TTTApp, self).__init__(backgroundsurface.get_size(), False, "Tic Tac Toe")
     # initialize the font system
     font.init()
     # now override the background attribute of the application
     self.background = backgroundsurface
     # allow selecting who goes first
     self.gameover = True
     self.endmessage("[H]uman or [C]omputer first?")
     self.awaitingupdate = True
开发者ID:tiggerntatie,项目名称:hhs-cp-site,代码行数:17,代码来源:pygametictactoe.py


示例17: __init__

    def __init__(self):
        display.init()
        font.init()
        mixer.init(buffer=0)
        self.screen_size = [800, 500]
        self.surface = display.set_mode(self.screen_size)

        life_image = image.load(Utils.get_path("image/icon.png")).convert_alpha()
        display.set_icon(life_image)
        display.set_caption("Ping Pong")
        display.set_icon(life_image)

        self.theme_sound = mixer.Sound(Utils.get_path("sound/menu-screen-theme.wav"))
        self.theme_sound.set_volume(0.25)
        if Setting.MUSIC:
            self.theme_sound.play(-1)

        self.switch_screen(Setting.MENU_SCREEN)
开发者ID:kimthuy,项目名称:pingpong,代码行数:18,代码来源:__init__.py


示例18: initWindow

    def initWindow(self, size = None):
        if (size == None):
            self.size = Config.screen_size
        display.init()
        font.init()
        self.screen = display.set_mode(
            self.size,
            flags.FULLSCREEN if Config.fullscreen else flags.RESIZABLE
        )
        display.set_caption(Config.screen_caption)

        #Initializing bachground surface
        self.background = Surface(self.size).convert()
        self.background.fill(Config.background_color)

        #Initializing raycast engine
        self.raycast = Raycast(self.size)

        self.loadTextures()

        self.default_font = font.SysFont('Arial', 15)
开发者ID:grisevg,项目名称:RayCastPy,代码行数:21,代码来源:display.py


示例19: __init__

 def __init__(self, text, loc, color=(0, 0, 0), bg_color=None,
              callback=None, fnt=DEFAULT_FONT, size=DEFAULT_FONT_SIZE,
              bold=False, underline=False, italics=False):
     
     if not font.get_init():
         font.init()
     self.fnt = font.Font(fnt, size)
     
     self.fnt.set_bold(bold)
     self.fnt.set_underline(underline)
     self.fnt.set_italic(italics)
     
     if bg_color is not None:
         self.srf = self.fnt.render(text, 1, color, bg_color)
     else:
         self.srf = self.fnt.render(text, 1, color)
     
     self.width = self.srf.get_width()
     self.height = self.srf.get_height()
     
     self.location = loc
     self.callback = callback
开发者ID:ROBOMonkeys,项目名称:tower-defense-game,代码行数:22,代码来源:button.py


示例20: __init__

    def __init__(self, position, font, text="", textcolor=(0, 0, 255), bgcolor=(0, 0, 0)):
        """A non-user-editable text box for displaying things on screen.
        
        font - a pygame.freetype.Font object. Size, style, text color,
        and rotation may be changed by editing the appropriate member
        variables of the font object

        position - an (x,y) coordinate pair for the top-left corner of
        the text box

        textcolor - the color of the rendered font. An (r,g,b) triple.

        bgcolor - the background color of the rendered font. An
        (r,g,b) triple. The background will be transparent if bgcolor
        is None

        """
        Widget.__init__(self, position)
        ft.init()  # initialize the font module only if we need to
        # multiple initializations are safe
        self.font = font
        self._text = text
        self.textcolor = textcolor
        self.bgcolor = bgcolor
开发者ID:ZSarver,项目名称:neintimes,代码行数:24,代码来源:gui.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python font.render函数代码示例发布时间:2022-05-25
下一篇:
Python font.get_fonts函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap