예제 #1
0
    def start_game(self):
        from src.elements.Level import load_level2
        from static.maps.level1 import level1

        levels = [
            load_level2(level1),
            load_level(path('static/maps/level2.json')),
            load_level(path('static/maps/level3.json')),
            load_level(path('static/maps/level4.json')),
            load_level(path('static/maps/level5.json')),
        ]
        self.set_state(InGame(self, levels))
        return
예제 #2
0
    def __init__(self, x, y, x_speed=0, y_speed=0, frecuencia=BULLET_FRECUENCY,
                 size=CANNON_SIZE, bullet_radius=BULLET_RADIUS, bullet_damage=BULLET_DAMAGE):
        super().__init__(size, size, x, y)

        # posición
        self.image = pygame.image.load(path('static/img/cannon.png'))
        # escalar a tamaño
        self.image = pygame.transform.smoothscale(self.image, (size, size))
        # voltear horizontalmente
        self.image = pygame.transform.flip(self.image, x_speed < 0, False)

        # obtener rectángulo antes de rotar para evitar que cambie el tamaño para colisiones
        self.rect = self.image.get_rect().move(x, y)

        # rotar según angulo de disparo
        # TODO balas verticales
        self.image = pygame.transform.rotate(self.image, -math.degrees(math.atan(y_speed / x_speed)))

        # obtener rect y corregir posición de dibujo
        self.pos = self.image.get_rect()
        self.pos.center = self.rect.center

        # para lanzar proyectiles
        self.bullet_group = None
        self.frecuencia = frecuencia
        self.iteracion = 0

        # propiedades de balas
        self.x_speed = x_speed
        self.y_speed = y_speed
        self.bullet_radius = bullet_radius
        self.bullet_damage = bullet_damage
예제 #3
0
    def __init__(self,
                 text,
                 x=0,
                 y=0,
                 color=(0, 0, 0),
                 size=30,
                 center=False,
                 antialias=True):
        global fonts
        if size not in fonts:
            fonts[size] = pygame.font.Font(path("static/freesansbold.ttf"),
                                           size)

        self.text = fonts[size].render(text, antialias, color)

        self.rect = self.text.get_rect()
        self.set_pos(x, y, center)
예제 #4
0
 def __init__(self, driver, img: str = 'Anouk'):
     self.driver = driver
     self.char = Character(path(f'static/img/{img}.png'), x=400, y=300)
예제 #5
0
channels = [
    pygame.mixer.Channel(0),  # player1 jump
    pygame.mixer.Channel(1),  # player2 jump
    pygame.mixer.Channel(2),  # player3 jump
    pygame.mixer.Channel(3),  # player4 jump
    pygame.mixer.Channel(4),  # player1 hit
    pygame.mixer.Channel(5),  # player2 hit
    pygame.mixer.Channel(6),  # player3 hit
    pygame.mixer.Channel(7),  # player4 hit
    pygame.mixer.Channel(8),  # cannons
    pygame.mixer.Channel(9),  # coins
    pygame.mixer.Channel(10),  # fondo
    pygame.mixer.Channel(11),  #
]

jump_sound = pygame.mixer.Sound(path("static/sounds/ha.wav"))
hit_sound = pygame.mixer.Sound(path("static/sounds/ah.wav"))
fire_sound = pygame.mixer.Sound(path("static/sounds/pium.wav"))
coin_sound = pygame.mixer.Sound(path("static/sounds/prim.wav"))
background_sound = pygame.mixer.Sound(path("static/sounds/mii2.wav"))


def play_jump(player_id):
    channels[player_id % 4].play(jump_sound)
    return


def play_hit(player_id):
    channels[player_id % 4 + 4].play(hit_sound)
    return
예제 #6
0
 def img_path(self):
     return path(f'static/img/{SPRITE_LIST[self.img]}.png')
예제 #7
0
    def __init__(self, x, y):
        super().__init__()
        self.image = pygame.image.load(path('static/img/FrenCoin.png'))
        self.image = pygame.transform.smoothscale(self.image, (COIN_SIZE, COIN_SIZE))

        self.rect = self.image.get_rect().move((x, y))