コード例 #1
0
class DynamicObject(Entity):
    """An object that can be pushed by the player or other entities and obeys gravity"""
    def __init__(self, rect, image, data, pushable):
        Entity.__init__(self, data)
        self.add(data.dynamicObjects)
        self.rect = rect
        self.mask = pygame.mask.from_surface(image)
        self.maskOutline = self.mask.outline()
        self.isPushable = pushable
        self.movedThisFrame = False

        #self.collisions = CollisionComponent(self, False, True)
        #self.gravity = GravityComponent(self)
        self.enchantments = EnchantmentComponent(self)
        self.isBeingStoodOn = False

        h = rect.height / 2.0
        w = rect.width / 2.0
        self.body = data.world.CreateDynamicBody(
            position=(data.pixelsToMetreCoords(self.rect.topleft)), angle=0)
        self.body.CreatePolygonFixture(box=(data.pixelsToMetresConvert(
            (h, w))),
                                       density=1,
                                       friction=0.3)

    def update(self, data):
        self.enchantments.update(data)

        #if not data.balloons or not self.isBeingStoodOn:  # balloons don't float when something is on top of them
        #	self.gravity.update(data)

        #if self.isPushable:
        #	data.dynamicObjects.remove(self)
        #	self.collisions.checkIfBeingPushed(data.playerGroup.sprites() + data.dynamicObjects.sprites(), data)
        #	data.dynamicObjects.add(self)
        #self.collisions.checkIfStandingOn(data.dynamicObjects, data)
        #self.collisions.checkForWorldCollisions(data)

        if not data.spellTargeter and data.input.mousePressed == 1 and self.rect.collidepoint(
                data.gameMousePos):
            self.enchantments.removeSoulBind()
            SpellTargeter(self, data.RED, 'soulbind', data)

        self.isBeingStoodOn = False
コード例 #2
0
ファイル: object.py プロジェクト: jellyberg2/Magus-Operandi
class DynamicObject(Entity):
	"""An object that can be pushed by the player or other entities and obeys gravity"""
	def __init__(self, rect, image, data, pushable):
		Entity.__init__(self, data)
		self.add(data.dynamicObjects)
		self.rect = rect
		self.mask = pygame.mask.from_surface(image)
		self.maskOutline = self.mask.outline()
		self.isPushable = pushable
		self.movedThisFrame = False
		
		#self.collisions = CollisionComponent(self, False, True)
		#self.gravity = GravityComponent(self)
		self.enchantments = EnchantmentComponent(self)
		self.isBeingStoodOn = False


		h = rect.height / 2.0
		w = rect.width / 2.0
		self.body = data.world.CreateDynamicBody(position=(data.pixelsToMetreCoords(self.rect.topleft)), angle=0)
		self.body.CreatePolygonFixture(box=(data.pixelsToMetresConvert((h, w))), density=1, friction=0.3)


	def update(self, data):
		self.enchantments.update(data)

		#if not data.balloons or not self.isBeingStoodOn:  # balloons don't float when something is on top of them
		#	self.gravity.update(data)

		#if self.isPushable:
		#	data.dynamicObjects.remove(self)
		#	self.collisions.checkIfBeingPushed(data.playerGroup.sprites() + data.dynamicObjects.sprites(), data)
		#	data.dynamicObjects.add(self)
		#self.collisions.checkIfStandingOn(data.dynamicObjects, data)
		#self.collisions.checkForWorldCollisions(data)

		if not data.spellTargeter and data.input.mousePressed == 1 and self.rect.collidepoint(data.gameMousePos):
			self.enchantments.removeSoulBind()
			SpellTargeter(self, data.RED, 'soulbind', data)

		self.isBeingStoodOn = False
コード例 #3
0
    def __init__(self, rect, image, data, pushable):
        Entity.__init__(self, data)
        self.add(data.dynamicObjects)
        self.rect = rect
        self.mask = pygame.mask.from_surface(image)
        self.maskOutline = self.mask.outline()
        self.isPushable = pushable
        self.movedThisFrame = False

        #self.collisions = CollisionComponent(self, False, True)
        #self.gravity = GravityComponent(self)
        self.enchantments = EnchantmentComponent(self)
        self.isBeingStoodOn = False

        h = rect.height / 2.0
        w = rect.width / 2.0
        self.body = data.world.CreateDynamicBody(
            position=(data.pixelsToMetreCoords(self.rect.topleft)), angle=0)
        self.body.CreatePolygonFixture(box=(data.pixelsToMetresConvert(
            (h, w))),
                                       density=1,
                                       friction=0.3)
コード例 #4
0
ファイル: object.py プロジェクト: jellyberg2/Magus-Operandi
	def __init__(self, rect, image, data, pushable):
		Entity.__init__(self, data)
		self.add(data.dynamicObjects)
		self.rect = rect
		self.mask = pygame.mask.from_surface(image)
		self.maskOutline = self.mask.outline()
		self.isPushable = pushable
		self.movedThisFrame = False
		
		#self.collisions = CollisionComponent(self, False, True)
		#self.gravity = GravityComponent(self)
		self.enchantments = EnchantmentComponent(self)
		self.isBeingStoodOn = False


		h = rect.height / 2.0
		w = rect.width / 2.0
		self.body = data.world.CreateDynamicBody(position=(data.pixelsToMetreCoords(self.rect.topleft)), angle=0)
		self.body.CreatePolygonFixture(box=(data.pixelsToMetresConvert((h, w))), density=1, friction=0.3)