本文整理汇总了Python中pygame.sprite.RenderUpdates.empty方法的典型用法代码示例。如果您正苦于以下问题:Python RenderUpdates.empty方法的具体用法?Python RenderUpdates.empty怎么用?Python RenderUpdates.empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.sprite.RenderUpdates
的用法示例。
在下文中一共展示了RenderUpdates.empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WinScreenView
# 需要导入模块: from pygame.sprite import RenderUpdates [as 别名]
# 或者: from pygame.sprite.RenderUpdates import empty [as 别名]
class WinScreenView(View):
def __init__( self, screen, display ):
self.screen = screen
self.screenRect = screen.get_rect()
self.display = display
self.model = None
self.bgImage = load_png( 'bg_winscreen.png' )
self.btnGroup = RenderUpdates()
quitBtn = QuitButton()
quitBtn.rect.bottomleft = self.screenRect.bottomleft
quitBtn.rect.move_ip( 10, -10 )
self.btnGroup.add( quitBtn )
self.quitButton = quitBtn
self.groups = [ self.btnGroup ]
def ModelStarted( self, model ):
View.ModelStarted(self,model)
controller = mvcState.GetController()
controller.mouseListeners.append( self.quitButton )
time = self.model.time/1000
self.timeButton = MoneyWidget( time )
self.timeButton.rect.topleft = (503,112)
self.btnGroup.add( self.timeButton )
money = self.model.money
self.moneyButton = MoneyWidget( money )
self.moneyButton.rect.topleft = (240,180)
self.btnGroup.add( self.moneyButton )
gay = rng.choice( [7, 11, 23, 29, 71, 93] )
self.gayButton = MoneyWidget( gay )
self.gayButton.rect.topleft = (328,432)
self.btnGroup.add( self.gayButton )
def Update( self, timeChange ):
self.btnGroup.update( timeChange )
def Kill( self ):
controller = mvcState.GetController()
controller.mouseListeners.remove( self.quitButton )
self.btnGroup.empty()
def OnUserQuit( self ):
self.Kill()
示例2: Labirinto
# 需要导入模块: from pygame.sprite import RenderUpdates [as 别名]
# 或者: from pygame.sprite.RenderUpdates import empty [as 别名]
class Labirinto( object ):
tipos_mapa = {
CHR_CAMINHO: Caminho,
CHR_PAREDE: Parede,
CHR_ENTRADA: Entrada,
CHR_SAIDA: Saida,
CHR_CAMINHO_ERRADO: CaminhoErrado,
CHR_CAMINHO_PERCORRIDO: CaminhoPercorrido,
CHR_CAMINHO_CERTO: CaminhoCerto,
CHR_VAZIO: Vazio,
}
def __init__( self, tela, descricao_mapa=None ):
self.tela = tela
self.entrada = None
self.saida = None
self.tamanho = None
self.mapa = None
self.tam_peca = None
# grupo que contem objetos nao desenhados
self.nao_desenhados = RenderUpdates()
if descricao_mapa:
self.monta_labirinto( descricao_mapa )
# __init__()
def monta_labirinto( self, descricao_mapa ):
self.__le_mapa( descricao_mapa )
self.__arruma_posicoes()
self.__le_imagens()
# monta_labirinto()
def __le_imagens( self ):
"""Lê as imagens para cada tipo de peça.
Usa-se variavel de classe para evitar que cada objeto tenha uma copia
da mesma imagem, economizando memoria.
"""
t = self.tam_peca
if t is None:
raise Exception( "Você deve usar __arruma_posicoes() primeiro!" )
Quadrado.tamanho = t
# Lê imagens:
Parede.image = desenha_quadrado( t, Color( "gray35" ) )
Caminho.image = desenha_quadrado( t, Color( "wheat" ) )
Entrada.image = desenha_quadrado( t, Color( "magenta" ) )
Saida.image = desenha_quadrado( t, Color( "green" ) )
CaminhoCerto.image = desenha_quadrado( t, Color( "cyan" ) )
CaminhoErrado.image = desenha_quadrado( t, Color( "red" ) )
CaminhoPercorrido.image = desenha_quadrado( t, Color( "yellow" ) )
Vazio.image = pygame.Surface( t )
Vazio.image.set_colorkey( Color( "black" ) )
Vazio.image.fill( Color( "black" ) )
# __le_imagens()
def __le_mapa( self, descricao ):
mapa = []
max_x = 0
tipos_mapa = self.tipos_mapa
# esvazia grupo de sprites nao desenhados
self.nao_desenhados.empty()
Quadrado.grupos = self.nao_desenhados
for i, linha in enumerate( descricao.split( "\n" ) ):
l = []
for j, letra in enumerate( linha ):
tipo = tipos_mapa.get( letra, Vazio )
if tipo == Entrada:
self.entrada = ( i, j )
elif tipo == Saida:
self.saida = ( i, j )
l.append( tipo() )
max_x = max( max_x, j )
mapa.append( l )
max_x += 1
self.mapa = mapa
self.tamanho = ( max_x, i )
# __le_mapa()
def __arruma_posicoes( self ):
if self.mapa is None:
raise Exception( "Você deve usar __le_mapa() primeiro!" )
tw, th = self.tela.get_size()
mw, mh = self.tamanho
w = int( floor( float( tw ) / mw ) )
#.........这里部分代码省略.........
示例3: Game
# 需要导入模块: from pygame.sprite import RenderUpdates [as 别名]
# 或者: from pygame.sprite.RenderUpdates import empty [as 别名]
class Game(object):
title = 'Gravity'
screen_size = 1000, 750
def __init__(self,level=0):
pygame.init()
self.screen = pygame.display.set_mode(self.screen_size)
if self.title:
pygame.display.set_caption(self.title)
self.fps = 30
#group definitions
self.userPlacedObjects = Group()
self.startItems = RenderUpdates()
self.playerGroup = RenderUpdates()
self.tails = RenderUpdates()
self.blackHoles = RenderUpdates()
self.obstacles = RenderUpdates()
self.masslessObstacles = RenderUpdates()
self.goalCollide = Group()
self.toolbar = OrderedUpdates()
#level/transition/player & enemy/obstacle creation hocus pocus
self.goal = Goal(573,372,self.goalCollide,30)
self.bar = ToolBar(0,626,self.toolbar,self.screen,self,self.goal)
self.player = Player(50,535,self.screen,(255,0,0),self.playerGroup,1000,624,(2,-2),self.tails,self)
self.level = level
self.levelUp = True
self.stars = Starfield(self.screen,1000,626,200)
BlackHole(339,70,self.blackHoles,self.screen,80,71,16)
temp = EarthRounder(513,313,self.masslessObstacles,self.screen,40,0)
temp.rotate(55)
temp = Alien(60,188,self.masslessObstacles,self.screen,34,1)
temp.rotate(-15)
temp = Alien(107,268,self.masslessObstacles,self.screen,35,1)
temp.rotate(-75)
temp = Alien(816,533,self.masslessObstacles,self.screen,39,0)
temp.rotate(-13)
temp = BlueUpAnDown(811,227,self.masslessObstacles,self.screen,34,1,97,239)
temp.rotate(80)
self.obstacles.add(self.blackHoles)
self.obstacles.add(self.goalCollide)
self.freeb = False
self.gotoLevel = level
self.loaded = False
if system.thereIsASaveFile() and level == 0:
self.intro_screen = Intro(0,0,self.startItems,str('title_w_file.png'))
self.thereIsAFile = True
elif level == 0:
self.intro_screen = Intro(0,0,self.startItems)
self.thereIsAFile = False
def quit(self):
self.done = True
def level_0(self):
self.clock.tick(self.fps)
pygame.draw.rect(self.screen,(0,0,0),((0,0),(1000,750)))
for evt in pygame.event.get():
if evt.type == QUIT:
self.quit()
if evt.type == KEYDOWN:
if evt.key == K_ESCAPE:
self.quit()
elif evt.key == K_RETURN:
if not self.thereIsAFile:
self.transition = Transition(-1314,0,self.screen,self.startItems)
self.intro_screen.begin()
else:
loadingDial = system.Loading()
pygame.draw.rect(self.screen,(0,0,0),((0,0),(1000,750)))
self.startItems.draw(self.screen)
loadingDial.draw(self.screen)
pygame.display.flip()
self.loadFile(system.loadFile())
elif evt.key == K_RIGHT:
self.intro_screen.instruct(True)
elif evt.key == K_LEFT:
self.intro_screen.instruct(False)
elif evt.key == K_n:
if self.thereIsAFile:
self.transition = Transition(-1314,0,self.screen,self.startItems)
self.intro_screen.begin()
self.transition = Transition(-1314,0,self.screen,self.startItems)
elif evt.key == K_d:
if self.thereIsAFile:
os.remove('save.txt')
self.thereIsAFile = False
self.startItems.empty()
self.intro_screen = Intro(0,0,self.startItems)
if self.intro_screen.next_level():
self.level = 1
#.........这里部分代码省略.........