本文整理汇总了Python中myrmidon.Game.get_entities方法的典型用法代码示例。如果您正苦于以下问题:Python Game.get_entities方法的具体用法?Python Game.get_entities怎么用?Python Game.get_entities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myrmidon.Game
的用法示例。
在下文中一共展示了Game.get_entities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import get_entities [as 别名]
def execute(self, game, x, y, angle_to = 0.0):
self.image = game.graphics['shot']
self.x = x
self.y = y
self.ox = x+random.random()
self.oy = y+random.random()
self.z = 512
self.collision_circle_radius = self.image.width/2
self.age=0
while True:
self.age+=1
xv = self.x-self.ox
yv = self.y-self.oy
self.ox = self.x
self.oy = self.y
self.x+=xv*.98
self.y+=yv*.98+.1
shots = Game.get_entities(Shot)
slen = len(shots)
for ai in range(slen-1):
a=shots[ai]
for bi in range(ai+1, slen):
b=shots[bi]
dvx = a.x-b.x
dvy = a.y-b.y
dist_sqr = dvx**2+dvy**2
rads = a.collision_circle_radius+b.collision_circle_radius
#if Game.collision_circle_to_circle(a,b):
if dist_sqr < rads**2:
td = math.sqrt(dist_sqr)
if td==0:td=0.0001
nx=dvx/td
ny=dvy/td
diffd = td-rads
fx = nx*diffd
fy = ny*diffd
a.x -= fx*.5
a.y -= fy*.5
b.x += fx*.5
b.y += fy*.5
#b.x -= fx
#b.y -= fy
#if self.x < 0 or self.x > Game.screen_resolution[0]-0 or self.y < 0 or self.y > Game.screen_resolution[1]:
if self.y > Game.screen_resolution[1]*.7:
self.y=Game.screen_resolution[1]*.7
if self.x > Game.screen_resolution[0]*.4:
self.x=Game.screen_resolution[0]*.4
if self.x < 20:
self.x=20
if self.age>600:
self.destroy()
yield