Esempio n. 1
0
    def __init__(self, direction, speed, owner, **kwargs):
        self.owner = owner
        self.speed = 1.0
        self.width = 0.5
        self.height = 0.15
        self.state = 'shooting'
        super(Arrow, self).__init__(owner.world,
                                    type="arrow",
                                    lifetime=kwargs.pop('lifetime', 1.0),
                                    **kwargs)

        target_position = b2Vec2(direction.x * (owner.width - self.width),
                                 direction.y * (owner.height - self.height))
        target_position = owner.physics.position + target_position

        self.create_dynamic_box_body(target_position.x, target_position.y,
                                     self.width, self.height)

        self.physics.fixedRotation = True
        self.physics.linearDamping = 0.2
        self.direction = direction
        self.physics.angle = vec2rad(direction)

        speed_vector = b2Vec2(1, 0) * self.speed * 1.5
        self.physics.ApplyLinearImpulse(
            impulse=self.physics.GetWorldVector(speed_vector),
            point=self.physics.position,
            wake=True)
        self.physics.bullet = True
Esempio n. 2
0
	def __init__(self, direction, speed, owner, **kwargs):
		self.owner = owner
		self.speed = 1.0          
		self.width = 0.5 
		self.height = 0.15
		self.state = 'shooting'
		super(Arrow, self).__init__(
			owner.world,
			type="arrow",
			lifetime=kwargs.pop('lifetime', 1.0),
			**kwargs)

		target_position = b2Vec2(
			direction.x*(owner.width-self.width),
			direction.y*(owner.height-self.height)
		)
		target_position = owner.physics.position + target_position

		self.create_dynamic_box_body(
			target_position.x,
			target_position.y,
			self.width, self.height
		)

		self.physics.fixedRotation = True
		self.physics.linearDamping = 0.2
		self.direction = direction
		self.physics.angle = vec2rad(direction)

		speed_vector = b2Vec2(1,0)*self.speed*1.5
		self.physics.ApplyLinearImpulse(
			impulse=self.physics.GetWorldVector(speed_vector),
			point=self.physics.position,
			wake=True
		)
		self.physics.bullet = True
Esempio n. 3
0
import random
import settings
from twisted.internet import reactor
from archers.utils import vec2rad, EventsMixins
from archers.utils import p2m, m2p, limit, get_class
from collisions import Collisions, CLCAT_OBSTACLE, CLCAT_TERRESTRIAL_OBSTACLE, CLCAT_BULLET, CLCAT_EVERYTHING

directions = {
	'north': b2Vec2(0, -1),
	'south': b2Vec2(0, 1),
	'east': b2Vec2(1, 0),
	'west': b2Vec2(-1, 0),
}

rotations = {
	'north': vec2rad(directions['north']),
	'south': vec2rad(directions['south']),
	'east': vec2rad(directions['east']),
	'west': vec2rad(directions['west']),
}

from archers.messages import UpdateMessage, FrameMessage, RemoveMessage, EventMessage


class ListWithCounter(list):
	def __init__(self):
		self.counter = 0

	def append(self, item):
		self.counter = self.counter + 1
		return super(ListWithCounter, self).append(item)
Esempio n. 4
0
import random
import settings
from twisted.internet import reactor
from archers.utils import vec2rad, EventsMixins
from archers.utils import p2m, m2p, limit, get_class
from collisions import Collisions, CLCAT_OBSTACLE, CLCAT_TERRESTRIAL_OBSTACLE, CLCAT_BULLET, CLCAT_EVERYTHING

directions = {
    'north': b2Vec2(0, -1),
    'south': b2Vec2(0, 1),
    'east': b2Vec2(1, 0),
    'west': b2Vec2(-1, 0),
}

rotations = {
    'north': vec2rad(directions['north']),
    'south': vec2rad(directions['south']),
    'east': vec2rad(directions['east']),
    'west': vec2rad(directions['west']),
}

from archers.messages import UpdateMessage, FrameMessage, RemoveMessage, EventMessage


class ListWithCounter(list):
    def __init__(self):
        self.counter = 0

    def append(self, item):
        self.counter = self.counter + 1
        return super(ListWithCounter, self).append(item)