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


Python Game.addSprite方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import addSprite [as 别名]
	def __init__( self, pos ):
		super( TinyWorld, self ).__init__( pos, "sprites/worlds/"+str(Game.level)+"/tiny-1.png", 9 )
		Game.addSprite( "tiny-worlds", self )
		
		self.addAnimState( "panic", 0, 3, 12 )
		
		self.setAnimState( "panic" )
开发者ID:laurenceroberts,项目名称:Ludum-Dare-23,代码行数:9,代码来源:World.py

示例2: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import addSprite [as 别名]
	def __init__( self, pos, target ):
		pos[0] -= 0
		pos[1] -= 16
		
		super( PaintSplat, self ).__init__( pos, "sprites/player/paint-splat-"+str(random.randint(1,6))+".png", 8 )
		Game.addSprite( "player-paint", self )
		
		self.addAnimState( "move", 0, 0, 1 )
		self.addAnimState( "splat-idle", 1, 1, 1 )
		self.addAnimState( "splat-drip", 2, 10, 4 )
		
		self.setAnimState( "move" )
		
		self.target = [target[0] - 24, target[1] - 24]
开发者ID:laurenceroberts,项目名称:Ludum-Dare-23,代码行数:16,代码来源:Player.py

示例3: update

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import addSprite [as 别名]
	def update( self, player ):
		if player.move_X != 0:
			if player.pos[0] < Game.screen_move_x or player.pos[0] > Game.screen_width - Game.screen_move_x:
				if player.move_X > 0:
					move_X = self.scroll_adjust
				else:
					move_X = -self.scroll_adjust
				
				if move_X > -1 and move_X < 1:
					self.move_X += move_X
				else:
					self.move_X = move_X
				
				far_left = Game.screen_width + 1
				far_right = -1
				
				for i in range(0, len(self.tiles)):
					if self.tiles[i].pos[0] <  -self.tiles[i].rect.width:
						self.tiles[i].kill( )
						self.tiles[i].remove
					
				if self.move_X <= -1 or self.move_X >= 1:
					for i in range(0, len(self.tiles)):
						self.tiles[i].pos[0] -= int( self.move_X )
						
						if self.tiles[i].pos[0] < far_left:
							far_left = self.tiles[i].pos[0]
						if self.tiles[i].pos[0] > far_right:
							far_right = self.tiles[i].pos[0]
						
					self.move_X = 0
					
					if far_left > 0:
						for y in range(0, self.count_y):
							self.tiles.append( Sprite( [far_left - self.tile.rect.width, Game.screen_height - (y+1)*self.tile.rect.height], self.bgsrc, self.zindex ) )
							Game.addSprite( "background", self.tiles[len(self.tiles)-1] )
					if far_right < Game.screen_width - self.tile.rect.width:
						for y in range(0, self.count_y):
							#print self.bgsrc
							self.tiles.append( Sprite( [far_right + self.tile.rect.width, Game.screen_height - (y+1)*self.tile.rect.height], self.bgsrc, self.zindex ) )
							Game.addSprite( "background", self.tiles[len(self.tiles)-1] )
开发者ID:laurenceroberts,项目名称:Ludum-Dare-23,代码行数:43,代码来源:ParallaxBackground.py

示例4: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import addSprite [as 别名]
	def __init__( self, src, zindex, repeat_y, scroll_adjust ):
		self.tile = Sprite( [0,0], src, zindex )
		self.tiles = []
		
		self.scroll_adjust = float(scroll_adjust)
		self.bgsrc = src
		self.zindex = zindex
		
		count_x = int( math.ceil( float(Game.screen_width) / float(self.tile.rect.width) ) )
		if repeat_y:
			count_y = int( math.ceil( float(Game.screen_height) / float(self.tile.rect.height) ) )
		else:
			count_y = 1
		
		self.count_x = count_x
		self.count_y = count_y
		
		for x in range(0, count_x):
			for y in range(0, count_y):
				self.tiles.append( Sprite( [x*self.tile.rect.width, Game.screen_height - (y+1)*self.tile.rect.height], src, zindex ) )
				Game.addSprite( "background", self.tiles[len(self.tiles)-1] )
开发者ID:laurenceroberts,项目名称:Ludum-Dare-23,代码行数:23,代码来源:ParallaxBackground.py

示例5: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import addSprite [as 别名]
 def __init__(self, pos, src):
     super(Enemy, self).__init__(pos, src, 9)
     Game.addSprite("enemies", self)
开发者ID:laurenceroberts,项目名称:Ludum-Dare-23,代码行数:5,代码来源:Enemy.py


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