本文整理汇总了Python中pygame.display.flip函数的典型用法代码示例。如果您正苦于以下问题:Python flip函数的具体用法?Python flip怎么用?Python flip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __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()
开发者ID:elizabeth-matthews,项目名称:atlasChronicle,代码行数:31,代码来源:fractalHandler.py
示例2: render
def render(self):
screen.blit(self.IMAGE, (0, 0))
PDI.flip()
if not PX.music.get_busy():
PX.music.load(SONG0)
PX.music.set_volume(Globals.VOLUME)
PX.music.play(0, 0.0)
开发者ID:rogerzxu,项目名称:OrganDonor,代码行数:7,代码来源:Game_state.py
示例3: draw
def draw(self):
self.background.draw()
self.showText(self.title,
.5, min(.4, self.timeAlive / 4000.0))
if self.timeAlive % 1000 < 650:
self.showText(self.text, .5, .6)
display.flip()
开发者ID:coleary9,项目名称:RockBrawl,代码行数:7,代码来源:title.py
示例4: display_loading_progress
def display_loading_progress(search_term, term_url_count, total_urls, urls_processed, term_count):
percent_complete = (urls_processed/float(total_urls)) * 100
percent_complete = int(percent_complete)
msg = "{}%".format(percent_complete)
loading_font_size = LOADING_FONT.get_ascent()
text = LOADING_FONT.render(msg, 1, (random.randint(0,255), random.randint(0,255), random.randint(0,255)))
x_coord = SCREEN_WIDTH - len(msg) * loading_font_size
y_coord = 0
screen.fill(RGB_BLACK, Rect(x_coord, y_coord, len(msg) * loading_font_size, loading_font_size + TEXT_PADDING))
screen.blit(text, (x_coord, y_coord))
if not DETAILED_PROGRESS:
display.flip()
return
progress_font_size = LOADING_FONT_DETAILED.get_ascent()
y_coord = SCREEN_HEIGHT - progress_font_size - TEXT_PADDING
screen.fill(RGB_BLACK, Rect(0, y_coord, SCREEN_WIDTH, progress_font_size + TEXT_PADDING))
msg = 'Total: {}/{} urls Search Term:"{}":{}/{} urls'.format(urls_processed, total_urls, search_term, term_count, term_url_count)
text = LOADING_FONT_DETAILED.render(msg, 1, FONT_COLOR)
screen.blit(text, (0, y_coord))
display.flip()
开发者ID:fjohnson,项目名称:imageflipper,代码行数:26,代码来源:display.py
示例5: update
def update(self, time):
Globals.WORLD.background(Globals.SCREEN)
Globals.WORLD.dr(Globals.SCREEN)
Globals.WORLD.update(self.npc1)
if self.Timer == 0:
Globals.WORLD.addEntity(self.npc1)
while self.Timer < 150:
key = PG.event.get(PG.KEYDOWN)
for event in key:
if event.type == PG.KEYDOWN:
self.Timer = 181
Globals.WORLD.background(Globals.SCREEN)
Globals.WORLD.dr(Globals.SCREEN)
Globals.WORLD.update(self.npc1)
set_timer = self.Timer % 10
if set_timer == 0:
self.npc1.rect.centery += 4
self.npc1.update_image(self.npc1.image_tracker*4,
self.npc1.change_direction)
self.Timer += 1
PDI.flip()
if self.Timer == 175:
self.npc1.update_image(self.npc1.image_tracker*4+3, True)
Globals.WORLD.addEntity(self.npc2)
if self.Timer == 176:
Dialogue = DB.Dialogue_box('cutscene1_dialogue.txt')
while Dialogue.isOpen:
Dialogue.update()
self.Timer += 1
if self.Timer == 183:
Globals.WORLD.addEntity(self.npc2)
self.npc1.rect.centery += 60
self.npc1.update_image(self.npc1.image_tracker*4+3, True)
self.endScene()
开发者ID:davidmvp,项目名称:cryptography,代码行数:34,代码来源:cutscene1.py
示例6: main
def main(argv=sys.argv[1:]):
pygame.init()
screen = display.set_mode(DISPLAY_SIZE)
ball = image.load('samples/4-2/ball.png')
# 描画座標を保持する変数
x, y = 0, 0
while True:
event_dispatch()
screen.fill((0, 0, 0))
# 右矢印キーの入力状態と左矢印キーの入力状態を見て 1, 0, -1 の値を生成する
dx = get_key_state('right') - get_key_state('left')
# 下矢印キーの入力状態と上矢印キーの入力状態を見て 1, 0, -1 の値を生成する
dy = get_key_state('down') - get_key_state('up')
# キー入力状態から座標を変化させる
x += dx * 5
y += dy * 5
# 変化させた座標に描画する
screen.blit(ball, (x, y))
display.flip()
time.delay(100)
开发者ID:Machi427,项目名称:python,代码行数:29,代码来源:pygame3.py
示例7: runtrial
def runtrial(self):
surface = display.get_surface()
surface.fill((255,255,255))
surface.blit(self.image,TOPLEFT)
display.flip()
self.sound.play()
time.sleep(ST_LENGTH)
surface.blit(self.fill,TOPLEFT)
display.flip()
time.sleep(TB_LENGTH)
keypresses = []
for e in event.get(KEYDOWN):
keypresses += [e.dict['unicode']]
if SPACE in keypresses:
return None
if unicode(KEYLEFT) in keypresses:
if self.trgtimg:
#print "user hit key \""+ KEYLEFT +"\" correctly"
self.result[0] = True
else:
#print "user hit key \""+ KEYLEFT +"\" incorrectly"
self.result[0] = False
if unicode(KEYRIGHT) in keypresses:
if self.trgtsnd:
#print "user hit key \""+ KEYRIGHT +"\" correctly"
self.result[1] = True
else:
#print "user hit key \""+ KEYRIGHT +"\" incorrectly"
self.result[1] = False
return True
开发者ID:sfavors3,项目名称:MindMixer,代码行数:30,代码来源:mindmixer.py
示例8: play_scene
def play_scene(self):
self.screen.blit(self.img, self.origin)
while(self.end_cutscene is False):
PD.flip()
for event in PE.get():
if event.type == PG.KEYDOWN and event.key == PG.K_q:
#skip cutscene
self.end_cutscene = True
return False # end entire cutscene
elif event.type == PG.KEYDOWN and event.key == PG.K_SPACE:
if(len(self.text) > 0 and len(self.textcoords) > 0):
self.screen.blit(self.img, self.origin)
#find better way to clear text, maybe layers?
txt = self.text.pop()
txtcoord = self.textcoords.pop()
self.screen.blit(self.font.render(txt, True,
self.text_color),
txtcoord)
elif(len(self.over_img) > 0):
oimg = self.over_img.pop()
oimgcoord = self.over_imgcoords.pop()
self.screen.blit(oimg, oimgcoord)
else:
self.end_cutscene = True # no more txt or imgs to add
return True # go to next scene
开发者ID:fryingpan,项目名称:Assignment2,代码行数:25,代码来源:Cutscene.py
示例9: run
def run(self):
window = display.get_surface()
for evt in event.get():
if evt.type == pygame.QUIT:
self.quit()
elif evt.type == pygame.MOUSEMOTION:
self.processMouseMotion(evt.pos)
elif evt.type == pygame.KEYDOWN:
self.processKeyDown(evt.key)
elif evt.type == pygame.MOUSEBUTTONDOWN:
self.processMouseButtonDown(evt.pos)
elif evt.type == pygame.MOUSEBUTTONUP:
self.processMouseButtonUp(evt.pos)
window.fill(self.aColor)
# self.testObj.rect.x = self.mouseX
# self.testObj.rect.y = self.mouseY
# self.activeSprites.draw(window)
self.activeState.update(self.Clock.get_time())
self.activeState.activeSprites.draw(window)
if len(self.activeState.pts) > 1:
draw.lines(window, (255, 0, 255), False, self.activeState.pts, 3)
self.Clock.tick(30)
display.flip()
self.run()
开发者ID:Berulacks,项目名称:ethosgame,代码行数:33,代码来源:game.py
示例10: draw
def draw(self):
Constants.SCREEN.fill((0, 0, 0))
font = pygame.font.Font(None, 30)
new_high = font.render("Congratulations! You have a new high score", 1,
(255, 255, 255))
background = pygame.Surface(Constants.SCREEN.get_size())
new_high_rect = new_high.get_rect()
new_high_rect.centerx = background.get_rect().centerx
new_high_rect.centery = 75
Constants.SCREEN.blit(new_high, new_high_rect)
font = pygame.font.Font(None, 30)
presskey = font.render("Please type your name, then hit 'Enter'", 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)
#Print a red rectangle in the middle of the screen
rect = pygame.draw.rect(Constants.SCREEN, (255, 0, 0),
(0, Constants.HEIGHT / 2,
Constants.WIDTH, 30))
if len(self.name) != 0:
name_msg = font.render(string.join(self.name, ""), 1, (0, 0, 0))
name_msg_rect = name_msg.get_rect()
name_msg_rect.center = rect.center
Constants.SCREEN.blit(name_msg, name_msg_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.flip()
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:35,代码来源:NewHigh.py
示例11: run
def run(self):
while self.can_run:
self.check_gamestate()
#want delay for the ideal FPS
lastframedelay = self.fps_clock.tick(GAME_GLOBALS.MAX_FPS)
update_count = lastframedelay + self.cycles_left
if update_count > (GAME_GLOBALS.MAX_FPS * GAME_GLOBALS.UPDATE_INT):
update_count = GAME_GLOBALS.MAX_FPS * GAME_GLOBALS.UPDATE_INT
#Do at least 1 update if for some reason
#the computer is super fast
event = pygame.event.get()
self.check_exit(event)
self.GAME_STATE.update(event)
update_count -= GAME_GLOBALS.UPDATE_INT
if update_count > GAME_GLOBALS.UPDATE_INT:
while update_count > GAME_GLOBALS.UPDATE_INT:
update_count -= GAME_GLOBALS.UPDATE_INT
#Do update stuff
event = pygame.event.get()
self.check_exit(event)
self.GAME_STATE.update(event)
self.cycles_left = update_count
DISP.flip()
if self.exitting:
#TODO: save stuff?
pygame.quit()
sys.exit(0)
else:
#something kicked us out of the event loop but
#the exitting flag is still false
self.can_run = True
开发者ID:ckim89,项目名称:EVE,代码行数:35,代码来源:core.py
示例12: pause
def pause(display):
global main_score
screen = display.get_surface()
hsfont = font.Font(FONT, 100)
ysfont = font.Font(FONT,100)
hs = hsfont.render("HIGH SCORE :-->" + str(highscore/2), True, HIGHSCORE_COLOR)
y_score = ysfont.render("YOUR SCORE :-->"+str(main_score/2), True, Y_SCORE_COLOR)
main_score = 0
#score = 0
pause_img=image.load('pause.png').convert_alpha()
pause_img=transform.scale(pause_img, (1200, 700))
screen.blit(pause_img, (0, 0,))
screen.blit(hs, (200, 60))
screen.blit(y_score, (200, 200))
display.flip()
while True:
for i in event.get():
if i.type == MOUSEBUTTONDOWN or i.type == KEYDOWN:
return main()
开发者ID:abhishek3022,项目名称:Touch-free-flappy-bird-game,代码行数:26,代码来源:main.py
示例13: __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
示例14: update
def update(self):
"""
redraw
"""
self.screen.fill(config.bgcolor)
w2s = self.viewport.world_to_screen
# draw grid for debug
# self.draw_grid()
# draw bodies
# for b in self.world.bodies:
# polygon = []
# fflag = 0
# for node in b.shape.nodes:
# p, flag = w2s(b.coor.apply(mat((node[0], node[1], 0)).T))
# fflag = fflag or flag
# polygon.append(p)
# if fflag:
# pg.draw.polygon(self.screen, b.shape.color, polygon)
# draw points
for point in self.world.points:
p, flag = w2s(point.s.T)
if flag:
pg.draw.circle(self.screen, pg.Color("blue"), vint(p), 2)
# draw joints
jointColor = (0x22, 0xff, 0)
for j in self.world.joints:
p1, flag1 = w2s(j.t1.s.T)
p2, flag2 = w2s(j.t2.s.T)
if flag1 or flag2:
pg.draw.aaline(self.screen, jointColor, vint(p1), vint(p2))
pgdisplay.flip()
开发者ID:ZhanruiLiang,项目名称:AudioEffect,代码行数:35,代码来源:display.py
示例15: endScene
def endScene(self):
fpsClock = PT.Clock()
DURATION = 2000.0
start_time = PT.get_ticks()
ratio = 0.0
while ratio < 1.0:
current_time = PT.get_ticks()
ratio = (current_time - start_time)/DURATION
if ratio > 1.0:
ratio = 1.0
value = int(255*ratio)
fade_color = PC.Color(0, 0, 0, 0)
fade_color.a = value
# PD.rect(Globals.SCREEN, fade_color, (0,0,400,300))
surf = PG.Surface((800, 600))
surf.set_alpha(value)
surf.fill((0, 0, 0))
Globals.SCREEN.blit(surf, (0, 0))
PD.flip()
fpsClock.tick(60)
levelTwoEvents[1] = False
Player.events[4] = False
self.stone_mound = item.Item(54*Setup.PIXEL_SIZE, 26*Setup.PIXEL_SIZE, stone_mound_image)
Globals.WORLD.addEntity(self.stone_mound)
Globals.STATE = LevelTwo()
开发者ID:kzhang12,项目名称:Video-Game-Design,代码行数:25,代码来源:LevelTwo.py
示例16: main
def main(window, handle_events):
## window = Window()
## window.init()
world = World()
world.stage = 1
p1 = Platform(600, 300, 400, 50)
world.add_item(p1)
p2 = Platform(500, 600, 800, 100)
world.add_item(p2)
""" vert order:
0 3
1 2
"""
rest_length, stiffness, damping = 200, 10, 1
spring = Spring(p1, p2, lambda vs: vs[1], lambda vs: vs[0], rest_length, stiffness, damping)
world.add_spring(spring)
spring = Spring(p1, p2, lambda vs: vs[2], lambda vs: vs[3], rest_length, stiffness, damping)
world.add_spring(spring)
spring = Spring(
p1, p2, lambda vs: (vs[1] + vs[3]) / 2, lambda vs: (vs[1] + vs[3]) / 2, rest_length, 10 * stiffness, damping
)
world.add_spring(spring)
font_path = os.path.join(data_dir(), "fonts", "vinque", "vinque.ttf")
fnt = font.Font(font_path, 36)
surface = fnt.render("The adventures of...", True, (255, 255, 255))
word = Word(p2, surface, (200, 50))
world.add_word(word)
fnt = font.Font(font_path, 48)
text = "Woger the wibbly wobbly wombat"
words = [fnt.render(word, True, (255, 255, 255)) for word in text.split()]
word_positions = ((200, 75), (500, 75), (175, 250), (350, 250), (550, 250))
for surface, position in zip(words, word_positions):
word = Word(p1, surface, position)
world.add_word(word)
fnt = font.Font(font_path, 24)
surface = fnt.render("space to continue, use awwow keys in game to weach owanges", True, (0, 0, 0))
word = Word(p2, surface, (40, 550))
world.add_word(word)
render = Render(window, world)
while True:
quit = handle_events(window, world)
if quit:
break
world.update()
render.draw_world()
display.flip()
开发者ID:tartley,项目名称:woger-wombat,代码行数:60,代码来源:main.py
示例17: runloop
def runloop(window, world, render):
clock = pygame.time.Clock()
clock.tick()
FPS = 30
while True:
clock.tick(FPS)
#TODO: hacky hack. This is not very accurate, will do for now.
elapsed_time = 1./FPS
if handle_events(window, world):
# show score outro
break
## return True
Sounds.sounds.update(elapsed_time)
world.update()
render.draw_world()
display.flip()
if world.end_game:
break
#show score
window.sounds.play_music("intro", loop=1)
quit = outro_main(window, handle_events, world.player_character.score)
return quit
开发者ID:mjs,项目名称:ldnpydojo,代码行数:28,代码来源:main.py
示例18: main
def main():
display.init()
maxX,maxY = display.list_modes()[0]
screen = display.set_mode( (maxX/3, maxY/3 ) )
display.flip()
pgw = PygameWidget( )
p = Player( pgw, pipe_desc=Player.test_pipe_desc )
p.play()
clock = pygame.time.Clock()
running = True
while running:
clock.tick( 60 )
for evt in [pygame.event.wait()] + pygame.event.get():
if evt.type == pygame.KEYDOWN:
if p._playing:
p.pause()
else:
p.play()
elif evt.type == pygame.QUIT:
p.stop()
running = False
开发者ID:Lasanha,项目名称:Gambiarra,代码行数:25,代码来源:video.py
示例19: update
def update():
"""
Updates the display by swapping the back buffer and screen buffer.
According to the pygame documentation, the flip should wait for a
vertical retrace when both HWSURFACE and DOUBLEBUF are set on the
surface.
"""
display.flip()
开发者ID:craigthomas,项目名称:Chip8Python,代码行数:8,代码来源:screen.py
示例20: draw
def draw(self):
"""Perform all graphical tasks for this frame."""
self.background.draw()
for i in range(0, len(self.choices)):
self.drawItem(i)
self.drawTitle()
display.flip()
开发者ID:coleary9,项目名称:RockBrawl,代码行数:8,代码来源:menu.py
注:本文中的pygame.display.flip函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论