Ejemplo n.º 1
0
    def __init__(self, point, sprite, rank):

        self.party_rank = rank
        self.ai_tag = self.set_ai_tag()

        Actor.__init__(self, point, sprite)
        self.stat_component = self.set_stats()
Ejemplo n.º 2
0
    def __init__(self,
                 obs_dim,
                 act_dim,
                 act_limit,
                 critics,
                 checkpoint_file=None,
                 noise_clip=0.5,
                 target_noise=0.2):
        # TODO fix
        #Actor.__init__(self, obs_dim, act_dim, act_limit, critic, checkpoint_file, noise_clip, target_noise)
        Actor.__init__(self, obs_dim, act_dim, act_limit, critics,
                       checkpoint_file)
        inputs = keras.Input(shape=(obs_dim))

        # TODO make it a param observation multiplier
        obs_mul = 4

        x = layers.Reshape((obs_mul, int(obs_dim / obs_mul)))(inputs)
        #x = layers.TimeDistributed(layers.Conv1D(32, 3, 2), name='conv_1_shared')(x)
        #x = layers.TimeDistributed(layers.Flatten())(x)
        #x = layers.TimeDistributed(layers.Dense(64, activation='relu'))(x)
        x = layers.LSTM(256, return_sequences=True)(x)
        x = layers.LSTM(128, return_sequences=True)(x)
        x = layers.LSTM(64)(x)

        outputs = layers.Dense(act_dim, activation='tanh')(x)
        self.model = keras.Model(inputs=inputs, outputs=outputs)
        self.model._name = 'lstm_actor'
        self.model.summary()
Ejemplo n.º 3
0
    def __init__(self,
                 texto="None",
                 x=0,
                 y=0,
                 magnitud=20,
                 vertical=False,
                 fuente=None,
                 fijo=True):
        """Inicializa el actor.

        :param texto: Texto a mostrar.
        :param x: Posición horizontal.
        :param y: Posición vertical.
        :param magnitud: Tamaño del texto.
        :param vertical: Si el texto será vertical u horizontal, como True o False.
        :param fuente: Nombre de la fuente a utilizar.
        :param fijo: Determina si el texto se queda fijo aunque se mueva la camara. Por defecto está fijo.
        """
        self.__magnitud = magnitud
        self.__vertical = vertical
        self.__fuente = fuente
        self.__color = pilas.colores.blanco
        Actor.__init__(self, x=x, y=y)
        self.centro = ("centro", "centro")
        self.fijo = fijo
        self.texto = texto
Ejemplo n.º 4
0
    def __init__(self,
                 texto="None",
                 x=0,
                 y=0,
                 magnitud=20,
                 vertical=False,
                 fuente=None,
                 fijo=True,
                 ancho=0):
        """Inicializa el actor.

        :param texto: Texto a mostrar.
        :param x: Posición horizontal.
        :param y: Posición vertical.
        :param magnitud: Tamaño del texto.
        :param vertical: Si el texto será vertical u horizontal, como True o False.
        :param fuente: Nombre de la fuente a utilizar.
        :param fijo: Determina si el texto se queda fijo aunque se mueva la camara. Por defecto está fijo.
        :param ancho: El limite horizontal en pixeles para la cadena, el texto de mostrara en varias lineas si no cabe en este límite.
        """
        self._ancho_del_texto = ancho
        self.__magnitud = magnitud
        self.__vertical = vertical
        self.__fuente = fuente
        self.__color = pilas.colores.blanco
        Actor.__init__(self, x=x, y=y)
        self.centro = ("centro", "centro")
        self.fijo = fijo
        self.texto = texto
Ejemplo n.º 5
0
    def __init__(self, name, virtual=False):
        Actor.__init__(self)

        self.name = name
        self.faction = None
        self.living = True
        self.virtual = virtual
Ejemplo n.º 6
0
 def __init__(self, screen, position, velocity, delay=1):
     Actor.__init__(self, screen, position, 10, velocity)
     self.image = pygame.image.load("images/fly.png").convert_alpha()
     self.image_w, self.image_h = self.image.get_size()
     self.delay = delay
     self.acc_time = 0
     self.alive = True
Ejemplo n.º 7
0
Archivo: kama.py Proyecto: lcocox/sss
    def __init__(self, screen, player_vector=None):
        self._screen_w = screen.get_rect().width
        self._screen_h = screen.get_rect().height

        # 1337 = uninitialized... i hope no one ever sees this
        if player_vector and player_vector.mag > 1:
            # Spawn on the side of the screen that player is traveling
            # Using a really shitty heuristic that splits where the player can
            # move into 4 quads.
            if abs(player_vector.angle) < math.pi / 4:
                #right
                pos = (3 * screen.get_rect().width,
                       random.randint(-2 * screen.get_rect().height,
                                      3 * screen.get_rect().height))
            elif player_vector.angle >= math.pi / 4 and player_vector.angle < 3 * math.pi / 4:
                # up
                pos = (random.randint(-2 * screen.get_rect().width,
                                      3 * screen.get_rect().width),
                       -2 * screen.get_rect().height)
            elif abs(player_vector.angle) >= 3 * math.pi / 4 and abs(
                    player_vector.angle) < 5 * math.pi / 4:
                # left
                pos = (-2 * screen.get_rect().width,
                       random.randint(-2 * screen.get_rect().height,
                                      3 * screen.get_rect().height))
            else:
                # down
                pos = (random.randint(-2 * screen.get_rect().width,
                                      3 * screen.get_rect().width),
                       3 * screen.get_rect().height)
        else:
            pos = (random.randint(0,
                                  screen.get_rect().width) +
                   screen.get_rect().width * random.choice(
                       (-2, 2)), random.randint(0,
                                                screen.get_rect().height) +
                   screen.get_rect().height * random.choice((-1, 2)))

        # point towards center
        initial_orient = math.atan2((self._screen_h / 2) - pos[1],
                                    (self._screen_w / 2) - pos[0])

        # Initialize an actor with these values
        Actor.__init__(self, Kama.img_normal[0], pos, initial_orient)

        self._roam_speed = 5
        self._follow_speed = 3.5
        self._charge_speed = 10
        self._health = 0
        self._ROAM, self._FOLLOW, self._CHARGE = 0, 1, 2
        self._refollowed = False

        self._vector = Vector(self._roam_speed, self._angle)
        self._mode = self._ROAM

        center = self.rect.center
        self.image = Kama.img_normal[int(
            math.degrees(-self._angle - math.pi / 2))]
        self.rect = self.image.get_rect(center=center)
        self.radius = self.img_normal[0].get_rect().height / 2
Ejemplo n.º 8
0
 def __init__(self, image):
     Actor.__init__(self, image)
     self.direction = random.randrange(-1, 2) * const.ENEMY_SPEED
     if self.direction > 0:
         self.rect.left = const.SCREENRECT.left
     else:
         self.rect.right = const.SCREENRECT.right
Ejemplo n.º 9
0
	def __init__(self):
		
		# init class members once
		if Player.spriteset is None:
			Player.spriteset = Spriteset.fromfile("hero")
			Player.seq_idle = Sequence.create_sprite_sequence(Player.spriteset, "idle", 4)
			Player.seq_jump = Sequence.create_sprite_sequence(Player.spriteset, "jump", 24)
			Player.seq_run = Sequence.create_sprite_sequence(Player.spriteset, "run", 5)
			Player.spriteset_death = Spriteset.fromfile("effect_death")
			Player.seq_death = Sequence.create_sprite_sequence(Player.spriteset_death, "death-", 5)

		Actor.__init__(self, None, 60, 188)
		self.state = State.Undefined
		self.direction = Direction.Right
		self.xspeed = 0
		self.yspeed = 0
		self.set_idle()
		self.sprite.set_position(self.x, self.y)
		self.width = self.size[0]
		self.height = self.size[1]
		self.medium = Medium.Floor
		self.jump = False
		self.immunity = 0
		self.rectangle = Rectangle(0, 0, self.width, self.height)


		self.palettes = (self.spriteset.palette, Palette.fromfile("hero_alt.act"))
Ejemplo n.º 10
0
	def __init__(self, screen):
		self._screen_w = screen.get_rect().width
		self._screen_h = screen.get_rect().height
		# start in dumb random place, needs changed later
		pos = (random.randint(0, self._screen_w) + self._screen_w*random.choice((-1, 1)),
			   random.randint(0, self._screen_h) + self._screen_h*random.choice((-1, 1)))	
		# Initialize an actor with these values
		Actor.__init__(self, Shooter.img[0], pos, 0)
Ejemplo n.º 11
0
    def __init__(self, map, coord, name, color=None):

        Actor.__init__(self, map, coord, name, color)
        self.team = 'monster'
        self.object_type = 'monster'
        self.turn_component = TurnComponent(self)
        self.set_ai(AIComponent(self))
        self.set_stats(StatComponent(self))
Ejemplo n.º 12
0
 def __init__(self, initial_position, vector_shot_from):
     self._speed = 20
     Actor.__init__(self, Bullet.img[0], initial_position, vector_shot_from.angle)
     self._vector = Vector.product(Vector(self._speed, self._angle), vector_shot_from)
     center = self.rect.center
     self.image = Bullet.img[int(2*math.degrees(- self._angle - math.pi/2))]
     self.rect = self.image.get_rect(center=center)
     self.radius = (Bullet.img[0].get_rect().width + Bullet.img[0].get_rect().height)/4
Ejemplo n.º 13
0
 def __init__(self, texto="None", x=0, y=0, magnitud=20, vertical=False):
     imagen = pilas.mundo.motor.obtener_texto(texto, magnitud, vertical)
     self._definir_area_de_texto(texto, magnitud)
     Actor.__init__(self, imagen, x=x, y=y)
     self.magnitud = magnitud
     self.texto = texto
     self.color = pilas.colores.blanco
     self.centro = ("centro", "centro")
     self.fijo = True
Ejemplo n.º 14
0
    def __init__(self):
        self.managers = [Manager(self, i) for i in xrange(5)]
        self.tasks = []
        self.no_more_pages = False

        for manager in self.managers:
            manager.start()

        Actor.__init__(self)
Ejemplo n.º 15
0
 def __init__(self, texto="None", x=0, y=0, magnitud=20):
     imagen = pilas.mundo.motor.obtener_texto(texto, magnitud)
     self._definir_area_de_texto(texto, magnitud)
     Actor.__init__(self, imagen, x=x, y=y)
     self.magnitud = magnitud
     self.texto = texto
     self.color = pilas.colores.blanco
     self.centro = ("centro", "centro")
     self.fijo = True
Ejemplo n.º 16
0
    def __init__(self, boss, index):
        self.index = index
        self.boss = boss
        self.tasks = []

        self.workers = [Worker(self, i) for i in xrange(4)]
        for worker in self.workers:
            worker.start()

        Actor.__init__(self)
Ejemplo n.º 17
0
 def __init__(self, screen):
     self._screen_w = screen.get_rect().width
     self._screen_h = screen.get_rect().height
     # start in dumb random place, needs changed later
     pos = (random.randint(0, self._screen_w) +
            self._screen_w * random.choice(
                (-1, 1)), random.randint(0, self._screen_h) +
            self._screen_h * random.choice((-1, 1)))
     # Initialize an actor with these values
     Actor.__init__(self, Shooter.img[0], pos, 0)
Ejemplo n.º 18
0
	def __init__(self, item_ref, x, y):

		# init class members once
		if Opossum.spriteset is None:
			Opossum.spriteset = Spriteset.fromfile("enemy_opossum")
			Opossum.seq_walk = Sequence.create_sprite_sequence(Opossum.spriteset, "opossum-", 6)

		Actor.__init__(self, item_ref, x, y)
		self.xspeed = -2
		self.direction = Direction.Left
		self.sprite.set_animation(Opossum.seq_walk, 0)
Ejemplo n.º 19
0
    def __init__(self, master, x: int, y: int):

        Actor.__init__(self, master, self.img, x, y)

        self.rotating_speed = (1 if random.randint(0, 2) == 0 else -1 ) *\
           (random.randrange(0, 3) + 0.5)

        self.move_x = random.randrange(-1, 2) * (random.randint(0, 50) / 10.0)

        self.orig_hitboxes = [Rect(5, 5, 29, 30)]
        self.hitboxes = [Rect(5, 5, 29, 30)]
Ejemplo n.º 20
0
 def __init__(self, xvel, yvel, seed, projimage):
     Actor.__init__(self)
     #self.image = pygame.image.load("").convert_alpha()
     #self.rect.x = x#
     #self.rect.y = y#
     self.projimage = projimage
     self.xvel = xvel
     self.yvel = yvel
     self.frame = 0
     self.health = 1
     random.seed(seed)
Ejemplo n.º 21
0
 def __init__(self, initial_position, vector_shot_from):
     self._speed = 20
     Actor.__init__(self, Bullet.img[0], initial_position,
                    vector_shot_from.angle)
     self._vector = Vector.product(Vector(self._speed, self._angle),
                                   vector_shot_from)
     center = self.rect.center
     self.image = Bullet.img[int(2 *
                                 math.degrees(-self._angle - math.pi / 2))]
     self.rect = self.image.get_rect(center=center)
     self.radius = (Bullet.img[0].get_rect().width +
                    Bullet.img[0].get_rect().height) / 4
Ejemplo n.º 22
0
 def __init__(self, x, y, image):
     Actor.__init__(self)
     self.image = image
     self.rect = self.image.get_rect()
     self.rect.width = 16
     self.rect.height = 16
     self.rect.x = x
     self.rect.y = y
     self.xvel = 12
     self.yvel = 0
     self.health = -1
     self.damage = 10
Ejemplo n.º 23
0
 def __init__(self, x, y):
     Actor.__init__(self)
     self.image = pygame.image.load("gfx/ArmPart1.png").convert_alpha()
     self.image2 = pygame.image.load("gfx/ArmPart3.png").convert_alpha()
     self.rect = self.image.get_rect()
     self.rect.width = 64
     self.rect.height = 64
     self.rect.x = x
     self.rect.y = y
     self.maxhealth = 250
     self.health = self.maxhealth
     self.damage = 2
Ejemplo n.º 24
0
 def __init__(self,world,y,x,name=None):
     Actor.__init__(self,world,y,x)
     self._hp, self.hpmax = 10, 10
     self._running = None
     self.weapon = None
     self.armor = None
     self.xplvl = 1
     self._xp = 0
     if not name:
         self.generate_name()
     else:
         self.desc = name
Ejemplo n.º 25
0
 def __init__(self, screen, position, size, velocity):
     Actor.__init__(self, screen, position, size, velocity)
     self.friction = 0.3
     self.state = Hydrophyte.UNMARKED
     self.images = [pygame.image.load(ur).convert() for ur in Hydrophyte.imgs]
     for im in self.images:
         im.set_colorkey((0,0,0))
     self.images[0] = pygame.transform.scale(self.images[0], (2*size, 2*size))
     self.images[1] = pygame.transform.scale(self.images[1], (2*size, 2*size))
     self.image_w, self.image_h = self.images[0].get_size()
     self.phase_threshold_time = 0.5
     self.sema_drown = 2 # semaphor - when equal to 0, then hydrophyte's drowning
     self.phase_time = 0
Ejemplo n.º 26
0
    def __init__(self, master: "Game", x: int = 0, y: int = 0):

        # hitboxes
        self.orig_hitboxes = [
            Rect(1, 1, 19, 19)
        ]

        self.hitboxes = [
            Rect(1, 1, 19, 19)
        ]

        Actor.__init__(self, master, Surface((100, 100)), x, y)

        self.time_alive_start = time.time()
Ejemplo n.º 27
0
    def __init__(self):

        name = 'Jorgen'

        # premade image
        # image_packet = ('standard', 'rogue', RED)

        # custom image
        ag = AvatarGen('random')
        image_packet = ag.get_image_package(RED)

        stats = self.create_stat_component()

        Actor.__init__(self, name, image_packet, stats)
Ejemplo n.º 28
0
 def __init__(self, initial_position, initial_orientation, fps):
     Actor.__init__(self, PlayerShip.img_normal, initial_position, initial_orientation)
     self._loaded_t = PlayerShip.img_thrust
     self._loaded_ls = PlayerShip.img_lstrafe
     self._loaded_rs = PlayerShip.img_rstrafe
     self._cur_image = self._loaded_image
     
     self._vector = Vector(0, 0)
     self._max_speed = 13
     self._acceleration_rate = 0.5
     self._fire_rate = 50
     self._time_since_fire = 0
     
     self.health = 5
     self.radius = (self._loaded_image.get_rect().width + self._loaded_image.get_rect().height)/4
Ejemplo n.º 29
0
    def __init__(self, value, x, y):

        # init class members once
        if Score.spriteset is None:
            Score.spriteset = Spriteset.fromfile("score")

        Actor.__init__(self, None, int(x), int(y))
        if value is 5:
            self.sprite.set_picture(0)
        elif value is -5:
            self.sprite.set_picture(1)
        elif value is 1:
            self.sprite.set_picture(2)

        self.t0 = game.window.get_ticks()
        self.t1 = self.t0 + 1000
Ejemplo n.º 30
0
Archivo: kama.py Proyecto: a-leut/sss
	def __init__(self, screen, player_vector=None):
		self._screen_w = screen.get_rect().width
		self._screen_h = screen.get_rect().height


		# 1337 = uninitialized... i hope no one ever sees this
		if player_vector and player_vector.mag > 1:
			# Spawn on the side of the screen that player is traveling
			# Using a really shitty heuristic that splits where the player can
			# move into 4 quads.
			if abs(player_vector.angle) < math.pi/4:
				#right
				pos = (3*screen.get_rect().width, random.randint(-2*screen.get_rect().height, 3*screen.get_rect().height))
			elif player_vector.angle >= math.pi/4 and player_vector.angle <	3*math.pi/4:
				# up
				pos = (random.randint(-2*screen.get_rect().width, 3*screen.get_rect().width), -2*screen.get_rect().height)
			elif abs(player_vector.angle) >= 3*math.pi/4 and abs(player_vector.angle) < 5*math.pi/4:
				# left
				pos = (-2*screen.get_rect().width, random.randint(-2*screen.get_rect().height, 3*screen.get_rect().height))
			else:
				# down
				pos = (random.randint(-2*screen.get_rect().width, 3*screen.get_rect().width), 3*screen.get_rect().height)
		else:
			pos = (random.randint(0, screen.get_rect().width) + screen.get_rect().width*random.choice((-2, 2)),
				   random.randint(0, screen.get_rect().height) + screen.get_rect().height*random.choice((-1, 2)))
		
		# point towards center
		initial_orient = math.atan2((self._screen_h/2)-pos[1], (self._screen_w/2)-pos[0])

		# Initialize an actor with these values
		Actor.__init__(self, Kama.img_normal[0], pos, initial_orient)
		
		self._roam_speed = 5
		self._follow_speed = 3.5
		self._charge_speed = 10
		self._health = 0
		self._ROAM, self._FOLLOW, self._CHARGE = 0, 1, 2
		self._refollowed = False

		self._vector = Vector(self._roam_speed, self._angle)
		self._mode = self._ROAM
		
		center = self.rect.center
		self.image = Kama.img_normal[int(math.degrees(-self._angle - math.pi/2))]
		self.rect = self.image.get_rect(center = center)
		self.radius = self.img_normal[0].get_rect().height/2
Ejemplo n.º 31
0
    def __init__(self, initial_position, initial_orientation, fps):
        Actor.__init__(self, PlayerShip.img_normal, initial_position,
                       initial_orientation)
        self._loaded_t = PlayerShip.img_thrust
        self._loaded_ls = PlayerShip.img_lstrafe
        self._loaded_rs = PlayerShip.img_rstrafe
        self._cur_image = self._loaded_image

        self._vector = Vector(0, 0)
        self._max_speed = 13
        self._acceleration_rate = 0.5
        self._fire_rate = 50
        self._time_since_fire = 0

        self.health = 5
        self.radius = (self._loaded_image.get_rect().width +
                       self._loaded_image.get_rect().height) / 4
Ejemplo n.º 32
0
 def __init__(self, screenSize, image):
     Actor.__init__(self)
     self.health = -1
     self.damage = 999
     self.screenSize = screenSize
     self.image = image
     self.rect = self.image.get_rect()
     self.rect.width = 96
     self.rect.height = self.screenSize[1]
     self.rect.x = self.screenSize[0]
     self.rect.y = 0
     self.xvel = 3
     self.subimage = 0 #0 = fully closed
     self.open = False # 0 if closed, 1 if open
     self.subimagemax = 5#NUMBEROFSUBIMAGES-1
     self.toggle = -1 #direction of subimage change
     self.counter = 0
     self.countermax = 40
Ejemplo n.º 33
0
    def __init__(self, texto="None", x=0, y=0, magnitud=20, vertical=False, fuente=None):
        """Inicializa el actor.

        :param texto: Texto a mostrar.
        :param x: Posición horizontal.
        :param y: Posición vertical.
        :param magnitud: Tamaño del texto.
        :param vertical: Si el texto será vertical u horizontal, como True o False.
        :param fuente: Nombre de la fuente a utilizar.
        """
        imagen = pilas.mundo.motor.obtener_texto(texto, magnitud, vertical, fuente)
        self._definir_area_de_texto(texto, magnitud)
        Actor.__init__(self, imagen, x=x, y=y)
        self.magnitud = magnitud
        self.texto = texto
        self.color = pilas.colores.blanco
        self.centro = ("centro", "centro")
        self.fijo = True
Ejemplo n.º 34
0
    def __init__(self, screenSize, playerprojectile):
        #sound
        self.whoosh = pygame.mixer.Sound("sfx/whoosh.wav")
        self.whoosh.play()
        self.buzz = pygame.mixer.Sound("sfx/buzz.wav")
        self.buzzcountmax = 9
        self.buzzcount = 0
        
        Actor.__init__(self)
        self.screenSize = screenSize
        self.image = pygame.image.load("gfx/player.png").convert_alpha()
        self.playerprojectile = playerprojectile
        self.rect = self.image.get_rect()
        self.enter = True
        self.rect.width = 48
        self.rect.height = 48
        self.rect.x = -48
        self.rect.y = self.screenSize[1]/2 - self.rect.height/2
        #shield stuff
        self.shieldimage = pygame.image.load("gfx/shield.png").convert_alpha()
        self.shieldenergy = 300
        self.shield = False
        self.immortal = 60
        #Motion variables.
        self.xvelmin = 1
        self.yvelmin = 1
        self.xvelmax = 6
        self.yvelmax = 6
        self.xvel = self.xvelmin
        self.yvel = self.yvelmin
        #collision variables
        self.nearpower = False #near the white blood cells, determines type of shot
        #Shooting variables.
        self.shootnormalmax = 4 #time (frames) between normal shots
        self.shootnormalwait = self.shootnormalmax
        self.shootpowermax = 8 #time (frames) between power shots
        self.shootpowerwait = self.shootpowermax
        self.damage = 999
        self.fullhealth = 150
        self.health = self.fullhealth

        self.subimage = 0
        self.subimagemax = 3
        self.input = [False, False, False, False, False, False] #left, right, up, down, shoot, shield
Ejemplo n.º 35
0
 def __init__(self):
     Actor.__init__(self)
     self.glut_sphere = GlutSphereActor()
     self.glut_cylinder = GlutCylinderActor()
     self.color = [0.15, 0.15, 0.80]
     sphere = Vec3([0,0,0])
     sphere.center = Vec3([0,0,0])
     sphere.radius = 1.0
     sphere.color = self.color
     sphere.index = 0
     # self.sphere_array = VertexArrayTest()
     self.sphere_array = SphereImposterArray([sphere,])
     buffers = atom_attributes
     # self.sphere_array = NewSphereArray(buffers)
     cylinder = Vec3([0,0,0])
     cylinder.center = Vec3([0,0,0])
     cylinder.radius = 1.0
     cylinder.height = 2.0
     self.cylinder_array = CylinderImposterArray([cylinder,])
Ejemplo n.º 36
0
 def __init__(self, melee):
     Actor.__init__(self, melee)
             
     # Randomize velocity
     ub = melee.aabb.upper_bound
     lb = melee.aabb.lower_bound
     x = randrange(lb.x, ub.x)
     y = randrange(lb.y, ub.y)
     av = 0.1
     vx = randrange(-50.0, 50.0)
     vy = randrange(-50.0, 50.0)
     
     # Create body
     bodydef = Body()
     bodydef.ccd = True
     bodydef.position = Vec2(x, y) 
     self.body = melee.world.append_body(bodydef)
     self.body.angular_velocity = av
     self.body.linear_velocity = Vec2(vx, vy)
     
     # Create shape
     self.radius = 1.0
     density = 10.0
     
     c1 = Circle()
     c1.radius = self.radius 
     self.c1_local = -1.0, 1.0
     c1.local_position = Vec2(*self.c1_local)
     c1.density = density
     s1 = self.body.append_shape(c1)
     
     c2 = Circle()
     c2.radius = self.radius 
     self.c2_local = 1.0, 1.0
     c2.local_position = Vec2(*self.c2_local)
     c2.density = density
     s2 = self.body.append_shape(c2)
     
     self.body.set_mass_from_shapes()
     
     # Register shapes for collision callbacks
     melee.contact_register[hash(s1)] = self
     melee.contact_register[hash(s2)] = self
Ejemplo n.º 37
0
Archivo: texto.py Proyecto: apehua/m6
    def __init__(self, texto="None", x=0, y=0, magnitud=20, vertical=False, fuente=None, fijo=True):
        """Inicializa el actor.

        :param texto: Texto a mostrar.
        :param x: Posición horizontal.
        :param y: Posición vertical.
        :param magnitud: Tamaño del texto.
        :param vertical: Si el texto será vertical u horizontal, como True o False.
        :param fuente: Nombre de la fuente a utilizar.
        :param fijo: Determina si el texto se queda fijo aunque se mueva la camara. Por defecto está fijo.
        """
        self.__magnitud = magnitud
        self.__vertical = vertical
        self.__fuente = fuente
        self.__color = pilas.colores.blanco
        Actor.__init__(self, x=x, y=y)
        self.centro = ("centro", "centro")
        self.fijo = fijo
        self.texto = texto
Ejemplo n.º 38
0
 def __init__(self, x, y, xvel = -5, yvel = 0):
     Actor.__init__(self)
     self.image = pygame.image.load("gfx/whitebloodcell.png").convert_alpha()
     self.rect = self.image.get_rect()
     self.rect.x = x
     self.rect.y = y
     self.auraimage = pygame.image.load("gfx/WhiteAura.png").convert_alpha()
     self.aurarect = self.auraimage.get_rect()
     # self.aurarect.width = 400
     # self.aurarect.width = 400
     self.aurarect.center = self.rect.center
     #self.aurarect.centery = self.rect.centery
     # self.aurarect.x = x - 128
     # self.aurarect.y = y - 128
     self.xvel = xvel
     self.yvel = yvel
     self.angle = 0                      #Indicates rotation of the image
     self.frame = 0                      #Used on the aura
     self.health = -1
     self.damage = 999
Ejemplo n.º 39
0
    def __init__(self, master, x: int = 0, y: int = 0):

        # Create actor

        self.pid = len(master.players) % MAX_COLORS + 1
        self.sprite_idle = pygame.image.load("resources" + os.path.sep +\
         "player_{}_idle.png".format(self.pid))
        self.sprite_left = pygame.image.load("resources" + os.path.sep +\
         "player_{}_left.png".format(self.pid))
        self.sprite_right = pygame.image.load("resources" + os.path.sep +\
         "player_{}_right.png".format(self.pid))

        Actor.__init__(self, master, self.sprite_idle, x, y)

        # Choose sprite
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y

        # original collision boxes
        # They are used for hitbox update when moving
        self.orig_hitboxes = [
            Rect(17, 30, 6, 4),  # check front collision first
            Rect(15, 23, 9, 7),
            Rect(11, 15, 18, 8),
            Rect(7, 7, 26, 8),
            Rect(3, 0, 34, 7)
        ]

        self.hitboxes = [
            Rect(17, 30, 6, 4),
            Rect(15, 23, 9, 7),
            Rect(11, 15, 18, 8),
            Rect(7, 7, 26, 8),
            Rect(3, 0, 34, 7)
        ]

        self.update_hitboxes()

        # player controller
        self.controller = Player_Controller(self)
Ejemplo n.º 40
0
    def __init__(self, texto="None", x=0, y=0, magnitud=20, vertical=False, fuente=None, fijo=True, ancho=0):
        """Inicializa el actor.

        :param texto: Texto a mostrar.
        :param x: Posición horizontal.
        :param y: Posición vertical.
        :param magnitud: Tamaño del texto.
        :param vertical: Si el texto será vertical u horizontal, como True o False.
        :param fuente: Nombre de la fuente a utilizar.
        :param fijo: Determina si el texto se queda fijo aunque se mueva la camara. Por defecto está fijo.
        :param ancho: El limite horizontal en pixeles para la cadena, el texto de mostrara en varias lineas si no cabe en este límite.
        """
        self._ancho_del_texto = ancho
        self.__magnitud = magnitud
        self.__vertical = vertical
        self.__fuente = fuente
        self.__color = pilas.colores.blanco
        Actor.__init__(self, x=x, y=y)
        self.centro = ("centro", "centro")
        self.fijo = fijo
        self.texto = texto
Ejemplo n.º 41
0
 def __init__(self, x, y, screenSize):
     Actor.__init__(self)
     self.screenSize = screenSize
     self.image = []
     self.image.append(pygame.image.load("gfx/Boss1.png").convert_alpha())
     self.image.append(pygame.image.load("gfx/Boss3.png").convert_alpha())
     self.image.append(pygame.image.load("gfx/Boss5.png").convert_alpha())
     self.rect = self.image[0].get_rect()
     self.eyeimage1 = pygame.image.load("gfx/Eye1.png").convert_alpha()
     self.eyeimage2 = pygame.image.load("gfx/Eye2.png").convert_alpha()
     self.eyerect = self.eyeimage1.get_rect()
     self.projimage = pygame.image.load("gfx/enemyprojectile.png").convert_alpha()
     self.rect.width = 200
     self.rect.height = 400
     self.enter = True
     self.xgoal = x
     self.rect.x = self.xgoal+168
     self.rect.y = y + 40
     self.eyerect.x = self.rect.left - 32 + self.rect.x - self.xgoal
     self.eyerect.y = self.rect.centery - 32
     self.maxhealth = 800
     self.health = self.maxhealth
     self.damage = 999
     #Arms
     self.arms = [[],[]]
     self.armvel = 3
     self.armdir = 1
     self.armtime = 30
     #Firerate
     self.s1burstrate = 5
     self.s1firerate = 20
     self.s1burst = self.s1burstrate
     self.s1fire = self.s1firerate
     self.s3firerate = 50
     self.s3fire = self.s3firerate
     #animation stuff
     self.frame = 0
     self.framemax = 4
     self.phase = 0
     self.spawnedarms = False
Ejemplo n.º 42
0
 def __init__(self, melee):
     Actor.__init__(self, melee)
     
     self.damage = 1
     #from utils import squirtle
     file = "data/planet.svg"
     #self.svg = squirtle.SVG(file, anchor_x='center', anchor_y='center')
             
     # Create body
     bodydef = Body()
     bodydef.ccd = True
     bodydef.position = Vec2(0, 0) 
     self.body = melee.world.append_body(bodydef)
     
     # Create shape
     self.radius = 7
     circledef = Circle()
     circledef.radius = self.radius 
     shape = self.body.append_shape(circledef)
     
     # Register shapes for collision callbacks
     melee.contact_register[hash(shape)] = self
Ejemplo n.º 43
0
 def __init__(self, pos, world, eventMgr, pickup_type, duration):
     Actor.__init__(self)
     self.em = eventMgr
     eventMgr.register(self)
     self.world = world
     
     self.picked = False
     self.duration = duration
     self.pickup_type = pickup_type
     
     self.image = pygame.image.load("media/orb.png")
     self.rect = self.image.get_rect()
     self.rect.topleft = pos
     self.rect.width = 32
     self.rect.height = 32
     
     bodyDef = Box2D.b2BodyDef()
     bodyDef.type = Box2D.b2_staticBody
     bodyDef.position = (B2SCALE * (self.rect.left + 0.5 * self.rect.width), B2SCALE * (self.rect.top + 0.5 * self.rect.height))
     self.body = world.b2World.CreateBody(bodyDef)
     r = B2SCALE * self.rect.width * 0.5
     self.body.CreateCircleFixture(radius=r)
Ejemplo n.º 44
0
 def __init__(self, image):
     Actor.__init__(self, image)
     self.alive = True
     self.reloading = False
     self.rect.centerx = const.SCREENRECT.centerx
     self.rect.bottom = const.SCREENRECT.bottom
Ejemplo n.º 45
0
 def __init__(self, number=1):
     Actor.__init__(self)
     self.instance = number
Ejemplo n.º 46
0
 def __init__(self, initialPosition, initialDirection, speed, image):
     Actor.__init__(self, initialPosition, initialDirection, speed, image)
Ejemplo n.º 47
0
 def __init__(self, initial_pos):
     Actor.__init__(self, Arrow.img, initial_pos, 0)
Ejemplo n.º 48
0
 def __init__(self, boss, index):
     self.boss = boss
     self.index = index
     Actor.__init__(self)
Ejemplo n.º 49
0
 def __init__(self, image):
     Actor.__init__(self, image)
     self.alive = True
     self.reloading = False
     self.rect.centerx = screen.centerx
     self.rect.bottom = screen.bottom
Ejemplo n.º 50
0
 def __init__(self, pos):
     Actor.__init__(self, Time.img, pos, 0)
Ejemplo n.º 51
0
 def __init__(self, pos):
     Actor.__init__(self, HealthBar.imgs[4], (0, 0), 0)
     self.rect.topleft = pos
Ejemplo n.º 52
0
 def __init__(self, world, x, y):
     Actor.__init__(self, world, x, y, ZOMBIE_IMAGE, (90, 125),
                    ZOMBIE_MAX_SPEED, ROTATION_SPEED)
     self.hide_timer = 0
     self.needs_to_change_cover = False
     self.kamikaze = False
Ejemplo n.º 53
0
	def __init__(self, x, y, spriteset, sequence):
		self.spriteset = spriteset
		Actor.__init__(self, None, x, y)
		self.sprite.set_animation(sequence, 1)
Ejemplo n.º 54
0
 def __init__(self):
     Actor.__init__(self)
     self.is_player = True
Ejemplo n.º 55
0
    def __init__(self, given_opts = {}):
        ''' Initialize a new instance of the AMQPActor monitor

        :param given_opts: The default options to the process
        '''
        Actor.__init__(self, given_opts)
Ejemplo n.º 56
0
 def __init__(self):
     self.workers = {}
     Actor.__init__(self)
Ejemplo n.º 57
0
 def __init__(self):
     self.workers = {}
     Actor.__init__(self)
Ejemplo n.º 58
0
 def __init__(self, image, player):
     Actor.__init__(self, image)
     self.rect.centerx = player.rect.centerx
     self.rect.top = player.rect.top - 5
Ejemplo n.º 59
0
 def __init__(self, pos):
     Actor.__init__(self, HealthBar.imgs[4], (0,0), 0)
     self.rect.topleft = pos
Ejemplo n.º 60
0
 def __init__(self, initial_pos):
     Actor.__init__(self, Arrow.img, initial_pos, 0)