Пример #1
0
  def update(self, level = None):

    VisibleObject.update(self)

    if self.flip_finished and self.itemclass != "player":
      self.active = (self.x + self.rect.width / 2 > 0) and (self.y + self.rect.height / 2 > 0)

    if self.flipping:
      return

    if not self.active:
      return

    if self.gravity:
      self.dy += GRAVITY

    self.x += self.dx
    self.y += self.dy

    if not self.colliding or level == None:
      return

    collision_type = self.check_collisions(level)

    return collision_type
Пример #2
0
 def flip(self, flip_direction=CLOCKWISE):
     VisibleObject.flip(self, flip_direction)
     if flip_direction == CLOCKWISE:
         tempx = self.tilex
         self.tilex = FULL_TILES_VER - self.tiley - 1
         self.tiley = tempx
     else:
         tempy = self.tiley
         self.tiley = FULL_TILES_HOR - self.tilex - 1
         self.tilex = tempy
Пример #3
0
 def __init__(self, screen, tilex, tiley, set="brown", tileclass="wall"):
     x = (tilex - (FULL_TILES_HOR - TILES_HOR) + 0.5) * TILE_DIM
     y = (tiley - (FULL_TILES_VER - TILES_VER) + 0.5) * TILE_DIM
     VisibleObject.__init__(self, screen, x, y)
     self.animations["default"] = Animation(set, tileclass)
     self.image = self.animations[self.current_animation].update_and_get_image()
     self.rect = self.image.get_rect()
     self.tilex = tilex
     self.tiley = tiley
     self.tileclass = tileclass
     self.aligned = True
     return
Пример #4
0
 def to_str(self, verbose = True):
   string = VisibleObject.to_str(self, False)
   if self.trigger != None:
     string += " " + str(self.max_activations) + " " + self.trigger.trigger_type
   if verbose:
     log_message("Obj converted to string: " + string)
   return string
Пример #5
0
 def flip(self, flip_direction = CLOCKWISE):
   """Make the object flip with the level to either direction"""
   if VisibleObject.flip(self, flip_direction):
     if flip_direction == CLOCKWISE:
       self.initial_x, self.initial_y = -self.initial_y + PLAY_AREA_WIDTH / TILES_HOR * (TILES_HOR*2 - FULL_TILES_HOR), self.initial_x
     else:
       self.initial_x, self.initial_y = self.initial_y, -self.initial_x + PLAY_AREA_WIDTH / TILES_HOR * (TILES_HOR*2 - FULL_TILES_HOR)
   return
Пример #6
0
  def __init__(self, screen, x, y, life = -1, gravity = False, colliding = False):
    VisibleObject.__init__(self, screen, x, y)
    self.dx = 0.0
    self.dy = 0.0
    self.initial_x = x
    self.initial_y = y
    self.gravity = gravity
    self.colliding = colliding
    self.active = (self.x + self.rect.width / 2 > 0) and (self.y + self.rect.height / 2 > 0)

    self.on_ground = False

    self.life = life
    self.destructable = True
    if (self.life == -1):
      self.destructable = False

    return
Пример #7
0
  def __init__(self, screen, x = None, y = None, set = "brown", itemclass = "key", max_activations = 1, trigger_type = None):
    VisibleObject.__init__(self, screen, x, y)
    self.animations["default"] = Animation(set, itemclass)

    try:
      self.animations["broken"] = Animation(set, itemclass + "_broken")
    except:
      self.animations["broken"] = self.animations["default"]

    self.image = self.animations[self.current_animation].update_and_get_image()
    self.rect = self.image.get_rect()
    self.itemclass = itemclass
    self.activated_times = 0
    self.max_activations = max_activations
    self.trigger = None
    if trigger_type != None:
      self.trigger = Trigger(trigger_type, x, y)
    else:
      self.pickable = True
    return
Пример #8
0
 def render(self, surface = None, center = None, static_render = False):
   VisibleObject.render(self, surface, center, static_render)
   if variables["devmode"] and not self.flipping:
     VisibleObject.render(self, surface, (self.initial_x, self.initial_y), static_render, 100)
   return
Пример #9
0
 def update(self, level=None):
     VisibleObject.update(self)
     if not self.flipping:
         self.realign()
     return