Beispiel #1
0
    def __init__(self, position: Vector2, p_type=None):
        Sprite.__init__(self,
                        pyglet.resource.image("block_template.png"),
                        opacity=0)
        self.position = position
        self.anchor = Vector2()

        try:
            self.p_type = p_type == None and sort_new_piece() or p_type
            blocks_offsets = Pieces[self.p_type][
                0]  # De acordo com o tipo retorna lista com ofsets dos blocos para formar a peca
        except Exception as e:
            game_controller.pieces_generated["Square"] += 1
            self.p_type = "Square"  # peca padrao caso valor passado seja incorreto
            blocks_offsets = Pieces[self.p_type][0]

        self.is_stopped = True  # Booleano para checar se a peca ja parou de cair

        # Inicializa os blocos nas posicoes obtidas do dicionario de pecas
        for offset in blocks_offsets:
            blk_pos = getPosition(offset)
            block = Block(blk_pos,
                          block_color=Pieces[self.p_type][1],
                          b_type='Piece')
            self.add(block)
            block.update_cshape_center(
                blk_pos)  # realinha o centro do retangulo de colisao
    def __init__(self, map_manager, id):
        """initializer"""
        gallery = Gallery()
        self.rotation_vars = {}
        self.rotation_vars["nomads"] = {}
        self.rotation_vars["mammoth_herd"] = {}
        self.rotation_vars["BLANK"] = {}

        self.rotation_vars["BLANK"]["sprite"] = gallery.content["switch"][
            "off"]
        self.rotation_vars["nomads"]["sprite"] = gallery.content["actor"][
            "nomads"]
        self.rotation_vars["mammoth_herd"]["sprite"] = gallery.content[
            "actor"]["mammoth_herd"]

        Sprite.__init__(self, self.rotation_vars["BLANK"]["sprite"])
        self.counter = 0
        self.map = map_manager
        self.roamer = director.core.query_mover("Roamer" + str(id))
        self.ID = id
        self.transarctica = director.core.query_mover("Transarctica")
        self.driver = TrainDriver()
        self.driver.target = self
        self.config = Config()
        self.anchor = self.config.tile_width / 2, self.config.tile_width / 2
        self.next_update = 0
        self.max_forward_speed = 100 / self.config.km_per_tile * self.config.tile_width / 3600
Beispiel #3
0
    def __init__(self, image, pos, maplayer):
        Sprite.__init__(self, image)
        RectMapCollider.__init__(self)

        x, y = pos
        self.position = Vector2(x, y)
        self.cshape = AARectShape(self.position, self.width/2, self.height/2)

        self.maplayer = maplayer
Beispiel #4
0
    def __init__(self, id, rotation, pos, app):
        self.app = app
        self.id = id

        self.pos = pos
        Sprite.__init__(self, 'bullet.png', pos)

        self.rotation = rotation

        self.schedule(self.update)
Beispiel #5
0
    def __init__(self):
        image = common.load_image('dragon/head.png')
        self.normal = image
        self.touch = common.load_image('dragon/head_touch.png')
        Sprite.__init__(self, image)
        self.anchor_x, self.anchor_y = 200, 200
        self.position = 300, 300
        self.schedule_interval(self.update, 1/60.0)
        self._create_body()

        rotate = Accelerate(RotateBy(20, 1), 2)
Beispiel #6
0
    def __init__(self, speed=200, position=None):
        Sprite.__init__(self, 'img/ball_64x64.png')
        self.__speed = speed

        if not position:
            self.position = self.randomPosition()
        else:
            self.position = position

        center_x, center_y = self.position
        self.cshape = cm.CircleShape(eu.Vector2(center_x, center_y), 32)
Beispiel #7
0
 def __init__(self,
              spriteFilepath: str,
              position: tuple = (0, 0),
              domain=None):
     Sprite.__init__(self, spriteFilepath)
     self.position = position
     self.cshape = CircleShape(eu.Vector2(*self.position), TILE_WIDTH)
     self.setPos(self.position)
     self.domain = domain
     self.layer = None
     # use correct names for functions
     self.schedule(self.__update)
Beispiel #8
0
    def __init__(self, position: Vector2, block_color, scale=1, b_type=""):
        self.block_color = block_color
        self.b_type = b_type

        image = get_img_by_color(block_color)
        Sprite.__init__(self, image=image, position=position, scale=scale)

        if (not b_type == ''):
            #retangulo para calculo de colisao, como coodenadas realtivas a layer do jogo principal
            pos = game_controller.game_controller.main_game.point_to_local(
                (self.x, self.y))
            self.cshape = collision_model.AARectShape(pos, self.width / 2,
                                                      self.height / 2)
Beispiel #9
0
 def __init__(self, name, state=CardState.FACE_UP):
     image = pyglet.image.load('res/textures/wood3.png')
     Sprite.__init__(self, image)
     Tile.__init__(self, name, None, image)
     # super(Card, self).__init__('res/textures/fabric11.png')
     # super(Card, self).__init__('res/textures/grass5.png')
     file_name = 'res/graphes/' + name
     self.graphe = Sprite(file_name)
     self.add(self.graphe)
     self._state = self.set_state(state)
     self._name = name
     self._played = False
     self._edge = [None, None, None, None]
     self._vertex = [None, None, None, None]
Beispiel #10
0
 def __init__(self, id, pos, app):
     """Initializes a new tank sprite."""
     
     Sprite.__init__(self, self.image_file, pos)
     
     # Unique ID to reference this tank through the network. Generated
     # by the server.
     self.id = id
     
     # Keep a reference to the main application so we can access its
     # attributes when needed.
     self.app = app
     
     # The tank's current speed.
     self.speed = 0
     
     self.schedule(self.update)
     
     self.rotation_signum = 0
     self.driving_signum = 0
     
     self.updated_by_network = False
Beispiel #11
0
    def __init__(self, name="Hero"):
        self.name = name
        Sprite.__init__(self, "sources/man.gif")

        self.nameLabel = Label(name, 
                anchor_x='center', anchor_y="bottom")
        self.nameLabel.position = (0, self.height/2)
        self.add(self.nameLabel)

        barPosition = (-self.width/2, self.height/2)
        self.bloodBar = Sprite("sources/bloodBar.png", 
                position=barPosition, anchor=(1,1))
        self.healthBar = Sprite("sources/healthBar.png", 
                position=barPosition, anchor=(0,0))
        self.shieldBar = Sprite("sources/shieldBar.png", 
                position=barPosition, anchor=(0,0))

        self.add(self.bloodBar, z = 0)
        self.add(self.healthBar, z = 1)
        self.add(self.shieldBar, z = 2)

        self.health = 100
        self.shield = 0
        self.updateHealth()
Beispiel #12
0
 def __init__(self):
     image = common.load_image('dragon/part.png')
     Sprite.__init__(self, image)
    def __init__(self, map_manager):
        """initializer"""
        gallery = Gallery()

        self.rotation_vars = {}
        self.rotation_vars["NF"] = {}
        self.rotation_vars["SR"] = {}
        self.rotation_vars["BF"] = {}
        self.rotation_vars["DR"] = {}
        self.rotation_vars["EF"] = {}
        self.rotation_vars["WR"] = {}
        self.rotation_vars["CF"] = {}
        self.rotation_vars["AR"] = {}
        self.rotation_vars["SF"] = {}
        self.rotation_vars["NR"] = {}
        self.rotation_vars["DF"] = {}
        self.rotation_vars["BR"] = {}
        self.rotation_vars["WF"] = {}
        self.rotation_vars["ER"] = {}
        self.rotation_vars["AF"] = {}
        self.rotation_vars["CR"] = {}
        self.rotation_vars["BLANK"] = {}

        self.rotation_vars["NF"]["sprite"] = gallery.content["actor"][
            "engine000"]
        self.rotation_vars["SR"]["sprite"] = gallery.content["actor"][
            "engine000"]
        self.rotation_vars["BF"]["sprite"] = gallery.content["actor"][
            "engine045"]
        self.rotation_vars["DR"]["sprite"] = gallery.content["actor"][
            "engine045"]
        self.rotation_vars["EF"]["sprite"] = gallery.content["actor"][
            "engine090"]
        self.rotation_vars["WR"]["sprite"] = gallery.content["actor"][
            "engine090"]
        self.rotation_vars["CF"]["sprite"] = gallery.content["actor"][
            "engine135"]
        self.rotation_vars["AR"]["sprite"] = gallery.content["actor"][
            "engine135"]
        self.rotation_vars["SF"]["sprite"] = gallery.content["actor"][
            "engine180"]
        self.rotation_vars["NR"]["sprite"] = gallery.content["actor"][
            "engine180"]
        self.rotation_vars["DF"]["sprite"] = gallery.content["actor"][
            "engine225"]
        self.rotation_vars["BR"]["sprite"] = gallery.content["actor"][
            "engine225"]
        self.rotation_vars["WF"]["sprite"] = gallery.content["actor"][
            "engine270"]
        self.rotation_vars["ER"]["sprite"] = gallery.content["actor"][
            "engine270"]
        self.rotation_vars["AF"]["sprite"] = gallery.content["actor"][
            "engine315"]
        self.rotation_vars["CR"]["sprite"] = gallery.content["actor"][
            "engine315"]
        self.rotation_vars["BLANK"]["sprite"] = gallery.content["switch"][
            "off"]

        self.rotation_vars["NF"]["smoke_angle"] = 270
        self.rotation_vars["SR"]["smoke_angle"] = 90
        self.rotation_vars["BF"]["smoke_angle"] = 225
        self.rotation_vars["DR"]["smoke_angle"] = 45
        self.rotation_vars["EF"]["smoke_angle"] = 180
        self.rotation_vars["WR"]["smoke_angle"] = 0
        self.rotation_vars["CF"]["smoke_angle"] = 135
        self.rotation_vars["AR"]["smoke_angle"] = 315
        self.rotation_vars["SF"]["smoke_angle"] = 90
        self.rotation_vars["NR"]["smoke_angle"] = 270
        self.rotation_vars["DF"]["smoke_angle"] = 45
        self.rotation_vars["BR"]["smoke_angle"] = 225
        self.rotation_vars["WF"]["smoke_angle"] = 0
        self.rotation_vars["ER"]["smoke_angle"] = 180
        self.rotation_vars["AF"]["smoke_angle"] = 315
        self.rotation_vars["CR"]["smoke_angle"] = 135
        self.rotation_vars["BLANK"]["smoke_angle"] = 0

        self.rotation_vars["NF"]["smoke_pos"] = -2, 17
        self.rotation_vars["SR"]["smoke_pos"] = -2, 17
        self.rotation_vars["BF"]["smoke_pos"] = 1, 26
        self.rotation_vars["DR"]["smoke_pos"] = 1, 26
        self.rotation_vars["EF"]["smoke_pos"] = 18, 17
        self.rotation_vars["WR"]["smoke_pos"] = 18, 17
        self.rotation_vars["CF"]["smoke_pos"] = 25, -1
        self.rotation_vars["AR"]["smoke_pos"] = 25, -1
        self.rotation_vars["SF"]["smoke_pos"] = -2, -17
        self.rotation_vars["NR"]["smoke_pos"] = -2, -17
        self.rotation_vars["DF"]["smoke_pos"] = -26, -2
        self.rotation_vars["BR"]["smoke_pos"] = -26, -2
        self.rotation_vars["WF"]["smoke_pos"] = -18, 17
        self.rotation_vars["ER"]["smoke_pos"] = -18, 17
        self.rotation_vars["AF"]["smoke_pos"] = -5, 30
        self.rotation_vars["CR"]["smoke_pos"] = -5, 30
        self.rotation_vars["BLANK"]["smoke_pos"] = -18, 17

        self.is_moving = False
        Sprite.__init__(self, self.rotation_vars["BLANK"]["sprite"])
        self.counter = 0
        self.map = map_manager
        self.transarctica = director.core.query_mover("Transarctica")
        self.transarctica.map = map_manager
        self.driver = TrainDriver()
        self.driver.target = self
        self.config = Config()
        self.break_sound_source = load('music/stop.wav')  #, streaming=False)
        #self.break_sound.volume=0.5 * self.config.sound_switch

        self.anchor = self.config.tile_width / 2, self.config.tile_width / 2
        #self.transarctica.current_position = self.config.start_position
        self.last_position = {
            "X": self.transarctica.current_position["X"],
            "Y": self.transarctica.current_position["Y"]
        }
        self.max_forward_speed = 450 / self.config.km_per_tile * self.config.tile_width / 3600
        self.position = (-1, -1)
        self.last_break_status = self.transarctica.is_break_released
        self.last_reverse_status = self.transarctica.is_in_reverse
        self.last_direction = self.transarctica.direction
        self.arriving_from = ""
        self.leaving_toward = ""
        self.on_tile = "none"
        self.next_turn_at = (-1, -1)
        self.tile_entry_point = (-1, -1)

        self.smoke = Smoke()
        self.smoke.blend_additive = False
        self.smoke.position = self.rotation_vars["NF"]["smoke_pos"]
        self.smoke.life = 1
        self.smoke.speed = 30
        self.smoke.start_color = Color(0.20, 0.20, 0.20, 0.40)
        self.smoke.size = 15.0
        self.smoke.total_particles = 60
        self.add(self.smoke)
        self.prev_dirs = ""
Beispiel #14
0
 def __init__(self, x, y):
     name = 'asteroid_' + str(random.randint(1, 4)) + '.png'
     Sprite.__init__(self, name, position=(x, y), scale=0.7)
     self.radius = min(self.width, self.height) // 2
Beispiel #15
0
 def __init__(self):
     Sprite.__init__(self,'img/tetris/bg.png',scale=.4)
     self.image_anchor_y = 0
     self.position = W/2,0
Beispiel #16
0
 def __init__(self, speed=120, position=(320, 10)):
     Sprite.__init__(self, 'img/bouncer64x14.png')
     self.__speed = speed
     self.position = position
     center_x, center_y = self.position
     self.cshape = AARectShape(eu.Vector2(center_x, center_y), 32, 7)
Beispiel #17
0
    def __init__(self, pos, maplayer):
        Sprite.__init__(self, "ball.png", pos)
        RectMapCollider.__init__(self, "slide")

        self.maplayer = maplayer
        self.velocity = (0, 0)