本文整理汇总了Python中pygame.display.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
rect = Rect((0, 0), SCREEN_SIZE)
surface = Surface(SCREEN_SIZE)
pxarray = PixelArray(surface)
P = [(0, 100), (100, 0), (200, 0), (300, 100), (400, 200), (500, 200),
(600, 100), (400, 400), (700, 50), (800, 200)]
n = len(P) - 1 # n = len(P) - 1; (P[0], ... P[n])
k = 3 # degree of curve
m = n + k + 1 # property of b-splines: m = n + k + 1
_t = 1 / (m - k * 2) # t between clamped ends will be evenly spaced
# clamp ends and get the t between them
t = k * [0] + [t_ * _t for t_ in xrange(m - (k * 2) + 1)] + [1] * k
S = Bspline(P, t, k)
# insert a knot (just to demonstrate the algorithm is working)
S.insert(0.9)
step_size = 1 / STEP_N
for i in xrange(STEP_N):
t_ = i * step_size
try: x, y = S(t_)
# if curve not defined here (t_ is out of domain): skip
except AssertionError: continue
x, y = int(x), int(y)
pxarray[x][y] = (255, 0, 0)
del pxarray
for p in zip(S.X, S.Y): draw.circle(surface, (0, 255, 0), p, 3, 0)
SCREEN.blit(surface, (0, 0))
while 1:
for ev in event.get():
if ev.type == KEYDOWN:
if ev.key == K_q: exit()
display.update()
示例2: do_button
def do_button(screen, ren, where, x, y):
ren_rect = ren.get_rect().inflate(20, 10)
if where == "topleft":
ren_rect.topleft = screen.get_rect().topleft
if x != None:
ren_rect[0] = x
if y != None:
ren_rect[1] = y
if where == "midtop":
ren_rect.midtop = screen.get_rect().midtop
if y != None:
ren_rect[1] = y
if where == "topright":
ren_rect.topright = screen.get_rect().topright
if x != None:
ren_rect[0] = ren_rect[0] - x
if y != None:
ren_rect[1] = y
if where == None:
if x != None:
ren_rect[0] = x
if y != None:
ren_rect[1] = ren_rect[1] + y
screen.blit(ren, ren_rect.inflate(-20, -10))
update(ren_rect)
return ren_rect
示例3: paint_screen
def paint_screen(screen, color, *rect):
if not rect:
screen.fill(color)
update()
else:
screen.fill(color, rect)
update(rect)
示例4: draw
def draw(self):
if self.drawn is False:
Constants.SCREEN.fill((0, 0, 0))
game_ended = self.title_font.render(self.dis_text, 1,
(255, 255, 255))
background = pygame.Surface(Constants.SCREEN.get_size())
game_ended_rect = game_ended.get_rect()
game_ended_rect.center = background.get_rect().center
Constants.SCREEN.blit(game_ended, game_ended_rect)
# Center our 'Press any key text'
font = pygame.font.Font(None, 30)
presskey = font.render("Press the ESC key to quit, or (m) "
"to go back to the Menu", 1,
(255, 255, 255))
background = pygame.Surface(Constants.SCREEN.get_size())
presskeyrect = presskey.get_rect()
presskeyrect.centerx = background.get_rect().centerx
presskeyrect.y = Constants.HEIGHT - 40
Constants.SCREEN.blit(presskey, presskeyrect)
alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
alphaSurface.fill((0,0,0))
alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
Constants.SCREEN.blit(alphaSurface,(0,0))
display.update()
self.drawn = True
else:
pass
示例5: square_four
def square_four(screen, file):
wait_cursor()
draw_lines(screen)
num_imgs = len(gl.files)
if file >= num_imgs or file <= 0:
file = 0
img_four_name = gl.files[file]
img_four_file = file
img_four = load_img(img_four_name, screen, 0)
file = file + 1
img_four = adjust_img_size(img_four, screen.get_width(), screen.get_height())
img_four_rect = img_four.get_rect()
img_four_rect[0] = (screen.get_width() / 2)
img_four_rect[1] = (screen.get_height() / 2)
screen.blit(img_four, img_four_rect)
update(img_four_rect)
draw_lines(screen)
if gl.FOUR_STATUS_BARS:
font_size = 9
font = pygame.font.Font(gl.FONT_NAME, font_size)
name = os.path.basename(img_four_name)
name = check_truncate(screen.get_width(), name)
img_status = "%s [%d/%d]" % (name, img_four_file + 1, num_imgs)
raise_up = 12
show_message(screen, img_status, ((screen.get_width() / 2) + (screen.get_width() / 4 - font.size(img_status)[0]/2), screen.get_height() - raise_up), font_size, ("bold"))
normal_cursor()
return (file, img_four_rect, img_four_name, img_four_file)
示例6: __draw
def __draw(self):
self.__gen.draw(self.__canvas)
if self.__mouseDown:
diffX = self.__mouseCurrPos[0] - self.__mouseDownPos[0]
diffY = self.__mouseCurrPos[1] - self.__mouseDownPos[1]
if diffX > 0 and diffY > 0:
sizeX = max([diffX, diffY])
sizeY = sizeX
elif diffX > 0:
sizeX = max([abs(diffX), abs(diffY)])
sizeY = -sizeX
elif diffY > 0:
sizeY = max([abs(diffX), abs(diffY)])
sizeX = -sizeY
else:
sizeX = min([diffX, diffY])
sizeY = sizeX
self.__drawSize = (sizeX, sizeY)
pygame.draw.rect(self.__canvas, self.__highlightColor,
Rect(self.__mouseDownPos, self.__drawSize), 1)
display.flip()
display.update()
示例7: update_display
def update_display(update_queue):
"""(deque) -> NoneType
Updates the display with Rect's given in update_queue, and clears update_queue. Specifically, for each such Rect,
updates the display/screen only within that Rect."""
display.update(update_queue)
update_queue.clear()
示例8: start_editor
def start_editor(self):
glyph = self.editor_info
glyph_rect = glyph.rect
glyph.input(PAGES['editor'])
glyph.update()
editor = self.editor
editor_rect = editor.rect
SCREEN.blit(EDITOR_BKGSCREEN, (0, 0))
SCREEN.blit(glyph.image, glyph_rect)
SCREEN.blit(editor.image, editor_rect)
editor_focus = False
while 1:
mouse_pos = mouse.get_pos()
link = glyph.get_collisions(mouse_pos)
if link: mouse.set_cursor(*HAND_CURSOR)
else: mouse.set_cursor(*DEFAULT_CURSOR)
for ev in event.get():
if ev.type == MOUSEBUTTONDOWN:
if link: pass
if editor.rect.collidepoint(mouse_pos): editor_focus = True
else: editor_focus = False
if ev.type == KEYDOWN:
if ev.key == K_ESCAPE: exit()
if editor_focus == True: editor.input(ev)
cursor = editor.get_cursor()
editor.image.fill((255, 205, 0), cursor)
SCREEN.blit(editor.image, editor_rect)
display.update()
示例9: recoil
def recoil(attack, defend, move, me):
"""
function
"""
crit, type_, dmg = attack.calc_dmg(defend, move)
ret1 = dmg_pkmn(defend, dmg, me)
if dmg:
meth = getattr(
pokepong.move_sandbox, 'do_' + move.name.lower().replace(' ', '_').replace('-', '_'))
meth(attack, defend, me)
if crit:
display.update(write_btm('Critical Hit!'))
sleep(1)
if type_ > 1:
display.update(write_btm("It's Super Effective!"))
sleep(1)
elif 0 < type_ < 1:
display.update(write_btm("It wasn't", "very effective!"))
sleep(1)
elif type_ == 0:
display.update(write_btm("It had no effect"))
sleep(1)
ret2 = dmg_pkmn(attack, dmg / 4, not me)
if ret2:
display.update(write_btm(attack.name + ' was', 'hit with recoil!'))
if ret1 and ret2:
return 3
elif ret1:
return 1
elif ret2:
return 2
else:
return 0
示例10: print_version
def print_version(screen, screen_height):
imgvlogo = load_img(gl.IMGV_LOGO_SMALL, screen, False)
imgvlogo_rect = imgvlogo.get_rect()
imgvlogo_rect[0] = 5
imgvlogo_rect[1] = screen_height - 50
screen.blit(imgvlogo, imgvlogo_rect)
update(imgvlogo_rect)
msg = "Version %s" % gl.IMGV_VERSION
msg_font = pygame.font.Font(gl.FONT_NAME, 11)
msg_font.set_bold(1)
char = 0
i = 0
pygame.event.set_blocked(MOUSEMOTION)
while 1:
event = pygame.event.poll()
pygame.time.wait(1)
check_quit(event)
if char < len(msg):
if msg[char] != ' ': # don't delay on spaces
pygame.time.delay(75)
ren = msg_font.render(msg[char], 1, gl.RED) # one char at a time
ren_rect = ren.get_rect()
# center it
ren_rect[0] += (i + 7)
ren_rect[1] = screen_height - 15
screen.blit(ren, ren_rect)
i += ren.get_width() # make letters space evenly
char += 1
update(ren_rect)
else:
break
示例11: draw
def draw(self):
"""Draw all of the objects to the screen."""
# Update all scene layers to the screen.
self.all.update()
self.dirty_rects = self.all.draw(self.screen)
display.update(self.dirty_rects)
示例12: draw
def draw(self):
if self.timer >= GameIntro.delay:
self.timer = 0
if self.current_display == 2:
# Constants.Levels = []
# Constants.Levels.append(None)
# Constants.Levels.append(None)
# Constants.Levels[0] = Level_1.Level_1()
Constants.PLAY = Play()
Constants.STATE = Constants.PLAY
#Constants.STATE = Play()
Constants.STATE.set_level(0)
else:
self.current_display += 1
Constants.SCREEN.fill(pygame.Color("black"))
Constants.SCREEN.blit(GameIntro.images[self.current_display],
self.rect)
alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
alphaSurface.fill((0,0,0))
alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
Constants.SCREEN.blit(alphaSurface,(0,0))
display.update()
else:
pass
示例13: draw
def draw(self):
Constants.SCREEN.fill((0, 0, 0))
Constants.SCREEN.blit(Volume.image,
Volume.image.get_rect(center=(Constants.WIDTH / 2, Constants.HEIGHT / 2)))
Constants.SCREEN.blit(self.text, self.text_rect)
Constants.SCREEN.blit(self.speedometer.image, self.speedometer.rect)
display.update()
示例14: draw
def draw(self):
#Animate the car until we want a 'trail' of fire
if self.steps * self.speed <= Constants.WIDTH:
Constants.SCREEN.fill((0, 0, 0))
#Center our 'Press any key text'
font = pygame.font.Font(None, 30)
presskey = font.render("Press any key to continue to the Menu", 1,
(255, 255, 255))
background = pygame.Surface(Constants.SCREEN.get_size())
presskeyrect = presskey.get_rect()
presskeyrect.centerx = background.get_rect().centerx
presskeyrect.y = Constants.HEIGHT - 40
Constants.SCREEN.blit(presskey, presskeyrect)
#Move the car until it's off the screen
if self.rect.left <= Constants.WIDTH:
self.rect.midright = (self.steps * self.speed, Constants.HEIGHT
/ 2)
Constants.SCREEN.blit(self.image, self.rect)
#Once it's off the screen, show our ActionRPM text
else:
label = self.font.render("ActionRPM", 1, (0, 0, 0))
Constants.SCREEN.blit(label, (Constants.WIDTH / 3.5,
Constants.HEIGHT / 3))
alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
alphaSurface.fill((0,0,0))
alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
Constants.SCREEN.blit(alphaSurface,(0,0))
display.update()
示例15: dmg_pkmn
def dmg_pkmn(pkmn, dmg, me):
"""
function
"""
if pkmn.substitute == 0:
if pkmn.bide:
pkmn.bidedmg += dmg * 2
if dmg > 0:
for d in range(dmg):
if pkmn.hp <= 0:
return 1
pkmn.sethp(pkmn.hp - 1)
if not me:
display.update(draw_my_hp(pkmn))
else:
display.update(draw_opp_hp(pkmn))
sleep(.02)
else:
for d in range(0, dmg, -1):
if pkmn.maxhp == pkmn.hp:
break
pkmn.sethp(pkmn.hp + 1)
if not me:
display.update(draw_my_hp(pkmn))
else:
display.update(draw_opp_hp(pkmn))
sleep(.02)
return 0
else:
pkmn.substitute -= dmg
if pkmn.substitute < 1:
pkmn.substitute = 0
display.update(write_btm('The substitute broke'))
sleep(1)