Ignore:
Timestamp:
09/07/13 12:47:34 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Herd ALL THE SHEEPS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r437 r444  
    1010from nagslang.constants import (
    1111    COLLISION_TYPE_DOOR, COLLISION_TYPE_FURNITURE, COLLISION_TYPE_PROJECTILE,
    12     COLLISION_TYPE_SWITCH, COLLISION_TYPE_WEREWOLF_ATTACK,
    13     SWITCH_PUSHERS, ZORDER_FLOOR, ZORDER_LOW, ZORDER_HIGH)
     12    COLLISION_TYPE_SWITCH, COLLISION_TYPE_SHEEP, COLLISION_TYPE_SHEEP_PEN,
     13    COLLISION_TYPE_WEREWOLF_ATTACK, SWITCH_PUSHERS, ZORDER_FLOOR, ZORDER_LOW,
     14    ZORDER_HIGH)
    1415from nagslang.resources import resources
    1516from nagslang.events import DoorEvent
     
    684685        return [("name", "string"), ("position", "coordinates"),
    685686                ("outline", "polygon (convex)")]
     687
     688
     689class SheepPen(GameObject):
     690    zorder = ZORDER_FLOOR
     691
     692    def __init__(self, space, position, outline, sheep_count):
     693        body = make_body(None, None, position)
     694        # Adjust shape relative to position
     695        shape_outline = [(p[0] - position[0], p[1] - position[1]) for
     696                         p in outline]
     697        self.shape = pymunk.Poly(body, shape_outline)
     698        self.shape.collision_type = COLLISION_TYPE_SHEEP_PEN
     699        self.shape.sensor = True
     700        super(SheepPen, self).__init__(
     701            SingleShapePhysicser(space, self.shape),
     702            render.Renderer(),
     703            puzzle.MultiCollidePuzzler(sheep_count, COLLISION_TYPE_SHEEP),
     704        )
     705
     706    @classmethod
     707    def requires(cls):
     708        return [("name", "string"), ("position", "coordinates"),
     709                ("outline", "polygon (convex)"), ("sheep_count", "int")]
Note: See TracChangeset for help on using the changeset viewer.