Ejemplo n.º 1
0
    def test_status(self):
        phase = Phase()
        pigs = [Pig(1, 1) for i in range(2)]
        birds = [YellowBird(1, 1) for i in range(2)]
        phase.add_pigs(*pigs)
        phase.add_birds(*birds)
        self.assertEqual(ON_GOING, phase.status())

        for bird, pig in zip(birds, pigs):
            bird.clash(pig, 3)

        self.assertEqual(VICTORY, phase.status(),
                         'Without active pigs game should end with victory')

        phase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, phase.status(),
                          'Obstacle must not interfere on game result')

        pig = Pig()
        phase.add_pigs(pig)
        self.assertEqual(DEFEAT, phase.status(),
                         'With Active Pig and with no Active bird, game should end with defeat')

        phase.add_birds(YellowBird())
        self.assertEqual(ON_GOING, phase.status(),
                         'With active pig and birds, game should not end')

        pig.clash(pig, 3)
        self.assertEqual(VICTORY, phase.status(),
                         'Without active pigs game should end with victory')
Ejemplo n.º 2
0
    def teste_status(self):
        fase = Phase()
        porcos = [Pig(1, 1) for i in range(2)]
        passaros = [YellowBird(1, 1) for i in range(2)]
        fase.add_pigs(*porcos)
        fase.add_birds(*passaros)
        self.assertEqual(ON_GOING, fase.status())

        for passaro, porco in zip(passaros, porcos):
            passaro.clash(porco, 3)

        self.assertEqual(VICTORY, fase.status(),
                         'Sem porcos ativos o jogo deveria terminar com vitória')

        fase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, fase.status(),
                         'Obstáculo não interfere para definir vitória')

        porco = Pig()
        fase.add_pigs(porco)
        self.assertEqual(DEFEAT, fase.status(),
                         'Com Pig ativo e sem pássaro para lançar, o jogo deveria acabar em derrota')

        fase.add_birds(YellowBird())
        self.assertEqual(ON_GOING, fase.status(),
                         'Com Pig ativo e com pássaro para lançar, o jogo não deveria acabar')

        porco.clash(porco, 3)
        self.assertEqual(VICTORY, fase.status(),
                         'Sem porco ativo, o jogo deveria acabar com vitória')
Ejemplo n.º 3
0
    def test_status(self):
        phase = Phase()
        pigs = [Pig(1, 1) for i in range(2)]
        birds = [YellowBird(1, 1) for i in range(2)]
        phase.add_pigs(*pigs)
        phase.add_birds(*birds)
        self.assertEqual(ON_GOING, phase.status())

        for bird, pig in zip(birds, pigs):
            bird.clash(pig, 3)

        self.assertEqual(VICTORY, phase.status(),
                         'Without active pigs game should end with victory')

        phase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, phase.status(),
                         'Obstacle must not interfere on game result')

        pig = Pig()
        phase.add_pigs(pig)
        self.assertEqual(
            DEFEAT, phase.status(),
            'With Active Pig and with no Active bird, game should end with defeat'
        )

        phase.add_birds(YellowBird())
        self.assertEqual(ON_GOING, phase.status(),
                         'With active pig and birds, game should not end')

        pig.clash(pig, 3)
        self.assertEqual(VICTORY, phase.status(),
                         'Without active pigs game should end with victory')
Ejemplo n.º 4
0
    def test_game_over_with_pigs_and_birds(self):
        phase = Phase()
        pigs = [Pig(1, 1) for i in range(2)]  # creating 2 pigs
        birds = [YellowBird(1, 1) for i in range(2)]  # criating 2 birds
        phase.add_pigs(*pigs)
        phase.add_birds(*birds)

        self.assertEqual(ON_GOING, phase.status())

        # clashing bird against pig on time 3
        for bird, pig in zip(birds, pigs):
            bird.clash(pig, 3)

        self.assertEqual(VICTORY, phase.status())

        phase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, phase.status(),
                         'Obstacle must not interfere on game result')

        phase.add_pigs(Pig())
        self.assertEqual(
            DEFEAT, phase.status(),
            'With no active birds and one Pig active, player should lose')

        phase.add_birds(YellowBird())
        self.assertEqual(
            ON_GOING, phase.status(),
            'With one pig and bird both active, game should still going on')
Ejemplo n.º 5
0
    def teste_adicionar_obstaculo(self):
        fase = Phase()
        self.assertListEqual([], fase._obstacles)
        obstaculo = Obstacle()
        fase.add_obstacles(obstaculo)
        self.assertListEqual([obstaculo], fase._obstacles)

        obstaculo1, obstaculo2 = Obstacle(), Obstacle()
        fase.add_obstacles(obstaculo1, obstaculo2)
        self.assertListEqual([obstaculo, obstaculo1, obstaculo2], fase._obstacles)
Ejemplo n.º 6
0
    def test_add_obstacles(self):
        phase = Phase()
        self.assertListEqual([], phase._obstacles)
        obstacle = Obstacle()
        phase.add_obstacles(obstacle)
        self.assertListEqual([obstacle], phase._obstacles)

        obstacle1, obstacle2 = Obstacle(), Obstacle()
        phase.add_obstacles(obstacle1, obstacle2)
        self.assertListEqual([obstacle, obstacle1, obstacle2], phase._obstacles)
Ejemplo n.º 7
0
def main():
    global fase, passaros, porcos, obstaculos
    fase = Phase(clash_interval=32)
    passaros = [RedBird(30, 30), YellowBird(30, 30), YellowBird(30, 30)]
    porcos = [Pig(750, 1), Pig(700, 1)]
    obstaculos = [Obstacle(310, 100)]
    fase.add_obstacles(*obstaculos)
    fase.add_birds(*passaros)
    fase.add_pigs(*porcos)
    rodar_fase(fase)
Ejemplo n.º 8
0
def main():
    global fase, passaros, porcos, obstaculos
    fase = Phase(clash_interval=32)
    passaros = [RedBird(30, 30), YellowBird(30, 30), YellowBird(30, 30)]
    porcos = [Pig(750, 1), Pig(700, 1)]
    obstaculos = [Obstacle(310, 100)]
    fase.add_obstacles(*obstaculos)
    fase.add_birds(*passaros)
    fase.add_pigs(*porcos)
    rodar_fase(fase)
Ejemplo n.º 9
0
    def test_add_obstacles(self):
        phase = Phase()
        self.assertListEqual([], phase._obstacles)
        obstacle = Obstacle()
        phase.add_obstacles(obstacle)
        self.assertListEqual([obstacle], phase._obstacles)

        obstacle1, obstacle2 = Obstacle(), Obstacle()
        phase.add_obstacles(obstacle1, obstacle2)
        self.assertListEqual([obstacle, obstacle1, obstacle2],
                             phase._obstacles)
Ejemplo n.º 10
0
def create_phase(multplier=1):
    example_phase = Phase(1 if multplier == 1 else 32)
    birds = [RedBird(3 * multplier, 3 * multplier),
                YellowBird(3 * multplier, 3 * multplier),
                YellowBird(3 * multplier, 3 * multplier)]
    pigs = [Pig(78 * multplier, multplier), Pig(70 * multplier, multplier)]
    obstacles = [Obstacle(31 * multplier, 10 * multplier)]

    example_phase.add_birds(*birds)
    example_phase.add_pigs(*pigs)
    example_phase.add_obstacles(*obstacles)

    return example_phase
Ejemplo n.º 11
0
def criar_fase_exemplo(multiplicador=1):
    fase_exemplo = Phase(1 if multiplicador == 1 else 32)
    passaros = [RedBird(3 * multiplicador, 3 * multiplicador),
                YellowBird(3 * multiplicador, 3 * multiplicador),
                YellowBird(3 * multiplicador, 3 * multiplicador)]
    porcos = [Pig(78 * multiplicador, multiplicador), Pig(70 * multiplicador, multiplicador)]
    obstaculos = [Obstacle(31 * multiplicador, 10 * multiplicador)]

    fase_exemplo.add_birds(*passaros)
    fase_exemplo.add_pigs(*porcos)
    fase_exemplo.add_obstacles(*obstaculos)

    return fase_exemplo
Ejemplo n.º 12
0
def create_phase(multplier=1):
    example_phase = Phase(1 if multplier == 1 else 32)
    birds = [
        RedBird(3 * multplier, 3 * multplier),
        YellowBird(3 * multplier, 3 * multplier),
        YellowBird(3 * multplier, 3 * multplier)
    ]
    pigs = [Pig(78 * multplier, multplier), Pig(70 * multplier, multplier)]
    obstacles = [Obstacle(31 * multplier, 10 * multplier)]

    example_phase.add_birds(*birds)
    example_phase.add_pigs(*pigs)
    example_phase.add_obstacles(*obstacles)

    return example_phase
Ejemplo n.º 13
0
    def teste_acabou_com_porcos_e_passaros(self):
        fase = Phase()
        porcos = [Pig(1, 1) for i in range(2)]  # criando 2 porcos
        passaros = [YellowBird(1, 1) for i in range(2)]  # criando 2 pássaros
        fase.add_pigs(*porcos)
        fase.add_birds(*passaros)

        self.assertEqual(ON_GOING, fase.status())

        # colidindo cada passaro com um porco no tempo 3
        for passaro, porco in zip(passaros, porcos):
            passaro.clash(porco, 3)

        self.assertEqual(VICTORY, fase.status())

        fase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, fase.status(), 'Obstáculo não interfere no fim do jogo')

        fase.add_pigs(Pig())
        self.assertEqual(DEFEAT, fase.status(), 'Com Pig ativo e sem pássaro para lançar, o jogo deveria acabar')

        fase.add_birds(YellowBird())
        self.assertEqual(ON_GOING, fase.status(),
                         'Com Pig ativo e com pássaro para lançar, o jogo não deveria acabar')
Ejemplo n.º 14
0
    def test_game_over_with_pigs_and_birds(self):
        phase = Phase()
        pigs = [Pig(1, 1) for i in range(2)]  # creating 2 pigs
        birds = [YellowBird(1, 1) for i in range(2)]  # criating 2 birds
        phase.add_pigs(*pigs)
        phase.add_birds(*birds)

        self.assertEqual(ON_GOING, phase.status())

        # clashing bird against pig on time 3
        for bird, pig in zip(birds, pigs):
            bird.clash(pig, 3)

        self.assertEqual(VICTORY, phase.status())

        phase.add_obstacles(Obstacle())
        self.assertEqual(VICTORY, phase.status(), 'Obstacle must not interfere on game result')

        phase.add_pigs(Pig())
        self.assertEqual(DEFEAT, phase.status(), 'With no active birds and one Pig active, player should lose')

        phase.add_birds(YellowBird())
        self.assertEqual(ON_GOING, phase.status(),
                         'With one pig and bird both active, game should still going on')
import sys

project_dir = path.dirname(__file__)
project_dir = path.join('..')
sys.path.append(project_dir)

from actors import YellowBird, RedBird, Obstacle, Pig
from phase import Phase
from graphics_tk import rodar_fase

if __name__ == '__main__':
    fase = Phase(intervalo_de_colisao=32)


    # Adicionar Pássaros Vermelhos
    for i in range(5):
        fase.add_birds(RedBird(30, 30))
    # Adicionar Pássaros Amarelos
    for i in range(30):
        fase.add_birds(YellowBird(30, 30))


    # Obstaculos
    for i in range(30, 480, 32):
        fase.add_obstacles(Obstacle(300, i))

    # Porcos
    for i in range(30, 300, 32):
        fase.add_pigs(Pig(600, i))

    rodar_fase(fase)
from random import randint

if __name__ == '__main__':
    fase = Phase(intervalo_de_colisao=32)


    # Adicionar Pássaros Amarelos
    for i in range(80):
        fase.add_birds(YellowBird(30, 30))


    # Obstaculos
    theta = 270
    h = 12
    k = 7
    step = 32
    r = 50

    while theta < 480:
        x = 600 + (h + r * math.cos(theta))
        y = (k + r * math.sin(theta))
        fase.add_obstacles(Obstacle(x, y))
        theta += 32

    # Porcos
    for i in range(30, 300, 32):
        x = randint(590, 631)
        y = randint(0, 21)
        fase.add_pigs(Pig(x, y))

    rodar_fase(fase)
Ejemplo n.º 17
0
# -*- coding: utf-8 -*-
from actors import RedBird, YellowBird, Pig, Obstacle
from phase import Phase
import placa_grafica

fase_exemplo = Phase()
passaros = [RedBird(3, 3), YellowBird(3, 3), YellowBird(3, 3)]
porcos = [Pig(78, 1), Pig(70, 1)]
obstaculos = [Obstacle(31, 10)]

fase_exemplo.add_birds(*passaros)
fase_exemplo.add_pigs(*porcos)
fase_exemplo.add_obstacles(*obstaculos)

# Solução para ganhar
# fase_exemplo.lancar(45, 1)
# fase_exemplo.lancar(63, 3)
# fase_exemplo.lancar(23, 4)

if __name__ == '__main__':
    placa_grafica.animar(fase_exemplo)
Ejemplo n.º 18
0
from phase import Phase
from graphics_tk import run_phase
from random import randint

if __name__ == '__main__':
    fase = Phase(intervalo_de_colisao=32)

    # Adicionar Pássaros Amarelos
    for i in range(80):
        fase.add_birds(YellowBird(30, 30))

    # Obstaculos
    theta = 270
    h = 12
    k = 7
    step = 32
    r = 50

    while theta < 480:
        x = 600 + (h + r * math.cos(theta))
        y = (k + r * math.sin(theta))
        fase.add_obstacles(Obstacle(x, y))
        theta += 32

    # Porcos
    for i in range(30, 300, 32):
        x = randint(590, 631)
        y = randint(0, 21)
        fase.add_pigs(Pig(x, y))

    run_phase(fase)
import sys

project_dir = path.dirname(__file__)
project_dir = path.join('..')
sys.path.append(project_dir)

from actors import YellowBird, RedBird, Obstacle, Pig
from phase import Phase
from graphics_tk import run_phase

if __name__ == '__main__':
    fase = Phase(intervalo_de_colisao=32)


    # Adicionar Pássaros Vermelhos
    for i in range(5):
        fase.add_birds(RedBird(30, 30))
    # Adicionar Pássaros Amarelos
    for i in range(30):
        fase.add_birds(YellowBird(30, 30))


    # Obstaculos
    for i in range(30, 480, 32):
        fase.add_obstacles(Obstacle(300, i))

    # Porcos
    for i in range(30, 300, 32):
        fase.add_pigs(Pig(600, i))

    run_phase(fase)