コード例 #1
0
ファイル: projectile.py プロジェクト: geofmatthews/csci321
 def update(self, level = None):
   Gameobject.update(self, level)
   if self.y < 0 and self.current_animation != "dying":  #This kills projectiles that wander off the screen from the top
     self.current_animation = "dying"
   if self.dx == 0 and self.dy == 0 and self.saveddx != None:
     self.dx = self.saveddx
     self.dy = self.saveddy
   return
コード例 #2
0
ファイル: projectile.py プロジェクト: italomaia/turtle-linux
 def update(self, level=None):
     Gameobject.update(self, level)
     if self.y < 0 and self.current_animation != "dying":  #This kills projectiles that wander off the screen from the top
         self.current_animation = "dying"
     if self.dx == 0 and self.dy == 0 and self.saveddx != None:
         self.dx = self.saveddx
         self.dy = self.saveddy
     return
コード例 #3
0
ファイル: player.py プロジェクト: italomaia/turtle-linux
 def update(self, level = None):
   blood = Gameobject.update(self, level)
   if self.animations[self.current_animation].finished and self.current_animation != "dying":
     self.animations[self.current_animation].reset()
     self.current_animation = "default"
   if self.on_ground:
     if self.current_animation == "jumping":
       self.current_animation = "default"
     if self.dx != 0 and self.current_animation == "default":
       self.current_animation = "walking"
     if (self.dx == 0) and self.current_animation == "walking" :
       self.current_animation = "default"
   elif self.current_animation != "dying":
     self.current_animation = "jumping"
   return blood
コード例 #4
0
    def update(self, level=None):
        blood = Gameobject.update(self, level)

        if self.x < 0 or self.y < 0 or self.flipping:
            return []

        if self.attached == RIGHT:
            self.top_leg_attach_point = (self.rect.right + 2,
                                         self.rect.top + SPIDER_TOO_WIDE)
            self.bottom_leg_attach_point = (self.rect.right + 2,
                                            self.rect.bottom - SPIDER_TOO_WIDE)
        if self.attached == LEFT:
            self.top_leg_attach_point = (self.rect.left - 2,
                                         self.rect.top + SPIDER_TOO_WIDE)
            self.bottom_leg_attach_point = (self.rect.left - 2,
                                            self.rect.bottom - SPIDER_TOO_WIDE)
        if self.attached == DOWN:
            self.top_leg_attach_point = (self.rect.left + SPIDER_TOO_WIDE,
                                         self.rect.bottom + 2)
            self.bottom_leg_attach_point = (self.rect.right - SPIDER_TOO_WIDE,
                                            self.rect.bottom + 2)
        if self.attached == UP:
            self.top_leg_attach_point = (self.rect.left + SPIDER_TOO_WIDE,
                                         self.rect.top - 2)
            self.bottom_leg_attach_point = (self.rect.right - SPIDER_TOO_WIDE,
                                            self.rect.top - 2)

        if (not level.ground_check(self.top_leg_attach_point[0],
                                   self.top_leg_attach_point[1])
            ) and (not level.ground_check(self.bottom_leg_attach_point[0],
                                          self.bottom_leg_attach_point[1])):
            self.gravity = True
        else:
            self.gravity = False

        self.move_target = STAY
        if self.attached == RIGHT or self.attached == LEFT:
            if (level.player.rect.top > (self.y - 2)):
                self.move_target = DOWN
            if (level.player.rect.bottom < (self.y + 2)):
                self.move_target = UP

        if self.attached == DOWN or self.attached == UP:
            if (level.player.rect.left > (self.x - 2)):
                self.move_target = RIGHT
            if (level.player.rect.right < (self.x + 2)):
                self.move_target = LEFT

        if not self.gravity:
            if self.fire_delay > 0:
                self.fire_delay -= 1
            self.dy = 0
            self.dx = 0
            if self.move_target == UP:
                if (level.ground_check(self.top_leg_attach_point[0],
                                       self.top_leg_attach_point[1] - 1)):
                    self.dy = -1
            if self.move_target == DOWN:
                if (level.ground_check(self.bottom_leg_attach_point[0],
                                       self.bottom_leg_attach_point[1] + 1)):
                    self.dy = 1
            if self.move_target == LEFT:
                if (level.ground_check(self.top_leg_attach_point[0] - 1,
                                       self.top_leg_attach_point[1])):
                    self.dx = -1
            if self.move_target == RIGHT:
                if (level.ground_check(self.bottom_leg_attach_point[0] + 1,
                                       self.bottom_leg_attach_point[1])):
                    self.dx = 1
            if self.move_target == STAY and not level.player.dead:
                self.fire(level)

        if self.animations[
                self.
                current_animation].finished and self.current_animation != "dying":
            self.animations[self.current_animation].reset()
            self.current_animation = "default"
        if self.dx != 0 and self.dy != 0 and self.current_animation == "default":
            self.current_animation = "walking"
        if self.dx == 0 and self.dy == 0 and self.current_animation == "walking":
            self.current_animation = "default"

        return blood
コード例 #5
0
ファイル: spider.py プロジェクト: italomaia/turtle-linux
  def update(self, level = None):
    blood = Gameobject.update(self, level)

    if self.x < 0 or self.y < 0 or self.flipping:
      return []

    if self.attached == RIGHT:
      self.top_leg_attach_point = (self.rect.right + 2, self.rect.top + SPIDER_TOO_WIDE)
      self.bottom_leg_attach_point = (self.rect.right + 2, self.rect.bottom - SPIDER_TOO_WIDE)
    if self.attached == LEFT:
      self.top_leg_attach_point = (self.rect.left - 2, self.rect.top + SPIDER_TOO_WIDE)
      self.bottom_leg_attach_point = (self.rect.left - 2, self.rect.bottom - SPIDER_TOO_WIDE)
    if self.attached == DOWN:
      self.top_leg_attach_point = (self.rect.left + SPIDER_TOO_WIDE, self.rect.bottom + 2)
      self.bottom_leg_attach_point = (self.rect.right - SPIDER_TOO_WIDE, self.rect.bottom + 2)
    if self.attached == UP:
      self.top_leg_attach_point = (self.rect.left + SPIDER_TOO_WIDE, self.rect.top - 2)
      self.bottom_leg_attach_point = (self.rect.right - SPIDER_TOO_WIDE, self.rect.top - 2)

    if (not level.ground_check(self.top_leg_attach_point[0], self.top_leg_attach_point[1])) and (not level.ground_check(self.bottom_leg_attach_point[0], self.bottom_leg_attach_point[1])):
      self.gravity = True
    else:
      self.gravity = False

    self.move_target = STAY
    if self.attached == RIGHT or self.attached == LEFT:
      if (level.player.rect.top > (self.y - 2)):
        self.move_target = DOWN
      if (level.player.rect.bottom < (self.y + 2)):
        self.move_target = UP

    if self.attached == DOWN or self.attached == UP:
      if (level.player.rect.left > (self.x - 2)):
        self.move_target = RIGHT
      if (level.player.rect.right < (self.x + 2)):
        self.move_target = LEFT

    if not self.gravity:
      if self.fire_delay > 0:
        self.fire_delay -= 1
      self.dy = 0
      self.dx = 0
      if self.move_target == UP:
        if (level.ground_check(self.top_leg_attach_point[0], self.top_leg_attach_point[1] - 1)):
          self.dy = -1
      if self.move_target == DOWN:
        if (level.ground_check(self.bottom_leg_attach_point[0], self.bottom_leg_attach_point[1] + 1)):
          self.dy = 1
      if self.move_target == LEFT:
        if (level.ground_check(self.top_leg_attach_point[0] - 1, self.top_leg_attach_point[1])):
          self.dx = -1
      if self.move_target == RIGHT:
        if (level.ground_check(self.bottom_leg_attach_point[0] + 1, self.bottom_leg_attach_point[1])):
          self.dx = 1
      if self.move_target == STAY and not level.player.dead:
        self.fire(level)

    if self.animations[self.current_animation].finished and self.current_animation != "dying":
      self.animations[self.current_animation].reset()
      self.current_animation = "default"
    if self.dx != 0 and self.dy != 0 and self.current_animation == "default":
      self.current_animation = "walking"
    if self.dx == 0 and self.dy == 0 and self.current_animation == "walking":
      self.current_animation = "default"

    return blood
コード例 #6
0
 def update(self, level = None):
   Gameobject.update(self, level)
   if not self.flipping:
     self.x = round((self.x/TILE_DIM), 1)*TILE_DIM
     self.y = round((self.y/TILE_DIM), 1)*TILE_DIM
   return