本文整理汇总了Python中pygame.font.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: renderText
def renderText(text, font, antialias, color, size, autosize, wordwrap):
lines = text.split('\n')
if wordwrap and not autosize:
for i in xrange(len(lines)):
line = lines[i]
del lines[i]
lines[i:i] = wrapText(line, font, size[0]).split('\n')
if len(lines) == 1:
return font.render(text, antialias, color)
else:
lineHeight = font.get_linesize()
height = lineHeight * len(lines)
width = 0
lineSurfs = []
for line in lines:
linesurf = font.render(line, antialias, color)
lineSurfs.append(linesurf)
if linesurf.get_width() > width:
width = linesurf.get_width()
surf = pygame.Surface((width, height), pygame.SRCALPHA)
for i in xrange(len(lineSurfs)):
surf.blit(lineSurfs[i], (0, i * lineHeight))
return surf
开发者ID:249550148,项目名称:mygame,代码行数:26,代码来源:gui.py
示例2: textCrystal
def textCrystal(font, message, bevel=5, fontcolor=(64, 128, 255), contrast=70):
"""Renders text with a 'crystal' style apperance."""
base = font.render(message, 0, fontcolor)
size = base.get_width() + bevel * 2, base.get_height() + bevel * 2 + 2
img = pygame.Surface(size)
# Set background color to be transparent
img.set_colorkey(pygame.Color('black'))
tl = (-1, -1)
tc = (0, -1)
tr = (1, -1)
cr = (1, 0)
br = (1, 1)
bc = (0, 1)
bl = (-1, 1)
cl = (-1, 0)
for x in range(-bevel, 1, 1):
for position in (tl, tr, br, bl, tc, cr, bc, cl):
for location in (tl, tr, br, bl, tc, cr, bc, cl):
shade = ((-location[0]) - location[1]) * contrast
img.blit(font.render(message, 1, shadeColor(fontcolor, shade)),
(bevel + location[0] + (x * position[0]), bevel + location[1] + (x * position[1])))
img.blit(font.render(message, 1, fontcolor), (bevel, bevel))
return img
开发者ID:ankit-kapur,项目名称:turbo-bounce,代码行数:26,代码来源:Crystal_title.py
示例3: __pygame
def __pygame(title, message):
try:
import pygame, pygame.font
pygame.quit() #clean out anything running
pygame.display.init()
pygame.font.init()
screen = pygame.display.set_mode((460, 140))
pygame.display.set_caption(title)
font = pygame.font.Font(None, 18)
foreg = 0, 0, 0
backg = 200, 200, 200
liteg = 255, 255, 255
ok = font.render('Ok', 1, foreg)
screen.fill(backg)
okbox = ok.get_rect().inflate(20, 10)
okbox.centerx = screen.get_rect().centerx
okbox.bottom = screen.get_rect().bottom - 10
screen.fill(liteg, okbox)
screen.blit(ok, okbox.inflate(-20, -10))
pos = [20, 20]
for text in message.split('\n'):
msg = font.render(text, 1, foreg)
screen.blit(msg, pos)
pos[1] += font.get_height()
pygame.display.flip()
while 1:
e = pygame.event.wait()
if (e.type == pygame.QUIT or e.type == pygame.MOUSEBUTTONDOWN or
pygame.KEYDOWN and e.key
in (pygame.K_ESCAPE, pygame.K_SPACE, pygame.K_RETURN)):
break
pygame.quit()
except pygame.error:
raise ImportError
开发者ID:centipeda,项目名称:solarwolf,代码行数:35,代码来源:errorbox.py
示例4: _token_builder
def _token_builder(interpreted_txt):
# build a token from interpreted text
# accepts an interpreted text list
# returns a token object
iswhitespace = _iswhitespace
Token = _Token
links = defaultdict(list)
token_iswhitespace = True
surfs, x, y = [], 0, 0
for (envs, chars) in interpreted_txt:
bkg, color, font = envs["bkg"], envs["color"], envs["font"]
strbuff, surfbuff = [], []
for char in chars:
if not iswhitespace(char):
token_iswhitespace = False
if char == "\n":
char = Surface((0, font.get_linesize()))
if isinstance(char, unicode):
if iswhitespace(char):
char = " "
strbuff.append(char)
elif isinstance(char, str):
if iswhitespace(char):
char = " "
strbuff.append(char)
else:
if strbuff:
surfbuff.append(font.render("".join(strbuff), 1, color, bkg))
surfbuff.append(char)
strbuff = []
if strbuff:
surfbuff.append(font.render("".join(strbuff), 1, color, bkg))
if surfbuff:
# calculate link rects
link = envs["link"]
surfbuff_w = sum(surf.get_width() for surf in surfbuff)
surfbuff_h = max(surf.get_height() for surf in surfbuff)
links[link].append(Rect(x, 0, surfbuff_w, surfbuff_h))
x += surfbuff_w
# extend surfbuff to surfs and reset surfbuff
surfs.extend(surfbuff)
surfbuff = []
# get token width and height
width = sum(surf.get_width() for surf in surfs)
height = max(surf.get_height() for surf in surfs)
# given token height, modify link rect y
for rect in [rect for v in links.values() for rect in v]:
rect.y += height - rect.h
token_str = "".join(unicode(char) for (envs, chars) in interpreted_txt for char in chars)
return Token((width, height), links, surfs, token_iswhitespace, token_str)
开发者ID:LukeMS,项目名称:glyph,代码行数:60,代码来源:glyph.py
示例5: drawTree
def drawTree(tree):
screen = gameglobals.screen
global offset, font, balanceYOffset, graphics
centerX = gameglobals.cameraCenter[0] + offset[0]
centerY = gameglobals.cameraCenter[1] + offset[1]
for edgeLine in tree.edgeLines:
fromPos = [centerX + edgeLine.fromPosition[0],
centerY + edgeLine.fromPosition[1]]
toPos = [centerX + edgeLine.toPosition[0],
centerY + edgeLine.toPosition[1]]
pygame.draw.line(screen, LINE_COLOUR, fromPos, toPos, 3)
drawPos = [0,0] #ignore this statement. I just need a 2-element list.
arrowIndex = None
for nodeCircle in tree.nodeCircles:
balance = tree.balanceOf(nodeCircle)
positionX = centerX + nodeCircle.position[0]
positionY = centerY + nodeCircle.position[1]
if (abs(balance) >= 2):
drawPos[0] = positionX - graphics.nodeGlowHalfSize
drawPos[1] = positionY - graphics.nodeGlowHalfSize
image = graphics.nodeGlow
screen.blit(image, drawPos)
if (abs(balance) > 2):
screen.blit(image, drawPos)
drawPos[0] = positionX - graphics.nodeHalfSize
drawPos[1] = positionY - graphics.nodeHalfSize
if gameglobals.player.isSelected(nodeCircle.index):
image = graphics.node_selected
arrowX = positionX
arrowY = positionY
arrowIndex = nodeCircle.index
else:
image = graphics.node_unselected
screen.blit(image, drawPos)
#pygame.draw.circle(screen, colour, position, nodeCircle.radius)
if (nodeCircle.renderedText == None):
nodeCircle.renderedText = font.render(
str(tree.valueOf(nodeCircle)), True, NODE_TEXT_COLOUR)
drawPos[0] = positionX-nodeCircle.renderedText.get_width()//2
drawPos[1] = positionY-nodeCircle.renderedText.get_height()//2
screen.blit(nodeCircle.renderedText, drawPos)
if (nodeCircle.renderedBalance == None):
nodeCircle.renderedBalance = font.render(str(balance), True, TEXT_COLOUR)
drawPos[0] = positionX-nodeCircle.renderedBalance.get_width()//2
drawPos[1] = positionY-nodeCircle.renderedBalance.get_height()//2 - balanceYOffset
screen.blit(nodeCircle.renderedBalance, drawPos)
if arrowIndex != None:
drawArrow(arrowX, arrowY, arrowIndex)
开发者ID:Ohohcakester,项目名称:Tree-Balance-Game,代码行数:59,代码来源:draw.py
示例6: imgv_button
def imgv_button(screen, msg, x, y, where):
font = pygame.font.Font(gl.FONT_NAME, 10)
if gl.BEING_HOVERED:
ren = font.render(msg, 1, gl.BUTTON_TEXTHOVERCOLOR, gl.BUTTON_HOVERCOLOR)
ren_rect = do_button(screen, ren, where, x, y)
else:
ren = font.render(msg, 1, gl.BUTTON_TEXTCOLOR, gl.BUTTON_BGCOLOR)
ren_rect = do_button(screen, ren, where, x, y)
return ren_rect
开发者ID:paulmadore,项目名称:luckyde,代码行数:9,代码来源:buttons.py
示例7: textOutline
def textOutline(font, message, fontcolor, outlinecolor):
borde = font.render(message, 1, outlinecolor)
base = font.render(message, 1, fontcolor)
img = pygame.Surface( base.get_rect().inflate(2,2).size, 0, base )
for x in 0,2:
for y in 0,2:
img.blit(borde, (x,y) )
img.blit(base, (1, 1))
return img
开发者ID:ricardoquesada,项目名称:unigames,代码行数:9,代码来源:hollow.py
示例8: blitText
def blitText(size,color, text, pos, shaOff = None):
font = pygame.font.Font(FONT_FILENAME, size)
if shaOff != None:
txt = font.render(text, True, (0,0,0))
screen.blit(txt, (pos[0] + shaOff[0],pos[1] + shaOff[1]))
txt = font.render(text, True, color)
screen.blit(txt, pos)
开发者ID:rjzaar,项目名称:Speckpater,代码行数:9,代码来源:base.py
示例9: file_master
def file_master(screen, file_names, place, marker, menu_items, msg, down, button_op):
paint_screen(gl.BLACK)
show_message(msg, down, 10, ("bold", "transparent"))
font = pygame.font.Font(gl.FONT_NAME, 9)
font.set_bold(1)
(esc_rect, esc_font) = close_button(screen)
font_height = font.size(file_names[0])[1]
screen_height = screen.get_height()
name_max = 16
max_file_width = 116
line = 65 # leave room at top of screen for other stuff
col = 5
count = 0
back_rect = forward_rect = sort_rect = junk_rect()
for name in file_names[place:]:
count = count + 1
place = place + 1
marker = marker + 1
if count >= gl.MAX_SCREEN_FILES or place >= len(file_names):
ren_name = os.path.basename(name)
if len(ren_name) > name_max:
ren_name = ren_name[:name_max] + '...' # truncate
if ren_name[-4:] == '....':
ren_name = ren_name[:-1] # 3 .'s are enough
ren = font.render(ren_name, 1, gl.MSG_COLOR, gl.BLACK)
if (place + 1) < len(file_names):
forward_rect = imgv_button(screen, " Next ", 10, 18, "topright")
if (((place + 1) - gl.MAX_SCREEN_FILES) > 1):
back_rect = imgv_button(screen, " Previous ", 10, 18, "topleft")
if not gl.SORT_HIT:
sort_rect = imgv_button(screen, " Sort ", 13, 42, "midtop")
ren_rect = ren.get_rect()
ren_rect[0] = col
ren_rect[1] = line
menu_items.append((ren_rect, name))
screen.blit(ren, ren_rect)
update(ren_rect)
return (file_names, menu_items, 1, place, marker, forward_rect, back_rect, sort_rect)
ren_name = os.path.basename(name)
if len(ren_name) > name_max:
ren_name = ren_name[:name_max] + '...'
if ren_name[-4:] == '....':
ren_name = ren_name[:-1]
ren = font.render(ren_name, 1, gl.MSG_COLOR, gl.BLACK)
ren_rect = ren.get_rect()
ren_rect[0] = col
ren_rect[1] = line
menu_items.append((ren_rect, name))
screen.blit(ren, ren_rect)
line = line + 12
if (line + font_height) >= (screen_height - 15):
line = 65
col = col + max_file_width
update(ren_rect)
return (file_names, menu_items, 0, place, marker, forward_rect, back_rect, sort_rect)
开发者ID:rkulla,项目名称:imgv,代码行数:55,代码来源:file_master.py
示例10: __init__
def __init__(self, text, font, width, fgcolor, bgcolor=None):
self.text = text
self.font = font
self.fgcolor = fgcolor
self.bgcolor = bgcolor
if bgcolor is None:
self.image = font.render(text, 1, fgcolor)
self.shadow = font.render(text, 1, (0, 0, 0))
else:
self.image = font.render(text, 1, fgcolor, bgcolor)
self.shadow = None
开发者ID:seanlynch,项目名称:pythonverse,代码行数:11,代码来源:pvui_pygame.py
示例11: set_text
def set_text(self, text):
self.text = text
font = self.font
font.set_underline(self.underline)
font.set_bold(self.bold)
font.set_italic(self.italic)
# required for font.render to function properly when None is
# given for background
if self.background == None:
self.surface = font.render(text, self.antialias, self.color).convert_alpha()
else:
self.surface = font.render(text, self.antialias, self.color, self.background).convert()
开发者ID:mre521,项目名称:space-travel,代码行数:13,代码来源:screen.py
示例12: display_game_screen
def display_game_screen(difficulty):
"""Displays the playing screen at the beginning of a game"""
global cell_size, field_coord
display_clear()
font = pygame.font.SysFont(POLICE, TXT_SIZE)
# Displaying difficulty
text_diff = font.render("Difficulty: ", 1, (0, 0, 0))
if difficulty == "easy":
text_diff_2 = font.render("Easy", 1, (0, 255, 0))
show_mines_left(NB_MINES_EASY)
cell_size = min(WINDOW_SIZE[0]//FIELD_SIZE_EASY[0], (WINDOW_SIZE[1] - HEADER_SIZE)//FIELD_SIZE_EASY[1])
field_coord = (((WINDOW_SIZE[0] - cell_size * FIELD_SIZE_EASY[0])//2,
(WINDOW_SIZE[1] + HEADER_SIZE - cell_size * FIELD_SIZE_EASY[1])//2),
((WINDOW_SIZE[0] + cell_size * FIELD_SIZE_EASY[0])//2,
(HEADER_SIZE + WINDOW_SIZE[1] + cell_size * FIELD_SIZE_EASY[1])//2))
resize_cell_img()
for x in range(FIELD_SIZE_EASY[0]):
for y in range(FIELD_SIZE_EASY[1]):
WINDOW.blit(cell_img, cell_to_pixel((x, y)))
elif difficulty == "medium":
text_diff_2 = font.render("Medium", 1, (255, 255, 0))
show_mines_left(NB_MINES_MEDIUM)
cell_size = min(WINDOW_SIZE[0]//FIELD_SIZE_MEDIUM[0], (WINDOW_SIZE[1] - HEADER_SIZE)//FIELD_SIZE_MEDIUM[1])
field_coord = (((WINDOW_SIZE[0] - cell_size * FIELD_SIZE_MEDIUM[0])//2,
(WINDOW_SIZE[1] + HEADER_SIZE - cell_size * FIELD_SIZE_MEDIUM[1])//2),
((WINDOW_SIZE[0] + cell_size * FIELD_SIZE_MEDIUM[0])//2,
(HEADER_SIZE + WINDOW_SIZE[1] + cell_size * FIELD_SIZE_MEDIUM[1])//2))
resize_cell_img()
for x in range(FIELD_SIZE_MEDIUM[0]):
for y in range(FIELD_SIZE_MEDIUM[1]):
WINDOW.blit(cell_img, cell_to_pixel((x, y)))
else:
text_diff_2 = font.render("Hard", 1, (255, 0, 0))
show_mines_left(NB_MINES_HARD)
cell_size = min(WINDOW_SIZE[0]//FIELD_SIZE_HARD[0], (WINDOW_SIZE[1] - HEADER_SIZE)//FIELD_SIZE_HARD[1])
field_coord = (((WINDOW_SIZE[0] - cell_size * FIELD_SIZE_HARD[0])//2,
(WINDOW_SIZE[1] + HEADER_SIZE - cell_size * FIELD_SIZE_HARD[1])//2),
((WINDOW_SIZE[0] + cell_size * FIELD_SIZE_HARD[0])//2,
(HEADER_SIZE + WINDOW_SIZE[1] + cell_size * FIELD_SIZE_HARD[1])//2))
resize_cell_img()
for x in range(FIELD_SIZE_HARD[0]):
for y in range(FIELD_SIZE_HARD[1]):
WINDOW.blit(cell_img, cell_to_pixel((x, y)))
WINDOW.blit(text_diff, (10, (HEADER_SIZE - TXT_SIZE)/2))
WINDOW.blit(text_diff_2, (153, (HEADER_SIZE - TXT_SIZE)/2))
pygame.display.flip()
开发者ID:Aegdesil,项目名称:Minesweeper,代码行数:51,代码来源:display.py
示例13: _update
def _update(self, l):
bkg, color, font = self.bkg, self.color, self.font
spacing, dest, rect_w = self.spacing, self._dest, self.rect.w
bkg_img, image = self._image, self.image
lines, txt, wraps = self._lines, self.txt, self._wraps
tokenize = self._tokenize
Line = _Line
tokens = tokenize(txt[wraps[l]:])
dest.y = sum(line.image.get_height() + spacing for line in lines[:l])
wraps = wraps[:l + 1]
k = wraps[-1]
linebuff = []
L = [l] # a list of updated lines
for token in tokens:
if token == '\n':
k += 1 # increment k (so the \n will be on this line)
wraps.append(k)
# a space is the visual representation of the \n character
linebuff.append(' ')
_linebuff = []
elif font.size(''.join(linebuff + [token]))[0] < rect_w:
k += len(token)
linebuff.append(token)
continue
else:
wraps.append(k) # k is the position of the previous space token
k += len(token)
_linebuff = [token]
lines.insert(l + 1, Line(Surface((0, 0)), Rect(0, 0, 0, 0)))
line = font.render(''.join(linebuff), 0, color, bkg)
line = Line(line, Rect(dest.topleft, line.get_size()))
lines[l].clear(image, bkg_img)
lines[l] = line
dest.y += line.image.get_height() + spacing
linebuff = _linebuff
l += 1
L.append(l)
line = font.render(''.join(linebuff), 0, color, bkg)
line = Line(line, Rect(dest.topleft, line.get_size()))
lines[l].clear(image, bkg_img)
lines[l] = line
for line in [lines[l] for l in L]: image.blit(line.image, line.rect)
self._wraps = wraps
开发者ID:maxwellicus,项目名称:KILL-,代码行数:51,代码来源:editor.py
示例14: show
def show(self, SCREEN, posx):
if (self.posicao[0]-posx < 620 and self.posicao[0]-posx > -160):
font = pygame.font.Font("comic.ttf", 25)
self.rect = SCREEN.blit(self.imagem, (self.posicao[0]-posx, self.posicao[1]))
if self.opcoes[0] == True:
texto = font.render("Liga", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 20, self.posicao[1] + 25))
else:
texto = font.render("Desliga", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 4, self.posicao[1] + 25))
font = pygame.font.Font("comic.ttf", 20)
if self.leds[0] == True and self.leds[1] == True and self.leds[2] == True :
texto = font.render("1,2 e 3", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 10, self.posicao[1] + 60))
elif self.leds[0] == True and self.leds[1] == True:
texto = font.render("1 e 2", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 20, self.posicao[1] + 60))
elif self.leds[0] == True and self.leds[2] == True:
texto = font.render("1 e 3", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 33, self.posicao[1] + 60))
elif self.leds[1] == True and self.leds[2] == True:
texto = font.render("2 e 3", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 33, self.posicao[1] + 60))
elif self.leds[0] == True:
texto = font.render("1", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 40, self.posicao[1] + 60))
elif self.leds[1] == True:
texto = font.render("2", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 40, self.posicao[1] + 60))
elif self.leds[2] == True:
texto = font.render("3", True, (0, 0, 0))
SCREEN.blit(texto, (self.posicao[0]-posx + 40, self.posicao[1] + 60))
pygame.draw.line(SCREEN, (0, 0, 0, 0),
(self.posicao[0]-posx + 100, self.posicao[1] + 50),
(self.posicao[0]-posx + 125, self.posicao[1] + 50), 15)
pygame.draw.polygon(SCREEN, (0, 0, 0, 0),
((self.posicao[0]-posx + 125, self.posicao[1] + 25), (self.posicao[0]-posx + 125, self.posicao[1] + 75),
(self.posicao[0]-posx + 150, self.posicao[1] + 50)))
else:
self.rect = 0
pass
开发者ID:zicamc,项目名称:Clube_robotica,代码行数:55,代码来源:caixas.py
示例15: drow
def drow(self):
self.current_stage.draw(screen)
self.active_sprite_list.draw(screen)
self.text = font.render("Total Life : " + str(self.life), True, BLACK)
self.text_rect = self.text.get_rect()
self.text_x = screen.get_width() - self.text_rect.width * 1.2
self.text_y = 20
screen.blit(self.text, [self.text_x, self.text_y])
self.text =font.render("Total Credit: " + str(self.score), True, BLACK)
self.text_rect = self.text.get_rect()
self.text_x = screen.get_width() - self.text_rect.width * 1.2
self.text_y = 50
screen.blit(self.text, [self.text_x, self.text_y])
开发者ID:kikuzhi-seminar,项目名称:botboy-game,代码行数:14,代码来源:botboy.py
示例16: drawUIPanel
def drawUIPanel():
screen = gameglobals.screen
global graphics
size = gameglobals.size
# Draw Frame
drawPos = [0,0]
screen.blit(graphics.uiBar, drawPos)
# Draw Queue
queue = gameglobals.opQueue
operations = queue.nextFewOperations
queueDistance = 60
queueSize = len(operations)
queueLeft = (size[0] - (queueSize-1)*queueDistance)//2
posX = queueLeft
posY = 75
if (queue.renderedText == None):
queue.renderedText = []
for i in range(0, queueSize):
text = font.render(str(operations[i][0]), True, TEXT_COLOUR)
queue.renderedText.append(text)
for i in range (0,queueSize):
text = queue.renderedText[i]
if (operations[i][1] == True): # add
image = graphics.addSquare
else: # delete
image = graphics.deleteSquare
drawPos[0] = posX-graphics.squareHalfSize
drawPos[1] = posY-graphics.squareHalfSize
screen.blit(image, drawPos)
drawPos[0] = posX-text.get_width()//2
drawPos[1] = posY-text.get_height()//2
screen.blit(text, drawPos)
if i == 0:
if graphics.nextText == None:
graphics.nextText = font.render("NEXT", True, TEXT_COLOUR)
drawPos[0] = posX-graphics.nextText.get_width()//2
drawPos[1] = posY-graphics.nextText.get_height()//2+27
screen.blit(graphics.nextText, drawPos)
posX += queueDistance
drawText()
开发者ID:Ohohcakester,项目名称:Tree-Balance-Game,代码行数:49,代码来源:draw.py
示例17: make_planets
def make_planets(self):
font_size = max(8, int(round(self.surface.get_height() * PLANET_FRAC)))
font = pygame.font.Font('ASTRO.TTF', font_size)
planets = []
for char, color in zip(planet_font, planet_color):
planet_surface = font.render(char, True, color)
planet_shadow = font.render(char, True, (0, 0, 0, 96))
surface = pygame.Surface(
(planet_surface.get_width() + 1,
planet_surface.get_height() + 1)).convert_alpha()
surface.fill((0, 0, 0, 0))
surface.blit(planet_shadow, (1, 1))
surface.blit(planet_surface, (0, 0))
planets.append(surface)
self.planets = planets
开发者ID:seanlynch,项目名称:moondial,代码行数:15,代码来源:moondial.py
示例18: display_help_screen
def display_help_screen():
"""Displays the help screen"""
display_clear()
font = pygame.font.SysFont(POLICE, TXT_SIZE)
text_title = font.render("HOW TO PLAY", 1, (0, 0, 0))
text_help = font.render("Left click to reveal a cell.", 1, (0, 0, 0))
text_help_2 = font.render("Right click to flag a cell.", 1, (0, 0, 0))
text_help_3 = font.render("Click to go back.", 1, (0, 0, 0))
WINDOW.blit(text_title, (WINDOW_SIZE[0]//2 - text_title.get_width()//2, TXT_SIZE + 10))
WINDOW.blit(text_help, (10, 2 * TXT_SIZE + 70))
WINDOW.blit(text_help_2, (10, 3 * TXT_SIZE + 130))
WINDOW.blit(text_help_3, (WINDOW_SIZE[0]//2 - text_help_3.get_width()//2, 4 * TXT_SIZE + 240))
pygame.display.flip()
开发者ID:Aegdesil,项目名称:Minesweeper,代码行数:15,代码来源:display.py
示例19: screen
def screen(self,surface,pos,fgcolor=(128,128,125),font=None,interline=0):
fgcolor = [fgcolor]
px,y = pos
mono = True
if not font: font = Text.defaultfont
if font.size('i')!=font.size('x'): mono = False
char_w,char_h = font.size(' ')
char_h += interline
style_cmd = {'+':True,'-':False,'b':font.set_bold,'i':font.set_italic,'u':font.set_underline}
bz = self.baliz
def set_style(pos):
while True:
if bz and pos == bz[0][0]:
_,mode,style,color,value = bz.pop(0)
if mode: style_cmd[style](style_cmd[mode])
elif color:
if value: fgcolor.append(Color(int(value,16)<<8))
else: fgcolor.pop()
else: break
rec = Rect(pos,(0,0))
pos = 0
set_style(pos)
if mono:
for lines in self:
for line in lines:
x = px
for char in line:
rec = rec.unionall([(surface.blit(font.render(char,1,fgcolor[-1]),(x,y))),rec])
x += char_w
pos += 1
set_style(pos)
y += char_h
pos += 1
set_style(pos)
return rec
for lines in self:
for line in lines:
x = px
for char in line:
x = surface.blit(font.render(char,1,fgcolor[-1]),(x,y))
rec = rec.unionall([x,rec])
x = x.right
pos += 1
set_style(pos)
y += char_h
pos += 1
set_style(pos)
return rec
开发者ID:602p,项目名称:spacegame,代码行数:48,代码来源:text.py
示例20: Buyer
def Buyer(game, index, pp):
building_position = game.current_position()
font = pygame.font.Font(None, 30)
textImg = font.render(
" Buy building " + game.at(building_position)[0], 1, (255, 0, 0))
textImg1 = font.render(
" building name is " + game.at(building_position)[1], 1, (255, 0, 0))
catImg1 = pygame.image.load('pictures/bG.jpg')
pp.blit(catImg1, blue_bg)
bg_color = (255, 255, 255)
text_color = (255, 0, 0)
x_position = 120
y_position = 350
text_lenght = 100
x_text_border = 30
y_text_border = 30
Buy = Button()
Buy.create_button(pp, bg_color, x_position, y_position,
text_lenght, x_text_border, y_text_border, 'Buy', text_color)
Auction = Button()
Auction.create_button(pp, bg_color, x_position + 200, y_position,
text_lenght, x_text_border, y_text_border, 'Auction', text_color)
pp.blit(textImg, center) # za da e nai otgore
pp.blit(textImg1, (120, 200)) # za da e nai otgore
pygame.display.update()
mousex = 0
mousey = 0
player_index = game.current_player_index()
time.sleep(2)
for event in pygame.event.get(): # event handling loop
if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
pygame.quit()
sys.exit()
elif event.type == MOUSEMOTION:
mousex, mousey = event.pos
elif event.type == MOUSEBUTTONUP:
mousex, mousey = event.pos
if Buy.pressed([mousex, mousey]):
print('buy')
a = game.buy_building(building_position, 0)
if a:
return 'buy'
if Auction.pressed([mousex, mousey]):
return 'auction'
return 1
开发者ID:kmkirov,项目名称:Monopoly-Standart-,代码行数:48,代码来源:gui_functions.py
注:本文中的pygame.font.render函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论