本文整理汇总了Python中Entity.Entity.update方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.update方法的具体用法?Python Entity.update怎么用?Python Entity.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity.Entity
的用法示例。
在下文中一共展示了Entity.update方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(*args):
self = args[0]
width = args[1]
height = args[2]
Entity.update(self, width, height)
self.animate()
self.changed = False
示例2: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self,t=0):
Entity.update(self,t)
#print t, self.rect.topleft, self._speed
if self.jumping:
# if the jumping flag is true,
# call the jump function
self.setSpeed('x',-14.0)
self.jumping = False
else:
self.setSpeed('x',self._speed[1]+t/50.0)
if self.rect.top >= 230: # if you hit the top, reset the vel so it
self.setSpeed('x',0.0) # doesn't get stuck up at the top
# limit duration of post damage invincibility (2500 ms)
if self._invincible_time > 0:
self._invincible_time -= t
# On average, turn invisible for every other frame
if ((self._invincible_time /100)%2) == 0:
self.image = self._invisible_pic
else:
self.image = self._images[0]
if self.rect.left < 0:
self.rect.left = 0
elif self.rect.right > 930:
self.rect.right = 930
示例3: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self,t=0):
Entity.update(self,t)
#print t, self.rect.topleft, self._speed
if self.jumping:
# if the jumping flag is true,
# call the jump function
self.setSpeed('x',-14.0)
self.jumping = False
else:
self.can_jump = True
self.setSpeed('x',self._speed[1]+t/50.0)
if self.rect.top >= 230:
self.setSpeed('x',0.0)
# limit duration of post damage invincibility (2500 ms)
if self._invincible == True:
if self._invincible_time < 2500:
self._invincible_time += t
if ((self._invincible_time /100)%2) == 0:
self.image = self._invisible_pic
else:
self.image = self._images[0]
else:
self._invincible = False
self._invincible_time = 0
示例4: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self,t=0):
Entity.update(self,t)
if self.rect.right < 0:
self._wrap_count += 2
self.rect.left = 1024
self.rect.top = 300*random()
self.setSpeed(-8.0*random()-10.0-self._wrap_count*random(),0.0)
print self._speed
示例5: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, world):
if self.impactDestroy:
collisions = Entity.update(self, world)
for i in collisions:
if i:
world.projectiles.remove(self)
return collisions
else:
return Entity.update(self, world)
示例6: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, session):
if self.impactDestroy:
collisions = Entity.update(self, session.worlds[session.activeWorld])
for i in collisions:
if i:
session.worlds[session.activeWorld].projectiles.remove(self)
return collisions
else:
return Entity.update(self, session.worlds[session.activeWorld])
示例7: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, world):
Entity.update(self, world)
for p in world.players:
if self.rect.colliderect(p.rect):
p.weapon = self.contents
newWep = random.choice(const.weapons)
while newWep == p.weapon:
newWep = random.choice(const.weapons)
self.contents = newWep
self.momentum = [0,0]
##########################################
self.rect.topleft = [500,200]
示例8: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, session):
Entity.update(self, session.worlds[session.activeWorld])
for p in session.worlds[session.activeWorld].players:
if self.rect.colliderect(p.rect):
p.weapon = self.contents
newWep = random.choice(const.weapons)
while newWep == p.weapon:
newWep = random.choice(const.weapons)
self.contents = newWep
self.momentum = [0,0]
zone = random.choice(session.worlds[session.activeWorld].crateSpawnZones)
x = random.randint(zone[0], zone[1])
y = random.randint(zone[2], zone[3])
self.rect.center = [x,y]
示例9: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, world):
#Check if colliding with a projectile ie has been hit, and deals damage accordingly
for proj in world.projectiles:
if self.rect.colliderect(proj.rect):
proj.hitEnemy(world)
world.projectiles.remove(proj)
self.health -= proj.damage
#Kill if health <= 0
self.image.fill((255,0,0))
if self.health <= 0:
############################
world.enemies.remove(self)
#Call superclass update, returns true if enemy has hit a wall and reverses direction of travel
if Entity.update(self, world)[0]:
self.facingRight = not self.facingRight
#Select speed, dir based on facingRight and rage
if self.facingRight and not self.rage:
self.momentum[0] = const.enemySpeed
elif self.facingRight:
self.momentum[0] = const.rageSpeed
elif not self.facingRight and not self.rage:
self.momentum[0] = -const.enemySpeed
elif not self.facingRight and self.rage:
self.momentum[0] = -const.rageSpeed
else:
self.momentum[1] = 0
示例10: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, t=0):
Entity.update(self,t)
#if power up goes off left side of screen, setReady and send next random power up
if self.rect.right < 0:
self.setReady()
示例11: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self):
Entity.update(self)
self.recalcVerts()
示例12: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self, session):
####
for e in session.worlds[session.activeWorld].eList:
if e.type == KEYDOWN:
if e.key not in self.keysDown:
self.keysDown.append(e.key)
elif e.type == KEYUP:
if e.key in self.keysDown:
self.keysDown.remove(e.key)
#Check if on ground
self.onGround = self.checkOnGround(session.worlds[session.activeWorld].clips)
#Get Left/Right keys
if K_LEFT in self.keysDown: l = True
else: l = False
if K_RIGHT in self.keysDown: r = True
else: r = False
#Jumping
#If on ground and jump key hit, start jump
if self.onGround and (K_UP in self.keysDown or K_z in self.keysDown):
self.jumping = True
self.jumpStart = self.rect.bottom
if self.jumping:
#Check if below min jump height
if self.rect.bottom >= (self.jumpStart - (const.minJump)):
self.momentum[1] = -const.playerJumpSpeed
#Check if below max jump height
elif self.rect.bottom > (self.jumpStart - const.maxJump) and (K_UP in self.keysDown or K_z in self.keysDown):
self.momentum[1] = -const.playerJumpSpeed
else:
self.jumping = False
#Horizontal movement
if l and r:
self.momentum[0] = 0
elif l:
self.momentum[0] = -const.playerSpeed
elif r:
self.momentum[0] = const.playerSpeed
else:
self.momentum[0] = 0
#Superclass - updates position, checks collisions
collisions = Entity.update(self, session.worlds[session.activeWorld])
if self.jumping and collisions[1]:
self.jumping = False
if session.multiplayer:
pass
else:
#Shooting
if self.weapon.rapidFire == False:
for e in session.worlds[session.activeWorld].eList:
if e.type == KEYDOWN and e.key == K_x:
self.weapon.shoot(self, session.worlds[session.activeWorld])
else:
if K_x in self.keysDown:
self.weapon.shoot(self, session.worlds[session.activeWorld])
#Check if collided with any enemies
for enemy in session.worlds[session.activeWorld].enemies:
if self.rect.colliderect(enemy.rect):
###############################
self.rect.topleft = (400, 100)
self.momentum = [0,0]
#Check if collided with any playerIntact projectiles
for proj in session.worlds[session.activeWorld].projectiles:
if proj.playerInteract and self.rect.colliderect(proj.rect):
###############################
self.rect.topleft = (400, 100)
self.momentum = [0,0]
#Update facing direction
if self.momentum[0] > 0:
self.facingRight = True
elif self.momentum[0] < 0:
self.facingRight = False
示例13: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self,t=0):
Entity.update(self,t)
示例14: update
# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import update [as 别名]
def update(self):
Entity.update(self)
self.lifespan-=1
if self.lifespan<=0:
self.markedForDeletion = True