当前位置: 首页>>代码示例>>Python>>正文


Python sdl2.ext方法代码示例

本文整理汇总了Python中sdl2.ext方法的典型用法代码示例。如果您正苦于以下问题:Python sdl2.ext方法的具体用法?Python sdl2.ext怎么用?Python sdl2.ext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sdl2的用法示例。


在下文中一共展示了sdl2.ext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def __init__(self, model):
		self.model = model
		sdlttf.TTF_Init()
		self.window = sdl2.ext.Window("PyTGM Alpha", size=self.windowsize)
		self.renderer = sdl2.ext.SoftwareSpriteRenderSystem(self.window)
		self.sfactory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)
		self.tspr = self.sfactory.from_color(0x00000000, size=(350, 650),
			masks=(0xff000000,0x00ff0000,0x0000ff00,0x000000ff))
		self.trds = sdl2.ext.Renderer(self.tspr)
		self.trds.blendmode = sdl2.SDL_BLENDMODE_BLEND
		self.tfactory = sdl2.ext.SpriteFactory(sdl2.ext.TEXTURE, renderer = self.trds)
		self.trds.color = sdl2.ext.Color(255,255,255,0)
		self.trds.clear()
		self.loadtexture()
		self.window.show()
		self.render = self.draw() 
开发者ID:ruby3141,项目名称:PyTGM,代码行数:18,代码来源:view.py

示例2: orb_turn

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def orb_turn(self, activity):
        events = sdl2.ext.get_events()
        if events:
            activity.mark(
                l=self,
                s='sdl2 event(s)')
        for event in events:
            if event.type == sdl2.SDL_QUIT:
                raise SolentQuitException()
            elif event.type == sdl2.SDL_KEYDOWN:
                if event.key.keysym.sym == sdl2.SDLK_UP:
                    self.ent_player_b.velocity.vy = -3
                elif event.key.keysym.sym == sdl2.SDLK_DOWN:
                    self.ent_player_b.velocity.vy = 3
                elif event.key.keysym.sym == ord('\\'):
                    raise SolentQuitException()
            elif event.type == sdl2.SDL_KEYUP:
                if event.key.keysym.sym in (sdl2.SDLK_UP, sdl2.SDLK_DOWN):
                    self.ent_player_b.velocity.vy = 0
        self.sdl_world.process() 
开发者ID:solent-eng,项目名称:solent,代码行数:22,代码来源:sdl.py

示例3: draw_lines

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def draw_lines(surface, width, height):
    # Fill the whole surface with a black color.
    sdl2.ext.fill(surface, 0)
    for x in range(15):
        # Create a set of four random points for drawing the line.
        x1, x2 = randint(0, width), randint(0, width)
        y1, y2 = randint(0, height), randint(0, height)
        # Create a random color.
        color = sdl2.ext.Color(randint(0, 255),
                               randint(0, 255),
                               randint(0, 255))
        # Draw the line with the specified color on the surface.
        # We also could create a set of points to be passed to the function
        # in the form
        #
        # line(surface, color, (x1, y1, x2, y2, x3, y3, x4, y4, ...))
        #                       ^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^
        #                         first line     second line
        sdl2.ext.line(surface, color, (x1, y1, x2, y2))


# Draws random, filled rectangles on the passed surface 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:24,代码来源:draw.py

示例4: draw_rects

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def draw_rects(surface, width, height):
    # Fill the whole surface with a black color.
    sdl2.ext.fill(surface, 0)
    for k in range(15):
        # Create a set of four random points for the edges of the rectangle.
        x, y = randint(0, width), randint(0, height)
        w, h = randint(1, width // 2), randint(1, height // 2)
        # Create a random color.
        color = sdl2.ext.Color(randint(0, 255),
                               randint(0, 255),
                               randint(0, 255))
        # Draw the filled rect with the specified color on the surface.
        # We also could create a set of points to be passed to the function
        # in the form
        #
        # fill(surface, color, ((x1, y1, x2, y2), (x3, y3, x4, y4), ...))
        #                        ^^^^^^^^^^^^^^    ^^^^^^^^^^^^^^
        #                          first rect        second rect
        sdl2.ext.fill(surface, color, (x, y, w, h)) 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:21,代码来源:draw.py

示例5: oncheck

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def oncheck(button, event):
    if button.checked:
        color = GREEN
    else:
        color = RED
    if button.factory.sprite_type == sdl2.ext.SOFTWARE:
        sdl2.ext.fill(button.surface, color)
    else:
        # SDL textures do not support color manipulation operation as easy
        # as software surface (since the texture is ideally stored somwhere
        # on the GPU memory in a GPU-specific layout [or not]). To circumvent
        # this, we create a temporary sprite (texture) and exchange the button
        # texture with it.
        tmpsprite = button.factory.from_color(color, button.size)
        button.texture, tmpsprite.texture = tmpsprite.texture, button.texture
        del tmpsprite 
开发者ID:marcusva,项目名称:py-sdl2,代码行数:18,代码来源:gui.py

示例6: handle_events

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def handle_events():
	global CLICKEDBUTTON
	for event in sdl2.ext.get_events():
		if event.type == sdl2.SDL_QUIT:
			shutdown()
		elif event.type == sdl2.SDL_MOUSEBUTTONUP:
			mousex, mousey = event.button.x, event.button.y
			button = getButtonClicked(mousex, mousey)
			if button:
			    CLICKEDBUTTON.append(button)
		elif event.type == sdl2.SDL_KEYDOWN:
			sym = event.key.keysym.sym
			if sym == sdl2.SDLK_ESCAPE:
				shutdown()
			elif sym == sdl2.SDLK_q:
				CLICKEDBUTTON.append(YELLOW)
			elif sym == sdl2.SDLK_w:
				CLICKEDBUTTON.append(BLUE)
			elif sym == sdl2.SDLK_a:
				CLICKEDBUTTON.append(RED)
			elif sym == sdl2.SDLK_s:
				CLICKEDBUTTON.append(GREEN) 
开发者ID:rswinkle,项目名称:inventwithpython_pysdl2,代码行数:24,代码来源:simulate_pysdl2.py

示例7: main

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def main():
	#cause I don't want to pass these around
	global WINDOW, REN, SPRITE_FACTORY, SPRITE_RENDERER

	sdl2.ext.init()

	WINDOW = sdl2.ext.Window("Wormy", size=(WINDOWWIDTH, WINDOWHEIGHT))
	REN = sdl2.ext.Renderer(WINDOW, flags=sdl2.SDL_RENDERER_SOFTWARE)
	WINDOW.show()

	font_file = sysfont.get_font("freesans", sysfont.STYLE_BOLD)
	font_manager = sdl2.ext.FontManager(font_file, size=18)

	#fontmanager=font_manager will be default_args passed to every sprite creation method
	SPRITE_FACTORY = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE, renderer=REN, fontmanager=font_manager, free=True)
	SPRITE_RENDERER = SPRITE_FACTORY.create_sprite_render_system(WINDOW)
	
	showStartScreen()
	while True:
		runGame()
		showGameOverScreen() 
开发者ID:rswinkle,项目名称:inventwithpython_pysdl2,代码行数:23,代码来源:wormy_pysdl2.py

示例8: get_events

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def get_events(self):
        for sdl_event in sdl2.ext.get_events():
            yield to_vulk_event(sdl_event) 
开发者ID:realitix,项目名称:vulk,代码行数:5,代码来源:context.py

示例9: __init__

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def __init__(self):
		sdl2.ext.init()
		self.model = model.Model('', time.time())
		self.view = view.View(self.model)
		self.audio = audio.Audio(self.model)
		self.framerate = 60; 
开发者ID:ruby3141,项目名称:PyTGM,代码行数:8,代码来源:ctrl.py

示例10: draw

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def draw(self):
		stacksprite = self.tspr.subsprite((0, 0, 240, 504))
		stacksprite.x, stacksprite.y = self.origin
		cpiecesprite = self.tspr.subsprite((240, 0, 96, 96))
		nextsprite = self.tspr.subsprite((0,504,288,96))
		nextsprite.x, nextsprite.y = 120,36
		tick = 0
		cp = ['',-1]
		while True:
			yield
			tick += 1
			if cp[0] != [self.model.next[0], self.model.piecepos[2]]:
				self.trds.clear()
				self.drawstack()
				self.drawnext()
				self.drawcpiece()
				self.drawlevel()
				cp = [self.model.next[0], self.model.piecepos[2]]
			cpiecesprite.y, cpiecesprite.x = \
				(20-self.model.piecepos[0])*self.tsize+self.origin[1], \
				self.model.piecepos[1]*self.tsize+self.origin[0]
			self.drawtime(tick)
			sdl2.ext.fill(self.renderer.surface, sdl2.ext.Color(0,0,0))
			self.renderer.render([stacksprite, nextsprite, self.border, self.timertex, 
				self.leveltex, cpiecesprite])
			self.window.refresh() 
开发者ID:ruby3141,项目名称:PyTGM,代码行数:28,代码来源:view.py

示例11: render

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def render(self, components):
        sdl2.ext.fill(self.surface, sdl2.ext.Color(0, 0, 0))
        super(SoftwareRenderer, self).render(components) 
开发者ID:solent-eng,项目名称:solent,代码行数:5,代码来源:sdl.py

示例12: __init__

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def __init__(self, minx, miny, maxx, maxy):
        super(MovementSystem, self).__init__()
        self.componenttypes = Velocity, sdl2.ext.Sprite
        self.minx = minx
        self.miny = miny
        self.maxx = maxx
        self.maxy = maxy 
开发者ID:solent-eng,项目名称:solent,代码行数:9,代码来源:sdl.py

示例13: orb_close

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def orb_close(self):
        sdl2.ext.quit()
    # 
开发者ID:solent-eng,项目名称:solent,代码行数:5,代码来源:sdl.py

示例14: render

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def render(self, components):
        sdl2.ext.fill(self.surface, sdl2.ext.Color(255,255,255))

        # self.grid.plot(self.surface)

        for l in self.lines:
            l.plot(self.surface, self.grid)

        super(Renderer, self).render(components) 
开发者ID:udiboy1209,项目名称:fractal-creator,代码行数:11,代码来源:renderer.py

示例15: __init__

# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import ext [as 别名]
def __init__(self, title="Fractal App"):
        sdl2.ext.init()
        self.window = sdl2.ext.Window(title, size=(800, 600))
        self.world = sdl2.ext.World()
        self.renderer = Renderer(self.window)
        self.world.add_system(self.renderer) 
开发者ID:udiboy1209,项目名称:fractal-creator,代码行数:8,代码来源:__init__.py


注:本文中的sdl2.ext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。