Esempio n. 1
0
 def __init__(self, model, shape, element, lvl, duration, damage):
     Object.__init__(self, model, shape, element)
     
     self.duration = duration
     self.elapsed = 0.0
     self.lvl = lvl
     self.damage = damage
Esempio n. 2
0
    def __init__( self, stats, ai, xp, yp, zp=0, ori=0.0, xi=0, yi=0, zi=0, ri=0, thrust=0 ):
        Object.__init__( self, stats, xp, yp, zp, ori, xi, yi, zi, ri )

        self.alive = True
        self.maxOri = 2*pi

        self.thrust = thrust
        self.rg = 0

        self.shieldVsMass = self.stats.shieldVsMass
        self.shieldVsEnergy = self.stats.shieldVsEnergy
        self.hullVsMass = self.stats.hullVsMass 
        self.hullVsEnergy = self.stats.hullVsEnergy

        self.ai = ai
        self.dockedTo = False
        self.dockedAt = 0 # tick at docking

        self.hull = stats.maxHull
        self.shield = stats.maxShield
        self.inertiaControl = True

        self.headed = True # differentiate bases from ships

        self.pulsedUntil = -1000
        self.inNebula = False # variable state
        self.inertiaMod = 1
        self.thrustBoost = 0

        self.shipyards = [] # list of regulard shipyards
        self.guestDocked = [] # list of temporary docks
Esempio n. 3
0
 def __init__(self, parent_context, param_list, statements):
     import proto_functions
     Object.__init__(self, prototype=proto_functions.function_proto)
     self.parent_context = parent_context
     self.param_list = param_list
     self.statements = statements
     self.constructing_prototype = Object()
Esempio n. 4
0
    def __init__(self, model, shape, element, lvl, duration, damage):
        Object.__init__(self, model, shape, element)

        self.duration = duration
        self.elapsed = 0.0
        self.lvl = lvl
        self.damage = damage
Esempio n. 5
0
 def __init__(self, x, y, char, name, color, blocks=True, ai=None, always_visible=False,
              equipment=None, character_class=None, creature_type=None, xp=0, screen=None):
     #call super constructor to create the map object
     Object.__init__(self, x, y, char, name, color, blocks=blocks, always_visible=always_visible)
     self.character_class = character_class
     if self.character_class:
         # let the fighter component know who owns it
         self.character_class.owner = self
     
     self.screen = screen
     if self.screen:
         # set the screen element in the character_class
         self.character_class.screen = screen        
     
     self.ai = ai
     if self.ai:
         # let the ai component know who owns it
         self.ai.owner = self        
     
     self.xp = xp            
     self.dead = False
     self.inventory = []        
     #set the default equipment dictionary.
     self.equipment = {'head': None, 'body':None, 'legs':None, 'hands':None, 'feet':None, 'left hand': None, 'right hand': None}
     self.player = None
Esempio n. 6
0
	def __init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time, \
			owner, ships, damage):
		Object.__init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time)

		self.length += 4 + 4 + len(ships) * 8 + 4

		self.owner = owner
		self.ships = ships
		self.damage = damage
Esempio n. 7
0
 def __init__(self, x, y, char, name, color, slot, power_bonus=0, defense_bonus=0, max_hp_bonus=0):
     Object.__init__(self, x, y, char, name, color, blocks=False, always_visible=False)        
     self.slot = slot
     self.is_equipped = False
     self.power_bonus = power_bonus
     self.defense_bonus = defense_bonus
     self.max_hp_bonus = max_hp_bonus
Esempio n. 8
0
	def __init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time, \
			owner, resources):
		Object.__init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time)

		self.length += 4 + 4 + 16 * len(resources)
		self.owner = owner

		for r in resources:
			if len(r) != 4:
				raise TypeError("Resources should be 4 length, <id> <surface> <minable> <inaccess>")

		self.resources = resources
Esempio n. 9
0
 def __init__(self, source, image, coords):
     Object.__init__(self, source, image, coords)
     self.source = source
     self.wallgroup = self.source.wallgroup
     self.wall_list = []
     for w in self.wallgroup.sprites():
         self.wall_list.append(w.rect)
     self.walls = self.wall_list
     """ # old settings for sanity
     self.speed = 2
     self.ammo_speed = 3
     self.cooldown = 250
     self.blast_cool = 2000
     self.run_cool = 3000
     self.run_time = 750
     """
     tree = ET.parse("settings.xml")
     root = tree.getroot().find("player")
     fps = int(tree.getroot().find("main").find("fps").text)
     self.speed = int(root.find("speed").text)
     self.double_speed = self.speed * 2
     self.half_speed = int(self.speed)
     self.velocity = 0.4
     self.ammo_speed = float(root.find("ammo_speed").text) * self.speed
     self.cooldown = int(root.find("cooldown").text)
     self.blast_cool = int(root.find("blast_cool").text)
     self.blast_radius = int(root.find("blast_radius").text)
     self.run_cool = int(root.find("run_cool").text)
     self.run_time = int(root.find("run_time").text)
     self.ammo_image = path.join("images", "ammo.png")
     self.ammogroup = pygame.sprite.Group()
     self.blastgroup = pygame.sprite.Group()
     self.bombgroup = pygame.sprite.Group()
     self.aimx = lambda x: x  #* self.speed
     self.aimy = lambda y: y  #* self.speed
     #self.shoot_start = pygame.time.get_ticks() - self.cooldown
     #self.blast_start = pygame.time.get_ticks() - self.blast_cool
     self.run_start = pygame.time.get_ticks() - self.run_cool
     self.can_blast = True
     self.can_run = True
     self.run_speed = self.speed * 2
     self.old_dir = (1, 0)
     self.old_ammo_dir = (0, 0)
     self.ray_shrink = (-24, -6)
     self.cast = Cast(self)
     self.ammo_spawner = Spawner(self, deltaAmmo, self.cooldown,
                                 self.ammo_speed, self.ammo_image, 1,
                                 self.ammogroup)
     self.sarja_spawner = Spawner(self, deltaAmmo, self.cooldown,
                                  self.ammo_speed, self.ammo_image, 6,
                                  self.ammogroup)
     self.blast_spawner = Spawner(self, Blast, self.blast_cool, 1,
                                  self.ammo_image, 1, self.blastgroup)
     self.bomb_spawner = Spawner(self, Bomb, self.blast_cool, 250,
                                 self.ammo_image, 1, self.bombgroup)
     self.run_spawner = Spawner(self, Run, self.run_cool, self.run_time,
                                None, 1, None)
Esempio n. 10
0
 def __init__(self, position):
     Object.__init__(self)
     self.frame = 0
     self._position = position
     self.frames = self._cls_frames[:]
     self.frames_count = len(self.frames)
     self._current_frame_time = 0
     self._finished = False
     self.load_frame()
Esempio n. 11
0
 def __init__(self, model, shape, element, lvl, damage, target_obj, attract_v):
     Object.__init__(self, model, shape, element)
     
     self.lvl = lvl
     self.damage = damage
     self.target = target_obj
     
     self.velocity = attract_v
     
     self.dir = Vector3d(0.,0.,0.)
Esempio n. 12
0
 def __init__(self, model, shape, element, level):
     Object.__init__(self, model, shape, element)
     
     cfg = Config('physics','Ship')
     
     self.move_force_sz = cfg.get('move_force')
     self.spin_velocity = cfg.get('spin_velocity')
     self.strafe_force = cfg.get('strafe_force')
     self.shape.forces_res.append(cfg.get('vacuum_resistance'))
     self.breake_rate = cfg.get('breake_rate')
     
     self.mouse_sensivity = Config('game','Mouse').get('sensivity')
     
     self.level = level
     
     self.rotation = Quaternion.from_axis_rotations(0.,0.,0.)
     
     self.ship_dir = None
     self.up_dir = None
     
     self.spinning = {
         'up'    : False,
         'down'  : False,
         'left'  : False,
         'right' : False
     }
             
     self.vectors = {
         'up'    : (Vector3d.x_axis(), 1.),
         'down'  : (Vector3d.x_axis(), -1.),
         'left'  : (Vector3d.y_axis(), 1.),
         'right' : (Vector3d.y_axis(), -1.)
     }
     
     self.strafe = {
         'forward': False,
         'left'  : False,
         'right' : False,
         'breake' : False
     }
     
     self.strafe_vectors = {
         'forward':Vector3d(0.,0.,-0.7),
         'left'  : Vector3d(-0.9,0.,0.),
         'right' : Vector3d(0.9,0.,0.),
         'breake' : Vector3d(0.,0.,1.)
     }
     
     self.angles = [0.,0.]
     self.mouse_target = [0.,0.]
     
     self.collision_set = set()
     self.keep_colliding = set()
Esempio n. 13
0
    def __init__(self, model, shape, element, level):
        Object.__init__(self, model, shape, element)

        cfg = Config('physics', 'Ship')

        self.move_force_sz = cfg.get('move_force')
        self.spin_velocity = cfg.get('spin_velocity')
        self.strafe_force = cfg.get('strafe_force')
        self.shape.forces_res.append(cfg.get('vacuum_resistance'))
        self.breake_rate = cfg.get('breake_rate')

        self.mouse_sensivity = Config('game', 'Mouse').get('sensivity')

        self.level = level

        self.rotation = Quaternion.from_axis_rotations(0., 0., 0.)

        self.ship_dir = None
        self.up_dir = None

        self.spinning = {
            'up': False,
            'down': False,
            'left': False,
            'right': False
        }

        self.vectors = {
            'up': (Vector3d.x_axis(), 1.),
            'down': (Vector3d.x_axis(), -1.),
            'left': (Vector3d.y_axis(), 1.),
            'right': (Vector3d.y_axis(), -1.)
        }

        self.strafe = {
            'forward': False,
            'left': False,
            'right': False,
            'breake': False
        }

        self.strafe_vectors = {
            'forward': Vector3d(0., 0., -0.7),
            'left': Vector3d(-0.9, 0., 0.),
            'right': Vector3d(0.9, 0., 0.),
            'breake': Vector3d(0., 0., 1.)
        }

        self.angles = [0., 0.]
        self.mouse_target = [0., 0.]

        self.collision_set = set()
        self.keep_colliding = set()
Esempio n. 14
0
    def __init__(self,
                 x,
                 y,
                 char,
                 name,
                 color,
                 blocks=True,
                 ai=None,
                 always_visible=False,
                 equipment=None,
                 character_class=None,
                 creature_type=None,
                 xp=0,
                 screen=None):
        #call super constructor to create the map object
        Object.__init__(self,
                        x,
                        y,
                        char,
                        name,
                        color,
                        blocks=blocks,
                        always_visible=always_visible)
        self.character_class = character_class
        if self.character_class:
            # let the fighter component know who owns it
            self.character_class.owner = self

        self.screen = screen
        if self.screen:
            # set the screen element in the character_class
            self.character_class.screen = screen

        self.ai = ai
        if self.ai:
            # let the ai component know who owns it
            self.ai.owner = self

        self.xp = xp
        self.dead = False
        self.inventory = []
        #set the default equipment dictionary.
        self.equipment = {
            'head': None,
            'body': None,
            'legs': None,
            'hands': None,
            'feet': None,
            'left hand': None,
            'right hand': None
        }
        self.player = None
Esempio n. 15
0
	def __init__(self, map, con, x,y, char, color, fighter=None, level=None):
		Object.__init__(self, None, con, x,y, char,
			libtcod.namegen_generate('Celtic male'), color, True, fighter=fighter, level=level
		)

		map.player = self
		self.inventory = Inventory()
		self.mods = Inventory()

		class Item:
			stack_limit = 5
		obj = Object(None, con, None,None, 'b', 'boost', color, item=Item())
		obj.mod = mods.Boost()
		self.mods.add_item(obj)
Esempio n. 16
0
class ExplodingBullet(Object):
    def __init__(self, (xp, yp), zp, ori, (xi, yi), target, launcher, weapon):
        Object.__init__(self, weapon.stats.projectile, xp, yp, zp, ori, xi, yi,
                        0, 0)
        self.target = target
        self.launcher = launcher
        self.weapon = weapon
        self.ttl = weapon.stats.projectileTtl
Esempio n. 17
0
	def __init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number,
			modify_time):
		Object.__init__(self, sequence, \
			id, type, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time)
Esempio n. 18
0
class Mine(Object):
    def __init__(self, stats, (xp, yp), zp, (xi, yi), weapon, explosionRange,
                 detectionRange):
        Object.__init__(self, stats, xp, yp, zp,
                        random() * 2 * pi, xi, yi, 0, 0)  # random()*0.01 )
        self.weapon = weapon
        self.ttl = 30 * 360  #weapon.stats.projectileTtl
        self.detectionRange = detectionRange
        self.explosionRange = explosionRange
Esempio n. 19
0
    def __init__(self,
                 stats,
                 ai,
                 xp,
                 yp,
                 zp=0,
                 ori=0.0,
                 xi=0,
                 yi=0,
                 zi=0,
                 ri=0,
                 thrust=0):
        Object.__init__(self, stats, xp, yp, zp, ori, xi, yi, zi, ri)

        self.alive = True
        self.maxOri = 2 * pi

        self.thrust = thrust
        self.rg = 0

        self.shieldVsMass = self.stats.shieldVsMass
        self.shieldVsEnergy = self.stats.shieldVsEnergy
        self.hullVsMass = self.stats.hullVsMass
        self.hullVsEnergy = self.stats.hullVsEnergy

        self.ai = ai
        self.dockedTo = False
        self.dockedAt = 0  # tick at docking

        self.hull = stats.maxHull
        self.shield = stats.maxShield
        self.inertiaControl = True

        self.headed = True  # differentiate bases from ships

        self.pulsedUntil = -1000
        self.inNebula = False  # variable state
        self.inertiaMod = 1
        self.thrustBoost = 0

        self.shipyards = []  # list of regulard shipyards
        self.guestDocked = []  # list of temporary docks
Esempio n. 20
0
	def __init__(self, sequence, \
			id, type, name, \
			size, \
			startx, starty, startz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time, \
			endx, endy, endz):
		Object.__init__(self, sequence, \
			id, type, name, \
			size, \
			startx, starty, startz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time)

		self.length += 8*3
		self.start = self.pos
		self.end   = (endx, endy, endz)
Esempio n. 21
0
 def __init__(self, x, y, char, name, color, use_function=None):
     Object.__init__(self, x, y, char, name, color, blocks=False, always_visible=False)
     self.use_function = use_function        
Esempio n. 22
0
	def __init__(self, rotation, radius, weight=0, position=(0,0)):
		Object.__init__(self, rotation, position)
		# Set parts radius and weight
		self.radius = radius
		self.weight = weight
Esempio n. 23
0
 def __init__(self, model, shape, element):
     Object.__init__(self, model, shape, element)
     self.level = None
     self.time_interval_shot = 1.0
     self.elapsed = 0.0
     self.gun_pos = None
Esempio n. 24
0
 def __init__(self, prototype):
     Object.__init__(self, prototype=prototype)
Esempio n. 25
0
 def __init__(self):
     import proto_functions
     Object.__init__(self, prototype=proto_functions.undefined_proto)
Esempio n. 26
0
    def __init__(self, model, shape, element):
        Object.__init__(self, model, shape, element)
	self.asteroid_type = None
	self.shot_tick_interval = 100
	self.shot_tick_counter = 0
	self.shot = False
Esempio n. 27
0
 def __init__(self, contents):
     import proto_functions
     Object.__init__(self, prototype=proto_functions.tuple_proto)
     self.contents = contents
Esempio n. 28
0
    def __init__(self, model, shape, element):
        Object.__init__(self, model, shape, element)
        self.level = None
	self.time_interval_shot = 1.0
	self.elapsed = 0.0
	self.gun_pos = None
Esempio n. 29
0
    def __init__(self, num):
        import proto_functions

        Object.__init__(self, prototype=proto_functions.num_proto)
        self.num = num
Esempio n. 30
0
 def __init__(self, model, shape, element):
     Object.__init__(self, model, shape, element)
Esempio n. 31
0
 def __init__(self, value):
     import proto_functions
     Object.__init__(self, prototype=proto_functions.bool_proto)
     self.value = value
Esempio n. 32
0
 def __init__(self, model, shape, element):
     Object.__init__(self, model, shape, element)
     
     self.type = element['type'].split('_')[0]
Esempio n. 33
0
    def __init__(self, model, shape, element):
        Object.__init__(self, model, shape, element)

        self.type = element['type'].split('_')[0]