本文整理汇总了Python中pygame.display.set_mode函数的典型用法代码示例。如果您正苦于以下问题:Python set_mode函数的具体用法?Python set_mode怎么用?Python set_mode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_mode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handle_input
def handle_input(self, events):
"""
Handles incoming input events
:param events: input events from the main app
:return:
"""
for event in events:
if event.type == QUIT:
sys.exit(0)
elif event.type == KEYUP:
if event.key == K_UP:
if self.menu_option <= 0:
self.menu_option = len(self.menu_options) - 1
else:
self.menu_option -= 1
elif event.key == K_DOWN:
if self.menu_option >= len(self.menu_options) - 1:
self.menu_option = 0
else:
self.menu_option += 1
elif event.key == K_RETURN:
if self.menu_option == 0:
self.context["gamestate"] = self.prev_state
elif self.menu_option == 1:
self.prev_state.restart_level()
self.context["gamestate"] = self.prev_state
elif self.menu_option == 2:
set_mode((LEVEL_WIDTH, LEVEL_HEIGHT))
self.context["gamestate"] = self.prev_state.prev_state
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
self.context["gamestate"] = self.prev_state
开发者ID:Kranek,项目名称:BlockBuster,代码行数:34,代码来源:GameStatePauseMenu.py
示例2: command_thumbs
def command_thumbs(screen, new_img, file):
normal_cursor()
gl.THUMBING = 1
screen_width = screen.get_width()
if gl.THUMB_VAL.upper() == "AUTO" or gl.USING_THUMB_DEFAULT:
gl.USING_THUMB_DEFAULT = 1
if screen_width == 640:
gl.THUMB_VAL = "85x90"
elif screen_width == 800:
gl.THUMB_VAL = "108x114"
elif screen_width == 1024:
gl.THUMB_VAL = "108x104"
else:
gl.THUMB_VAL = "100x100"
if not gl.TOGGLE_FULLSCREEN_SET:
screen = set_mode(screen.get_size()) # take away resize priviledges
paint_screen(gl.IMGV_COLOR)
set_caption("imgv")
(new_img, new_img, new_img, file) = thumbs_engine(screen, new_img, file)
if not gl.TOGGLE_FULLSCREEN_SET:
screen = set_mode(screen.get_size(), RESIZABLE) # restore resize priviledges
rect = get_center(screen, new_img)
my_update_screen(new_img, rect, file)
normal_cursor()
gl.THUMBING = 0
return (new_img, new_img, new_img, file, rect)
开发者ID:rkulla,项目名称:imgv,代码行数:28,代码来源:thumb.py
示例3: command_fullscreen
def command_fullscreen():
"Toggle between full screen and last screen resolution"
screen = get_surface()
wait_cursor()
if not toggle_fullscreen():
try:
if gl.FULLSCREEN_SPECIAL:
screen_res = screen.get_size()
else:
screen_res = screen.get_size()
gl.MAX_SCREEN_FILES = gl.MAX_SF["%sx%s" % (
screen_res[0], screen_res[1])]
if not gl.TOGGLE_FULLSCREEN_SET: # go into fullscreen mode
gl.BEFORE_WINSIZE = screen.get_size()
screen = set_mode(screen_res, screen.get_flags(
) ^ FULLSCREEN, screen.get_bitsize())
else: # returning from fullscreen. Go back to last screen size:
set_mode(gl.BEFORE_WINSIZE, screen.get_flags(
) ^ FULLSCREEN, screen.get_bitsize())
screen = set_mode(
gl.BEFORE_WINSIZE, RESIZABLE) # make resizeable
my_toggle_fullscreen()
except:
print "Couldn't toggle fullscreen. Resolution probably not supported by your video card."
return screen
开发者ID:rkulla,项目名称:imgv,代码行数:26,代码来源:res.py
示例4: my_slideshow
def my_slideshow(new_img, img, screen, file, num_imgs, rect):
if not gl.TOGGLE_FULLSCREEN_SET:
screen = set_mode(screen.get_size())
set_caption("Slideshow Options - imgv")
speed = get_speed(screen, new_img, rect, gl.files[file], file, num_imgs)
if not speed == -1: # didn't hit Esc from get_speed:
gl.SLIDE_SHOW_RUNNING = 1
disable_screensaver()
dont_call = 0
pygame.event.set_blocked(MOUSEMOTION)
while 1:
event = pygame.event.poll()
pygame.time.wait(1)
check_quit(event)
if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT, K_LCTRL, K_RCTRL, K_p, K_PAUSE, K_TAB, K_SPACE, K_BACKSPACE):
stopped_msg(screen)
my_update_screen(new_img, screen, rect, file, len(gl.files))
file = file - 1
break
if hit_key(event, K_p) or hit_key(event, K_PAUSE):
pause(screen)
my_update_screen(new_img, screen, rect, file, len(gl.files))
if dont_call == 1:
break
if not gl.WRAP_SLIDESHOW:
if file < num_imgs:
(new_img, file, rect, dont_call) = show_slideshow_img(screen, new_img, file, num_imgs, speed)
if gl.WRAP_SLIDESHOW:
if file >= num_imgs:
file = 0
(new_img, file, rect, dont_call) = show_slideshow_img(screen, new_img, file, num_imgs, speed)
pygame.time.delay(5) # don't hog CPU
if not gl.TOGGLE_FULLSCREEN_SET:
screen = set_mode(screen.get_size(), RESIZABLE)
return (new_img, new_img, new_img, file, rect)
开发者ID:paulmadore,项目名称:luckyde,代码行数:35,代码来源:slideshow.py
示例5: build
def build(settings):
pygame.init()
fullscreen = True
if fullscreen:
depth = 0
flags = FULLSCREEN | HWSURFACE | DOUBLEBUF
else:
depth = 16
flags = SWSURFACE | DOUBLEBUF
modes = display.list_modes(depth, flags)
if fullscreen:
if modes == -1: # Welcome to exceptionlessland
raise SystemExit("Failed to initialize display")
else:
mode = max(modes)
else:
mode = (settings.screen_width,settings.screen_height)
display.set_mode(mode, flags)
#print(modes)
#print(mode[0])
#print(mode[1])
return (display.get_surface(),mode[0],mode[1])
开发者ID:TinyFrank,项目名称:FakeIt,代码行数:25,代码来源:display.py
示例6: main
def main():
pygame.init()
display.set_mode((1280, 720), pygame.RESIZABLE)
display.set_caption("Ethos")
display.set_gamma_ramp
game = EthosMain()
game.run()
开发者ID:Berulacks,项目名称:ethosgame,代码行数:7,代码来源:game.py
示例7: 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
示例8: main
def main():
n = 200000
m = 200
print 'How fast can a world with {0} items and {1} creatures run.'.format(n, m)
pygame.init()
game = Game((256,256,128))
user = Player(game.world)
for i in range(n):
game.world.additem(Pickax((randint(0,255),randint(0,255),64),
choice(Metal.__subclasses__()),
choice(Wood.__subclasses__())))
for i in range(m):
game.schedule(Dwarf(user, (randint(0,255),randint(0,255),64)))
display.set_mode((1400,800), HWSURFACE | RESIZABLE)
renderers = [Renderer(game, user, DisplayOptions('FreeMono.ttf', False, 16, 18))]
game_acc = 0
render_acc = 0
last = time()
while renderers:
current = time()
delta = min(0.125, max(0, current - last))
renderer = renderers[-1]
if renderer.game:
game_acc += delta
while game_acc > renderer.game.dt:
renderer.game.step()
game_acc -= renderer.game.dt
rest = renderer.game.dt - game_acc
else:
rest = float('inf')
render_acc += delta
if render_acc > renderer.dt:
child = renderer.step()
if child != renderer:
if child:
renderers.append(child)
else:
renderers = renderers[:-1]
render_acc = 0
last = current
sleep(min(rest, renderers[-1].dt if renderers else 0))
开发者ID:tps12,项目名称:Dorftris,代码行数:56,代码来源:testcreaturesitemsfps.py
示例9: __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
示例10: pattern
def pattern():
display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
display.set_caption('TOUCH-FREE FLAPPY')
myfont = font.Font(FONT, FONT_SIZE)
screen = display.get_surface()
pt = 1
while 1:
i = cam.getImage()
(r,g,b)=i[640,350]
if r>rrm and r<rrx and g>rgm and g<rgx and b>rbm and b<rbx and pt==1:
pt=2
if r>grm and r<grx and g>ggm and g<ggx and b>gbm and b<gbx and pt==2:
pt=3
if r>yrm and r<yrx and g>ygm and g<ygx and b>ybm and b<ybx and pt==3:
main()
开发者ID:abhishek3022,项目名称:Touch-free-flappy-bird-game,代码行数:15,代码来源:main.py
示例11: main
def main():
terminou = False
term.cout (defaultMessageColor, 'Application Started!')
init ()
screen = display.set_mode (windowSize)
snake= Snake(windowSize[0]/2, windowSize[0]/2)
snake.generateFood (1, 1, screen.get_width(), screen.get_height())
core = GameCore (screen)
core.setMainDelay (0.2)
while not terminou:
for ev in event.get ():
if ev.type == QUIT:
terminou = True
break;
elif ev.type == KEYDOWN:
term.cout ('warning', 'Keypressed: ' + str (ev.key))
if ev.key == LEFT or ev.key == RIGHT or ev.key == DOWN or ev.key == UP:
snake.move (ev.key)
core.blitWalls ()
snake.blit (screen)
snake.blitFood (screen)
snake.move (snake.getDirection())
core.flipDisplay ()
开发者ID:chiforimpola,项目名称:GeneralApps,代码行数:27,代码来源:main.py
示例12: start_menu
def start_menu():
from pygame.display import set_mode, list_modes, set_caption
from pygame import init, quit
from pygame.constants import FULLSCREEN
from bin.Controller import process
from obj.Field import Field
init()
screen = set_mode(list_modes()[0], FULLSCREEN)
set_caption("Hero Misadventures")
menu = Menu(("Previous Field", "New Field", "Load Field", "Quit"), screen, surface=color("Lawn Green"),
selection_color=color("Lime Green"), text_color=color("Medium Blue"))
while True:
choose = menu.update()
if choose == 0:
field = Field(screen)
process(screen, field)
elif choose == 1:
from ctypes import cdll
cdll.LoadLibrary("Generator.so").main_generator("res/GENERATOR.HMinf", "res/FIELD.HMmap")
field = Field(screen)
process(screen, field)
elif choose == 2:
from pickle import load
field = load(open("res/SAVE.HMsave", "rb"))
field.screen = screen
process(screen, field)
elif choose == 3:
quit()
return
开发者ID:creators1303,项目名称:Hex_Platform,代码行数:31,代码来源:Interaction.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: __init__
def __init__(self, resolution, world, viewport=None):
pgdisplay.init()
self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF)
# self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF|pg.FULLSCREEN)
pgdisplay.set_caption('PyAudioEffect')
self.world = world
self.viewport = viewport
开发者ID:ZhanruiLiang,项目名称:AudioEffect,代码行数:7,代码来源:display.py
示例15: __init__
def __init__(self, name='demo'):
init()
State.events = EventManager()
State.game = util.load_cfg(name)
State.clock = Clock(10, State.game['frame_rate'])
State.window = display.set_mode(State.game['screen_size'])
self.create_screens()
开发者ID:pombredanne,项目名称:axengine2,代码行数:7,代码来源:engine.py
示例16: 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
示例17: refootprint
def refootprint(self, ev):
# Clear the window
# display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1)
# display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 4)
self.screen = display.set_mode((ev.w, ev.h),
pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF)
global gl
from . import opengl as gl
gl.viewport(0, 0, ev.w, ev.h)
gl.clear(gl.color_buffer_bit)
# Compute a 4:3 viewport
sz = min(ev.w*3, ev.h*4)
self.w = sz // 3
self.h = sz // 4
offx = (ev.w - self.w) // 2
offy = (ev.h - self.h) // 2
gl.viewport(offx, offy, self.w, self.h)
self.basic_shader = build_shader(basic_shader, self.w, self.h)
self.sunlight = gl.sunlightTextures(128, 128, 512)
self.sunlight_dl = self.sunlight[0].displayList(-1, 1, -1, 1)
global shader
shader = self.basic_shader
shader.attach()
shader.seti("tex", 0)
self.backlog_dirty = True
开发者ID:dsp2003,项目名称:e17p,代码行数:25,代码来源:pygame_renderer.py
示例18: __init__
def __init__(self, width, height, images, settings):
"""
- Initialise the screen
- Fill screen with "Cells"
- Convert images to pygame format
- Spawn ants, food sources, obstacles, ant home, etc
"""
self.settings = settings
self.width = width
self.height = height
self.cell_size = settings["cell_size"]
self.images = images
self.canvas = display.set_mode((self.width*self.cell_size, self.height*self.cell_size))
self.convert_images()
self.cells = [[Cell(self, i, j) for j in xrange(height)] for i in xrange(width)]
self.counter = 0
self.ants = {}
self.nests = {}
# self.spawn_worker_ants()
# self.spawn_soldier_ants()
self.create_walls()
for i in xrange(4):
self.spawn_foodsource()
# self.create_home()
self.spawn_colonies(2)
开发者ID:nandakishoremmn,项目名称:ants,代码行数:29,代码来源:world.py
示例19: 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
示例20: admin_menu
def admin_menu():
from pygame.display import set_mode, list_modes, set_caption
from pygame import init, quit
init()
screen = set_mode(list_modes()[0])
set_caption("Hero Misadventures")
menu = Menu(("Debug", "Release"), screen, text_color=color("White"), surface=color("Black"),
selection_color=color("Slate Gray"))
while True:
choose = menu.update()
if choose == -1:
continue
else:
if choose == 0:
from cProfile import runctx
from pstats import Stats
runctx("from bin.Interaction import debug_menu; debug_menu(screen)", {"screen": screen}, {}, "test/profiling.prof")
file = open("test/profiling.txt", "w")
info = Stats("test/profiling.prof", stream=file)
info.strip_dirs().sort_stats("cumulative").print_stats()
elif choose == 1:
quit()
start_menu()
return
开发者ID:creators1303,项目名称:Hex_Platform,代码行数:26,代码来源:Interaction.py
注:本文中的pygame.display.set_mode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论