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


Python Terrain.reset方法代码示例

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


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

示例1: Reset

# 需要导入模块: from terrain import Terrain [as 别名]
# 或者: from terrain.Terrain import reset [as 别名]
def Reset():
    """Reset the library. Useful for re-initializing to a different server."""
    data.reset()
    ApiFunction.reset()
    Element.reset()
    Image.reset()
    Feature.reset()
    Collection.reset()
    ImageCollection.reset()
    FeatureCollection.reset()
    Filter.reset()
    Geometry.reset()
    List.reset()
    Number.reset()
    String.reset()
    Date.reset()
    Dictionary.reset()
    Terrain.reset()
    _ResetGeneratedClasses()
    global Algorithms
    Algorithms = _AlgorithmsContainer()
开发者ID:bevingtona,项目名称:earthengine-api,代码行数:23,代码来源:__init__.py

示例2: Game

# 需要导入模块: from terrain import Terrain [as 别名]
# 或者: from terrain.Terrain import reset [as 别名]
class Game(pyglet.event.EventDispatcher):
	def __init__(self):
		self.window = pyglet.window.Window(fullscreen=True)
		self.terrain = Terrain(self.window.width, self.window.height-100)
		self.players = [
			Player(name, self, i)
			for i, name in enumerate(sys.argv[1:])]
		self.moving = []
		
		# Setup events
		self.window.event(self.on_draw)
		Game.register_event_type('next_player')
		Game.register_event_type('start_moving')
		Game.register_event_type('stop_moving')
		Game.register_event_type('explosion')
		
		# Start the game.
		self.reset()
		
		# Run the fucker
		pyglet.app.run()
	
	def reset(self):
		self.terrain.reset()
		for p in self.players:
			p.reset()
		random.shuffle(self.players)
		
		for p in self.players:
			new_x = None
			while not new_x:
				new_x = int(random.uniform(20, self.window.width - 20))
				for other in self.players:
					if other != p and abs(other.pos[0] - new_x) < 50:
						new_x = None
						break
			p.pos = new_x, self.terrain.flatten(new_x)
		
		self.next_player()
	
	def next_round(self):
		for p in self.players:
			p.next_round()
		self.next_player()
	
	def next_player(self):
		live_players = list(filter(lambda p: p.alive, self.players))
		if len(live_players) < 2:
			for p in live_players:
				p.score += 10000
			self.reset()
			return
		
		for p in live_players:
			if not p.ready:
				p.take_turn()
				return
		self.moving = [
			Shot(p.pos, p.angle, p.power, p)
			for p in self.players
			if p.alive]
		pyglet.clock.schedule(self.move, 1/60)
	
	def move(self, *args, **kwargs):
		for s in self.moving:
			s.move(self)
	
	def explosion(self, x, y, r, player=None):
		self.terrain.explosion(x, y, r)
		for p in self.players:
			p.explosion(x, y, r, player)
	
	def stop_moving(self, thing):
		self.moving.remove(thing)
		if not self.moving:
			pyglet.clock.unschedule(self.move)
			self.next_round()
	
	def start_moving(self, thing):
		self.moving.append(thing)
		
	def on_draw(self):
		self.window.clear()
		self.terrain.draw(self.window.width, self.window.height-100, 100)
		for p in self.players:
			p.draw()
		for m in self.moving:
			m.draw(self.window.height-100)
开发者ID:hartfelt,项目名称:kampvogne,代码行数:90,代码来源:kampvogne.py


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