Esempio n. 1
0
    def __init__(self, hud: HudManager):
        self.hud = hud
        self.window = hud.get_window()
        self.mouse = hud.get_window().get_mouse()
        self.fundo = GameImage(BACKGROUND_HOME)
        self.time = 0
        self.select = False
        points_background = pygame.transform.scale(
            GameImage(SOUND_BACKGROUND).image, (1100, 800))
        self.point_background = GameImage(SOUND_BACKGROUND)
        self.point_background.image = points_background
        self.point_background.set_position(
            self.window.width / 2 - points_background.get_width() / 2, 0)

        self.text = CenterText(hud.get_window(),
                               WIDTH_DIV,
                               300,
                               text="Escolha qual será sua próxima nave")

        self.jet_g_bool = False
        self.jet_green = Sprite(*JET_GREEN_FLY)
        self.jet_green.set_position(
            WIDTH_DIV - WIDTH_DIV / 2 - self.jet_green.width + 200, 350)

        self.jet_y_bool = False
        self.jet_yellow = Sprite(*JET_YELLOW_FLY)
        self.jet_yellow.set_position(WIDTH_DIV + WIDTH_DIV / 2 - 200, 350)
    def __init__(self, sprite, x=0, y=0):
        self.x = x
        self.y = y
        self.background_1 = Sprite(sprite)
        self.background_1.set_total_duration(1000)
        self.background_1.set_position(x, y)

        self.background_2 = Sprite(sprite)
        self.background_2.set_total_duration(1000)
        self.background_2.set_position(self.background_1.width, y)
Esempio n. 3
0
 def setBotoes(self):
     self.facil = Sprite("img/FACIL.png")
     self.facil.set_position((globais.WIDTH / 2) - (self.facil.width / 2),
                             (3 * (globais.HEIGHT / 7)))
     self.medio = Sprite("img/MEDIO.png")
     self.medio.set_position((globais.WIDTH / 2) - (self.medio.width / 2),
                             (4 * (globais.HEIGHT / 7)))
     self.dificil = Sprite("img/DIFICIL.png")
     self.dificil.set_position(
         (globais.WIDTH / 2) - (self.dificil.width / 2),
         (5 * (globais.HEIGHT / 7)))
Esempio n. 4
0
 def setBotoes(self):
     #'Nesta parte vamos criar todos os sprites e definir suas posições na janela'
     self.play = Sprite("img/PLAY.png")
     self.play.set_position(((2 * globais.WIDTH / 5) - self.play.width),
                            ((globais.HEIGHT / 2) - self.play.height))
     self.dificuldade = Sprite("img/DIFICULDADE.png")
     self.dificuldade.set_position(
         ((4 * globais.WIDTH / 5) - self.play.width),
         ((globais.HEIGHT / 2) - self.play.height))
     self.rank = Sprite("img/RANK.png")
     self.rank.set_position(((2 * globais.WIDTH / 5) - self.rank.width),
                            ((globais.HEIGHT / 2) + self.rank.height))
     self.quit = Sprite("img/QUIT.png")
     self.quit.set_position(((4 * globais.WIDTH / 5) - self.quit.width),
                            ((globais.HEIGHT / 2) + self.quit.height))
Esempio n. 5
0
 def setSprite(self, name):
     if name is None:
         self.sprite = None
         self.size = Vector2.zero()
     else:
         self.sprite = Sprite(name + ".png")
         self.size = Vector2(self.sprite.width, self.sprite.height)
Esempio n. 6
0
 def spawn(self, initial_x, initial_y, was_alien=False):
     bullet = Sprite("./assets/actors/bullet.png")
     bullet.set_position(initial_x - bullet.width / 2, initial_y - bullet.height)
     if was_alien == False:
         self.bullets.append(bullet)
     else:
         self.bullets_alien.append(bullet)
 def hidden(self):
     self.animation = Sprite(*self.sprites[random.randint(0, 3)])
     self.animation.set_loop(True)
     self.animation.set_total_duration(1000)
     self.animation.set_position(2000, 2000)
     self.is_hidden = True
     self.lifeModel.hidden()
     self.animation.y = random.randint(0, HEIGHT_SCREEN)
Esempio n. 8
0
 def __change_sprite(self, path, frame, total_duration=980, loop=True):
     self.x = self.animation.x
     self.y = self.animation.y
     self.animation = Sprite(path, frame)
     self.animation.x = self.x
     self.animation.y = self.y
     self.animation.set_total_duration(total_duration)
     self.animation.set_loop(loop)
Esempio n. 9
0
 def __init__(self, *sprite, x=0, y=0):
     self.animation = Sprite(*sprite[0])
     self.animation.set_total_duration(1000)
     self.__setPosition_x = x
     self.__setPosition_y = y
     self.animation.set_position(self.__setPosition_x, self.__setPosition_y)
     self.x = self.animation.x
     self.y = self.animation.y
     self.collided = False
Esempio n. 10
0
 def __init__(self,
              bar_x=4,
              bar_y=0,
              life_hud=LIFE_HUD,
              life_points=LIFE_POINTS):
     self.bar = GameImage(life_hud)
     self.bar.set_position(bar_x, bar_y)
     self.value = Sprite(*life_points)
     self.value.set_position(bar_x - 10, bar_y - 10)
     self.value.set_curr_frame(4)
Esempio n. 11
0
 def __init__(self,
              x=300,
              y=HEIGHT_SCREEN / 2,
              sprite=JET_BLUE_FLY,
              shoot=FIRE_BALL_BLUE):
     self.animation = Sprite(*sprite)
     self.animation.set_loop(True)
     self.animation.set_total_duration(1000)
     self.animation.set_position(x, y)
     self.ground_limit = HEIGHT_SCREEN - self.animation.height
     self.shotModel = ShotModel(2000, 2000)
     self.shotModel_special = ShotModel(2000, 2000, shoot)
Esempio n. 12
0
    def __init__(self, window, bullet, alien, multiplier=1):
        self.window = window
        self.bullet = bullet
        self.alien = alien

        self.sprite = Sprite("./assets/actors/spaceship.png")
        self.player_was_shot = False

        self.speed = globals.SPACESHIP_VEL
        self.reload_cron = 0
        self.reload_time = globals.RELOAD_TIME * multiplier

        self.__set_pos()
Esempio n. 13
0
 def __init__(self):
     self.ground_limit = GROUND
     self.animation = Sprite(*CAT_SPRITE_IDLE)
     self.animation.set_loop(False)
     self.animation.set_total_duration(1000)
     self.animation.set_position(0, self.ground_limit)
     self.x = self.animation.x
     self.y = self.animation.y
     self.point = 0
     self.antx = 0
     self.anty = 0
     self.looking_to = True
     self.jumping = False
     self.original_y = 0
    def __init__(self, hud: HudManager):
        super().__init__(hud)
        self.background = Sprite(BACKGROUND_WAR)
        self.background.set_total_duration(1000)
        self.background.set_position(0, 0)

        self.enemy_plane_two = EnemyAirPlaneModel(*ENEMY_PLANE_SECCOND_POSITION)
        self.enemy_plane_three = EnemyAirPlaneModel(*ENEMY_PLANE_THREE_POSITION)
        self.enemy_plane_four = EnemyAirPlaneModel(*ENEMY_PLANE_FOUR_POSITION)

        self.game_objects = [self.enemy_plane, self.enemy_plane_two, self.enemy_plane_three, self.enemy_plane_four,
                             self.air_plane, self.coin, self.life, self.special,
                             self.air_plane.get_shot(), self.air_plane.get_shot_special(),
                             self.enemy_plane.get_shot(), self.enemy_plane_two.get_shot(),
                             self.enemy_plane_three.get_shot(), self.enemy_plane_four.get_shot()]

        self.enemys = [self.enemy_plane, self.enemy_plane_two, self.enemy_plane_three, self.enemy_plane_four]
        self.enemy_shot_times = [0.0, 0.0, 0.0, 0.0]
Esempio n. 15
0
def main():
    HEIGHT = 600
    WIDTH = 800
    VEL_X = 200
    VEL_Y = 200

    window = Window(WIDTH, HEIGHT)
    keyboard = Keyboard()

    ball = Sprite("./assets/ball.png")
    ball.set_position((window.width / 2 - ball.width / 2),
                      (window.height / 2 - ball.height / 2))

    bat_player = Sprite("./assets/bat.png")
    bat_player.set_position(15, (window.height / 2 - bat_player.height / 2))

    bat_npc = Sprite("./assets/bat.png")
    bat_npc.set_position((window.width - 15) - bat_npc.width,
                         (window.height / 2 - bat_npc.height / 2))

    game_started = False
    player_score = 0
    npc_score = 0

    window.set_background_color((0, 0, 0))
    window.draw_text("{} {}".format(player_score, npc_score), window.width / 2,
                     15, 25, (255, 255, 255))
    ball.draw()
    bat_player.draw()
    bat_npc.draw()

    while True:
        # to start the game
        if keyboard.key_pressed("space") or game_started:
            ball.x += (VEL_X * window.delta_time())
            ball.y += (VEL_Y * window.delta_time())
            game_started = True

        # scoring and reset after left and right window collision
        if (ball.x < 0) or (ball.x + ball.width > window.width):
            if ball.x < 0:
                npc_score += 1
            elif ball.x + ball.width > window.width:
                player_score += 1

            ball.set_position((window.width / 2 - ball.width / 2),
                              (window.height / 2 - ball.height / 2))
            bat_player.set_position(
                15, (window.height / 2 - bat_player.height / 2))
            bat_npc.set_position((window.width - 15) - bat_npc.width,
                                 (window.height / 2 - bat_npc.height / 2))

            game_started = False

            window.set_background_color((0, 0, 0))
            window.draw_text("{} {}".format(player_score, npc_score),
                             window.width / 2, 15, 25, (255, 255, 255))
            ball.draw()
            bat_player.draw()
            bat_npc.draw()
            window.update()
            continue

        # bottom and top window collision
        if ball.y < 0:
            VEL_Y *= -1
            ball.set_position(ball.x, ball.y + 1)
        elif ball.y + ball.height > window.height:
            VEL_Y *= -1
            ball.set_position(ball.x, ball.y - 1)

        # bat collision
        if bat_player.collided(ball):
            VEL_X *= -1
            ball.set_position(ball.x + 1, ball.y)
        elif bat_npc.collided(ball):
            VEL_X *= -1
            ball.set_position(ball.x - 1, ball.y)

        # controls
        if keyboard.key_pressed("up") and bat_player.y > 15:
            bat_player.y -= 0.5
        if (keyboard.key_pressed("down")
                and (bat_player.y + bat_player.height < window.height - 15)):
            bat_player.y += 0.5

        # AI
        if (ball.y < window.height / 2 and bat_npc.y > 15 and game_started):
            bat_npc.y -= 0.5
        elif (ball.y > window.height / 2
              and bat_npc.y + bat_npc.height < window.height - 15
              and game_started):
            bat_npc.y += 0.5

        # reset
        window.set_background_color((0, 0, 0))
        window.draw_text("{} {}".format(player_score, npc_score),
                         window.width / 2, 15, 25, (255, 255, 255))
        ball.draw()
        bat_player.draw()
        bat_npc.draw()
        window.update()
Esempio n. 16
0
 def setNave(self):
     self.nave = Sprite("img/ywing.png")
     self.nave.set_position((globais.WIDTH / 2) - self.nave.width / 2,
                            (globais.HEIGHT) - self.nave.height)
Esempio n. 17
0
 def setInimigos(self):
     self.tieU = Sprite("img/tie.png")
Esempio n. 18
0
 def setTiro(self, inicial_x, inicial_y):
     tiro = Sprite("img/tiro.png")
     tiro.set_position(inicial_x, inicial_y)
     self.tiro.append(tiro)
Esempio n. 19
0
 def __init__(self):
     self.bar = GameImage(SPECIAL_HUD)
     self.bar.set_position(4, 76)
     self.value = Sprite(*SPECIAL_POINTS)
     self.value.set_position(-6, 65)
     self.value.set_curr_frame(0)
Esempio n. 20
0
 def setAbaixadoE(self):
     self.abaixado_e = Sprite("img/abaixado_e.png")
     self.personagem = self.abaixado_e
Esempio n. 21
0
 def setAbaixadoD(self):
     self.abaixado_d = Sprite("img/abaixado_d.png")
     self.personagem = self.abaixado_d
Esempio n. 22
0
 def setParadoE(self):
     self.parado_e = Sprite("img/parado_e2.png")
     self.personagem = self.parado_e
Esempio n. 23
0
 def setParadoD(self):
     self.parado_d = Sprite("img/parado_d2.png")
     self.personagem = self.parado_d