Пример #1
0
    def __init__(self):

        self.panier = Panier()
        self.fenetre = Fenetre()
        self.oeuf = Oeuf(self.panier)
        self.rejouer = True
        self.compteur = 0

        self.touches_actives = {}
        self.timer = pygame.time.Clock()
        self.group_oeufs = pygame.sprite.Group()
Пример #2
0
import pyglet

from fenetre import Fenetre

window = Fenetre()

pyglet.app.run()
print("c'est fini !")
Пример #3
0
class Jeu:

    def __init__(self):

        self.panier = Panier()
        self.fenetre = Fenetre()
        self.oeuf = Oeuf(self.panier)
        self.rejouer = True
        self.compteur = 0

        self.touches_actives = {}
        self.timer = pygame.time.Clock()
        self.group_oeufs = pygame.sprite.Group()

    def jouer(self):
        while self.rejouer:
            self.fenetre.affichage(self.fenetre.fond)
            if self.compteur == 0:
                self.compteur = 80
                self.oeuf.groupe_oeuf.add(Oeuf(self.panier))

            self.oeuf.chute(self.oeuf.groupe_oeuf, self.panier)

            self.fenetre.dessiner_groupe(self.oeuf.groupe_oeuf)

            self.fenetre.affichage(self.fenetre.sol)

            self.fenetre.dessiner_groupe(self.panier.groupe_panier)

            self.fenetre.afficher_score(self.panier.vie)

            self.fenetre.affichage(self.fenetre.score)

            self.fenetre.rafraichir_fenetre()

            if self.touches_actives.get(pygame.K_RIGHT) and \
                    self.panier.rect.x + self.panier.rect.width < self.fenetre.largeur_fenetre:
                self.panier.deplacement(pygame.K_RIGHT)
            elif self.touches_actives.get(pygame.K_LEFT) and \
                    self.panier.rect.x > 0:
                self.panier.deplacement(pygame.K_LEFT)

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.rejouer = False
                    pygame.quit()
                if event.type == pygame.KEYDOWN:
                    self.touches_actives[event.key] = True
                if event.type == pygame.KEYUP:
                    self.touches_actives[event.key] = False

            self.timer.tick(60)
            self.compteur -= 1
Пример #4
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# main.py
# Corps principal du programme
#
# Crée un objet de type jeu (contenant les règles et le moteur du jeu)
# Crée un objet de type fenetre (contenant l'interface graphique)
# Traite en boucle les évènements de l'interface graphique qui activent les fonctions du jeu
# Le jeu renvoie les valeurs d'affichage vers l'interface graphique

from tkinter import Tk

# Création du jeu
from jeu import Jeu
job = Jeu()

# Création de l'interface graphique

root = Tk()
from fenetre import Fenetre
wnd = Fenetre(root, job)

root.mainloop()
Пример #5
0
    dialogue = Dialog("resources/temporaire/Tharja.png", "Tharja", (10, 210), "resources/temporaire/Ricken.png", "Ricken", (500, 200))
    dialogue.punchlineList.append(["Il semblerait que mon sort n'ait pas fonctionné...", 0])
    dialogue.punchlineList.append(["Hein ? Tu as dit quelque chose ?", 1])
    dialogue.punchlineList.append(["Non non... Rien... hé hé...", 0])
    with open('dialogue.pickle', 'wb') as file:
        pickle.dump(dialogue, file)
    jeu.dialoguer(dialogue)

def testSerializedDialogue():
    with open('resources/temporaire/dialogue.pickle', 'rb') as file:
        dialogue = pickle.load(file)
    jeu.dialoguer(dialogue)

pygame.init()
pygame.mixer.init()
fenetre = Fenetre("test ISN Dialogue", constantes.largeur, constantes.hauteur)
fenetre.fond = pygame.image.load("resources/galaxie.jpg").convert_alpha()

with open('resources/niveau/1/firstDialog.pickle', 'rb') as file:
    firstDialog = pickle.load(file)

with open('resources/niveau/1/middleDialog.pickle', 'rb') as file:
    middleDialog = pickle.load(file)

with open('resources/niveau/1/lastDialog.pickle', 'rb') as file:
    lastDialog = pickle.load(file)

jeu = Jeu(fenetre,Niveau(1),0,0)
for explode in constantes.explodeList:
    explode = explode.convert_alpha()
#testDialog()
Пример #6
0
from fenetre import Fenetre

app = Fenetre() #création d'un objet fenete (cf constructeur de la classe pour voir ce que ca fait)
app.window.mainloop() #demarrage de la fenetre
Пример #7
0
from souris import Souris
from fenetre import Fenetre

fenetre = Fenetre(5, 5)
souris = Souris()

souris.clique(fenetre)

souris.pointe(5, 5)

souris.clique(fenetre)
Пример #8
0
    dialogue.punchlineList.append(["Hein ? Tu as dit quelque chose ?", 1])
    dialogue.punchlineList.append(["Non non... Rien... hé hé...", 0])
    with open('dialogue.pickle', 'wb') as file:
        pickle.dump(dialogue, file)
    jeu.dialoguer(dialogue)


def testSerializedDialogue():
    with open('resources/temporaire/dialogue.pickle', 'rb') as file:
        dialogue = pickle.load(file)
    jeu.dialoguer(dialogue)


pygame.init()
pygame.mixer.init()
fenetre = Fenetre("test ISN Dialogue", constantes.largeur, constantes.hauteur)
fenetre.fond = pygame.image.load("resources/galaxie.jpg").convert_alpha()

with open('resources/niveau/1/firstDialog.pickle', 'rb') as file:
    firstDialog = pickle.load(file)

with open('resources/niveau/1/middleDialog.pickle', 'rb') as file:
    middleDialog = pickle.load(file)

with open('resources/niveau/1/lastDialog.pickle', 'rb') as file:
    lastDialog = pickle.load(file)

jeu = Jeu(fenetre, Niveau(1), 0, 0)
for explode in constantes.explodeList:
    explode = explode.convert_alpha()
#testDialog()
Пример #9
0
 def setUp(self):
     self.a = Arene()
     self.f = Fenetre(self.a)
Пример #10
0
class TestRobot(unittest.TestCase):
    def setUp(self):
        self.a = Arene()
        self.f = Fenetre(self.a)

    def test_fenetre(self):
        self.assertEqual(self.f.arene, self.a)

    def test_avancerRobot(self):
        self.f.avancerRobot()
        self.assertEqual(self.f.arene.robot.pos, [12.0, 10.0])
        pos = self.a.robot.pos
        self.assertEqual(self.a.tableau[int(pos[0])][int(pos[1])], 2)

        self.a.robot.changerVitesseSimple(1)
        self.f.avancerRobot()
        self.assertEqual(self.f.arene.robot.pos, [15.0, 10.0])
        pos = self.a.robot.pos

    def test_tourneRobot(self):
        self.f.tourneRobot()
        self.assertEqual(self.a.robot.angle, PI / 2)

    def test_tourneRobot10(self):
        self.f.tourneRobot10()
        self.assertEqual(self.a.robot.angle, PI / 9)

    def test_tourneRobot10(self):
        self.f.tourneRobot_10()
        self.assertEqual(self.a.robot.angle, -PI / 9)

    def test_augmenterVitesseRobot(self):
        vitesse = self.f.arene.robot.vitesse
        self.f.augmenterVitesseRobot()
        self.assertEqual(self.f.arene.robot.vitesse, vitesse + 1)

    def test_augmenterVitesseRobot(self):
        vitesse = self.f.arene.robot.vitesse
        self.f.diminuerVitesseRobot()
        self.assertEqual(self.f.arene.robot.vitesse, vitesse - 1)