本文整理汇总了Python中pygame2.sdl.wm.set_caption函数的典型用法代码示例。如果您正苦于以下问题:Python set_caption函数的具体用法?Python set_caption怎么用?Python set_caption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_caption函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: draw_texturedpolygon
def draw_texturedpolygon (screen):
wm.set_caption ("primitives.textured_polygon examples")
tex = image.load_bmp (pygame2.examples.RESOURCES.get ("logo.bmp"))
primitives.textured_polygon (screen, ((4, 40), (280, 7), (40, 220),
(33, 237), (580, 370), (0, 0),
(640, 480)), tex, 10, 30)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:7,代码来源:primitives.py
示例2: run
def run ():
black = pygame2.Color (0, 0, 0)
white = pygame2.Color (255, 255, 255)
green = pygame2.Color (0, 255, 0)
red = pygame2.Color (255, 0, 0)
curcolor = black
pressed = False
lastpos = 0, 0
video.init ()
screen = video.set_mode (640, 480)
screen.fill (white)
screen.flip ()
wm.set_caption ("Mouse demo")
okay = True
while okay:
for ev in event.get ():
if ev.type == sdlconst.QUIT:
okay = False
if ev.type == sdlconst.KEYDOWN and ev.key == sdlconst.K_ESCAPE:
okay = False
if ev.type == sdlconst.MOUSEMOTION:
if pressed:
x, y = ev.pos
lastpos = ev.pos
screen.fill (curcolor, pygame2.Rect (x - 2, y - 2, 5, 5))
screen.flip ()
elif ev.type == sdlconst.MOUSEBUTTONDOWN:
if ev.button == 1:
pressed = True
elif ev.button == 4:
x, y = lastpos[0], lastpos[1] - 2
screen.fill (green, pygame2.Rect (x - 2, y - 2, 5, 5))
lastpos = x, y
screen.flip ()
elif ev.button == 5:
x, y = lastpos[0], lastpos[1] + 2
screen.fill (red, pygame2.Rect (x - 2, y - 2, 5, 5))
lastpos = x, y
screen.flip ()
elif ev.type == sdlconst.MOUSEBUTTONUP:
if ev.button == 1:
pressed = False
elif ev.button == 3:
if curcolor == white:
curcolor = black
screen.fill (white)
else:
curcolor = white
screen.fill (black)
screen.flip ()
video.quit ()
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:56,代码来源:mouse.py
示例3: run
def run ():
video.init ()
freetype.init ()
font = freetype.Font (pygame2.examples.RESOURCES.get ("sans.ttf"))
fpsmanager = sdlgfx.FPSmanager (2)
screen = video.set_mode (640, 480)
wm.set_caption ("FPSmanager example")
screenrect = pygame2.Rect (640, 480)
screen.fill (black)
screen.flip ()
okay = True
while okay:
for ev in event.get ():
if ev.type == sdlconst.QUIT:
okay = False
if ev.type == sdlconst.KEYDOWN:
framerate = fpsmanager.framerate
if ev.key == sdlconst.K_ESCAPE:
okay = False
elif ev.key in (sdlconst.K_PLUS, sdlconst.K_KP_PLUS):
framerate = min (framerate + 1, gfxconst.FPS_UPPER_LIMIT)
fpsmanager.framerate = framerate
elif ev.key in (sdlconst.K_MINUS, sdlconst.K_KP_MINUS):
framerate = max (framerate - 1, gfxconst.FPS_LOWER_LIMIT)
fpsmanager.framerate = framerate
screen.fill (black)
prev = time.time ()
fpsmanager.delay ()
last = time.time ()
millis = ((last - prev) * 1000)
fpstext = "FPS: %d" % fpsmanager.framerate
timetext = "time (ms) passed since last update: %.3f" % millis
surfacef, w, h = font.render (fpstext, white, ptsize=28)
surfacet, w2, h2 = font.render (timetext, white, ptsize=28)
blitrect = pygame2.Rect (w, h)
blitrect.center = screenrect.centerx, screenrect.centery - h
screen.blit (surfacef, blitrect.topleft)
blitrect = pygame2.Rect (w2, h2)
blitrect.center = screenrect.centerx, screenrect.centery + h
screen.blit (surfacet, blitrect.topleft)
screen.flip ()
video.quit ()
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:51,代码来源:fpsmanager.py
示例4: draw_zoomed
def draw_zoomed (screen):
wm.set_caption ("2x zoom")
pxarray = PixelArray (screen)
# Temporary array.
sf = video.Surface (640, 480, 32)
tmparray = PixelArray (sf)
tmparray[::2, ::2] = pxarray[:]
tmparray[1::2, ::2] = pxarray[:-1]
tmparray[:, 1::2] = tmparray[:, :-1:2]
pxarray[:] = tmparray[80:400, 80:320]
del tmparray
del sf
del pxarray
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:15,代码来源:pixelarray.py
示例5: run
def run ():
white = pygame2.Color (255, 255, 255)
black = pygame2.Color (0, 0, 0)
fontmap = [ "0123456789",
"ABCDEFGHIJ",
"KLMNOPQRST",
"UVWXYZ ",
"abcdefghij",
"klmnopqrst",
"uvwxyz ",
",;.:!?-+()" ]
video.init ()
imgfont = image.load_bmp (pygame2.examples.RESOURCES.get ("font.bmp"))
bmpfont = BitmapFont (imgfont, (32, 32), fontmap)
screen = video.set_mode (640, 480)
screen.fill (white)
center = (320 - bmpfont.surface.w / 2, 10)
screen.blit (bmpfont.surface, center)
screen.flip ()
wm.set_caption ("Keyboard demo")
x = 0, 0
pos = (310, 300)
area = pygame2.Rect (300, 290, 50, 50)
okay = True
while okay:
for ev in event.get ():
if ev.type == sdlconst.QUIT:
okay = False
if ev.type == sdlconst.KEYDOWN:
if ev.key == sdlconst.K_ESCAPE:
okay = False
elif bmpfont.contains (ev.unicode):
screen.fill (white)
screen.fill (black, area)
screen.blit (bmpfont.surface, center)
bmpfont.render_on (screen, ev.unicode, pos)
screen.flip ()
video.quit ()
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:46,代码来源:keyboard.py
示例6: test_pygame2_sdl_wm_set_caption
def test_pygame2_sdl_wm_set_caption(self):
# __doc__ (as of 2010-01-13) for pygame2.sdl.wm.set_caption:
# set_caption (str) -> None
#
# Sets the caption of the current SDL window.
# handled in wm_get_caption()
self.assertRaises (pygame2.Error, wm.set_caption, "test", "test")
sf = video.set_mode (10, 10)
self.assertEqual (wm.get_caption (), (None, None))
self.assertTrue (wm.set_caption ("test window") == None)
self.assertEqual (wm.get_caption (), ("test window", None))
self.assertTrue (wm.set_caption ("", "icon") == None)
self.assertEqual (wm.get_caption (), ("", "icon"))
self.assertTrue (wm.set_caption ("test window", "icon") == None)
self.assertEqual (wm.get_caption (), ("test window", "icon"))
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:18,代码来源:sdl_wm_test.py
示例7: test_pygame2_sdl_wm_get_caption
def test_pygame2_sdl_wm_get_caption(self):
# __doc__ (as of 2010-01-13) for pygame2.sdl.wm.get_caption:
# get_caption () -> str
#
# Gets the caption of the current SDL window.
self.assertRaises (pygame2.Error, wm.get_caption)
sf = video.set_mode (10, 10)
self.assertEqual (wm.get_caption (), (None, None))
wm.set_caption ("test window")
self.assertEqual (wm.get_caption (), ("test window", None))
wm.set_caption ("", "icon")
self.assertEqual (wm.get_caption (), ("", "icon"))
wm.set_caption ("test window", "icon")
self.assertEqual (wm.get_caption (), ("test window", "icon"))
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:16,代码来源:sdl_wm_test.py
示例8: draw_checked
def draw_checked (screen):
wm.set_caption ("Manipulating every second pixel in every second row")
pxarray = PixelArray (screen)
pxarray[::2,::2] = white
del pxarray
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:5,代码来源:pixelarray.py
示例9: draw_ellipse
def draw_ellipse (screen):
wm.set_caption ("draw.ellipse examnples")
draw.ellipse (screen, black, pygame2.Rect (20, 20, 100, 100), 4)
draw.ellipse (screen, red, pygame2.Rect (160, 100, 160, 60))
draw.ellipse (screen, green, pygame2.Rect (180, 190, 180, 200))
draw.ellipse (screen, blue, pygame2.Rect (390, 120, 200, 140), 7)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:draw.py
示例10: draw_filledcircle
def draw_filledcircle (screen):
wm.set_caption ("primitives.filled_circle examples")
primitives.filled_circle (screen, (100, 200), 45, black)
primitives.filled_circle (screen, (200, 160), 80, red)
primitives.filled_circle (screen, (370, 210), 100, green)
primitives.filled_circle (screen, (400, 400), 45, blue)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:primitives.py
示例11: run
def run ():
freetype.init ()
video.init ()
sdlmixer.init ()
sdlmixer.open_audio (sdlmixerconst.DEFAULT_FREQUENCY,
sdlmixerconst.DEFAULT_FORMAT,
sdlmixerconst.DEFAULT_CHANNELS,
1024)
print ("Detected decoders: %s" % sdlmixer.get_decoders ())
sound = sdlmixer.Chunk (pygame2.examples.RESOURCES.get ("house_lo.wav"))
channel_sound = sdlmixer.Channel (1)
font = freetype.Font (pygame2.examples.RESOURCES.get ("sans.ttf"))
surfaces = get_help (font)
screen = video.set_mode (640, 480)
wm.set_caption ("SDL_mixer sound example")
screenrect = pygame2.Rect (640, 480)
screen.fill (black)
yoff = 100
for (sf, w, h) in surfaces:
screen.blit (sf, (100, yoff))
yoff += h + 10
screen.flip ()
okay = True
while okay:
for ev in event.get ():
if ev.type == sdlconst.QUIT:
okay = False
if ev.type == sdlconst.KEYDOWN:
# play, pause, resume
if ev.key == sdlconst.K_SPACE:
if channel_sound.paused:
print ("Resuming")
channel_sound.resume ()
elif channel_sound.playing:
print ("Pausing")
channel_sound.pause ()
else:
print ("Starting")
channel_sound.play (sound, -1)
if ev.key == sdlconst.K_ESCAPE:
# exit the application
okay = False
elif ev.key in (sdlconst.K_PLUS, sdlconst.K_KP_PLUS):
# increase volume
channel_sound.volume = min (channel_sound.volume + 1,
sdlmixerconst.MAX_VOLUME)
print ("Volume is now: %d" % channel_sound.volume)
elif ev.key in (sdlconst.K_MINUS, sdlconst.K_KP_MINUS):
# decrease volume
channel_sound.volume = max (channel_sound.volume - 1, 0)
print ("Volume is now: %d" % channel_sound.volume)
screen.flip ()
freetype.quit ()
video.quit ()
sdlmixer.close_audio ()
sdlmixer.quit ()
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:63,代码来源:sound.py
示例12: draw_replaced
def draw_replaced (screen):
wm.set_caption ("Replacing colors")
pxarray = PixelArray (screen)
pxarray.replace (black, white, 0.06)
pxarray.replace (red, green, 0)
del pxarray
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:pixelarray.py
示例13: draw_mixed
def draw_mixed (screen):
wm.set_caption ("Manipulating parts")
pxarray = PixelArray (screen)
pxarray[::2, :120:2] = pxarray[-1, -1]
pxarray[::6, 120::] = red
del pxarray
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:pixelarray.py
示例14: draw_rect
def draw_rect (screen):
wm.set_caption ("draw.rect examples")
draw.rect (screen, black, pygame2.Rect (20, 20, 100, 100))
draw.rect (screen, red, pygame2.Rect (160, 100, 160, 60))
draw.rect (screen, green, pygame2.Rect (180, 190, 180, 200))
draw.rect (screen, blue, pygame2.Rect (390, 120, 200, 140))
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:draw.py
示例15: draw_hline
def draw_hline (screen):
wm.set_caption ("primitives.hline examples")
off = 0
for y in range (0, 480, 4):
primitives.hline (screen, 10, 630, y, colors[off])
off = (off + 1) % 4
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:primitives.py
示例16: draw_filledpolygon
def draw_filledpolygon (screen):
wm.set_caption ("primitives.filled_polygon examples")
primitives.filled_polygon (screen, ((4, 40), (280, 7), (40, 220),
(33, 237), (580, 370),
(0, 0), (640, 480)), black)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:5,代码来源:primitives.py
示例17: draw_aaline
def draw_aaline (screen):
wm.set_caption ("primitives.aaline examples")
primitives.aaline (screen, 4, 40, 17, 320, black)
primitives.aaline (screen, 280, 7, 40, 220, red)
primitives.aaline (screen, 33, 237, 580, 370, green)
primitives.aaline (screen, 0, 0, 640, 480, blue)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:primitives.py
示例18: draw_arc
def draw_arc (screen):
wm.set_caption ("primitives.arc examples")
primitives.arc (screen, (80, 100), 75, 0, 30, black)
primitives.arc (screen, (100, 200), 123, 4, 70, red)
primitives.arc (screen, (300, 300), 78, 200, 30, green)
primitives.arc (screen, (400, 80), 55, 10, 360, blue)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:primitives.py
示例19: draw_rectangle
def draw_rectangle (screen):
wm.set_caption ("primitves.rectangle examples")
primitives.rectangle (screen, pygame2.Rect (20, 20, 100, 100), black)
primitives.rectangle (screen, pygame2.Rect (160, 100, 160, 60), red)
primitives.rectangle (screen, pygame2.Rect (180, 190, 180, 200), green)
primitives.rectangle (screen, pygame2.Rect (390, 120, 200, 140), blue)
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:6,代码来源:primitives.py
示例20: draw_striped
def draw_striped (screen):
wm.set_caption ("Manipulating every third column")
pxarray = PixelArray (screen)
pxarray[::3] = white
del pxarray
开发者ID:gdos,项目名称:pgreloaded.sdl12,代码行数:5,代码来源:pixelarray.py
注:本文中的pygame2.sdl.wm.set_caption函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论