Ejemplo n.º 1
0
    def __init__(self, pos, world):
        super(Ship, self).__init__(28, 500, pos)
        self._world = world  # NOTE: The ONLY reason this is here/needed is because the ship is creating a Torpedo from it's command system...
        self.energyRechargeRate = 4

        self.body.velocity_limit = 100

        # Ship Specific
        self.commandQueue = CommandSystem(self, 4)

        self.shield = PlayerStat(100)
        self.shieldConversionRate = 1.0  # Amount of Shield Recovered Per Energy (Higher Better)
        self.shieldDamageReduction = 0.8  # Amount Damage is Multiplied by and taken from Shields before health is touched (Higher Better)
        self.radarRange = 300

        self.energy = PlayerStat(100)
        self.energyRechargeRate = 4

        self.thrusterForce = 3500
        self.rotationAngle = random.randint(0, 359)
        self.rotationSpeed = 120

        #self.resources = PlayerStat(1000)
        #self.resources.empty()
        #self.miningSpeed = 8
        self.tractorbeamForce = 10000

        self.lasernodes = []

        # extra state
        self.killed = False  # forcibly removed object 'for good'
Ejemplo n.º 2
0
    def __init__(self):
        self.id = Entity.IDs
        Entity.IDs += random.randint(1,
                                     8)  # Prevent guessing of id assignments

        self.messageQueue = MessageQueue()
        self.health = PlayerStat(100)
        self.energy = PlayerStat(0)
        self.energyRechargeRate = 0  # Amount of Energy Recovered Per Second
        self.timealive = 0
        self.TTL = None  # None means will live 'forever', otherwise if timealive > TTL (time to live), then the object will be automatically cleaned up in gameloop and destroyed.

        self.in_celestialbody = [
        ]  # keeps track of celestial bodies this object is in
        self.destroyed = False  # keeps track of if the object has been destroyed and needs to be removed from the world in the next gameloop.
Ejemplo n.º 3
0
    def __init__(self,
                 pos,
                 attack_range=64,
                 attack_speed=5,
                 health=400,
                 attack_time=(1.0, 2.0),
                 attack_amount=(15, 25),
                 move_speed=14,
                 mass=None):
        if mass == None:
            mass = random.randint(3000, 5000)
        super(Dragon, self).__init__(16, mass, pos)
        self.shape.elasticity = 0.8
        self.health = PlayerStat(health)

        self.shape.group = 1

        self.influence_range = attack_range
        self.attack_speed = attack_speed
        self.attack_time = attack_time
        self.attack_amt = attack_amount
        self._get_next_attack()
        self.target = None
        self.see = []
        #initial movement
        ang = random.randint(0, 359)
        self.body.velocity = Vec2d(
            math.cos(math.radians(ang)) * move_speed,
            math.sin(math.radians(ang)) * move_speed)
        self.lv = self.body.velocity.normalized()
Ejemplo n.º 4
0
    def __init__(self,
                 pos,
                 size=44,
                 radius=96,
                 whtype=1,
                 exitpos=None):  # need pairing option
        """
        whtype should be the type of WormHole (RANDOM, OTHER_CELESTIALBODY, FIXED_POINT)

        if you choose type FIXED_POINT, pass in an exitpos as a position
        if you choose type RANDOM, pass in an exitpos as a function which returns a random point.
        """
        super(WormHole, self).__init__(radius, sys.maxint, pos)

        # Everything in Group 1 won't hit anything else in Group 1
        self.shape.group = 1

        self.health = PlayerStat(0)
        self.influence_range = size  # just used for consistency

        # WormHoles can't be moved by explosions
        self.explodable = False
        self.gravitable = False

        self.type = whtype
        self.exit = exitpos
Ejemplo n.º 5
0
    def __init__(self,
                 pos,
                 size=128,
                 pull=15,
                 radius=60,
                 torpedo=False,
                 mass=-1):
        if mass == -1: mass = sys.maxint
        super(Planet, self).__init__(radius, mass, pos)

        #self.energyRechargeRate = 1
        #self.energy = PlayerStat(random.randint(50, 200))

        # Everything in Group 1 won't hit anything else in Group 1
        self.shape.group = 1

        # Planets can't be moved by explosions
        self.explodable = False
        self.gravitable = False

        # Planet specific
        self.health = PlayerStat(0)
        self.pull = pull
        self.influence_range = size
        #self.resources = PlayerStat(random.randint(500, 2000))

        self.effect_weapon = torpedo
Ejemplo n.º 6
0
    def __init__(self, pos):
        super(Constellation, self).__init__(48, sys.maxint, pos)

        # Everything in Group 1 won't hit anything else in Group 1
        self.shape.group = 1

        # Constellations can't be moved by explosions
        self.explodable = False
        self.gravitable = False

        self.health = PlayerStat(0)
Ejemplo n.º 7
0
    def __init__(self, pos, direction, owner=None):
        pos = (pos[0] + math.cos(math.radians(-direction)) * 32,
               pos[1] + math.sin(math.radians(-direction)) * 32)
        super(Torpedo, self).__init__(6, 60, pos)
        self.TTL = 4  # Torpedos last 4 seconds
        self.shape.elasticity = 0.8
        self.health = PlayerStat(1)
        self.owner = owner
        self.explodable = False

        #self.shape.group = 1
        v = 15000
        self.body.apply_impulse((math.cos(math.radians(-direction)) * v,
                                 math.sin(math.radians(-direction)) * v),
                                (0, 0))
Ejemplo n.º 8
0
    def __init__(self, pos, move_speed=30, mass=None):
        #TODO: Make Asteroids of different sizes
        if mass == None:
            mass = random.randint(1500, 3500)
        super(Asteroid, self).__init__(16, mass, pos)
        self.shape.elasticity = 0.8
        self.health = PlayerStat(self.mass / 15.0)

        self.shape.group = 1

        # initial movement
        ang = random.randint(0, 359)
        self.body.velocity = Vec2d(
            math.cos(math.radians(ang)) * move_speed,
            math.sin(math.radians(ang)) * move_speed)
Ejemplo n.º 9
0
    def __init__(self, pos, size=(384, 256), pull=2000, mass=-1):
        if mass == -1: mass = sys.maxint
        super(Nebula, self).__init__(size, mass, pos)

        self.body.angle = math.radians(random.randint(-30, 30))

        # Everything in Group 1 won't hit anything else in Group 1
        self.shape.group = 1

        # Nebulas can't be moved by explosions
        self.explodable = False
        self.gravitable = False

        self.health = PlayerStat(0)
        self.pull = pull
Ejemplo n.º 10
0
 def __init__(self,
              pos,
              delay,
              wmode,
              direction=None,
              speed=None,
              duration=None,
              owner=None):
     super(SpaceMine, self).__init__(7, 120, pos)
     self.shape.elasticity = 0.7
     self.health = PlayerStat(1)
     self.owner = owner
     self.explodable = False
     self.delay = delay
     self.active = False
     self.mode = wmode
     self.direction = direction
     self.speed = speed
     self.duration = duration
     self.influence_range = 96
     self.attack_speed = 5
     self.target = None
     self.lv = self.body.velocity.normalized()