Python

discovery Python

** Python

I discovery a Python and I have of make 3 mini games : 1. The Hangman 2. The rebus 3. Crossword He must be later introduced in renpy to make a story.

The Hangman

Before beginning the hung I made tests to learn little Python then I started the hangman, I was sad has to begin because I did not know by what to begin then I have to look of other games to give me a direction.

My code for the hangman:

from random import choice

Nombre de coups par partie

nombres_de_coups = 7

liste des mots

liste = [ "epee", "kawaii", "montagne", "samourai", "kendo", "nobunaga", ] print nombres_de_coups

def choisir_mot(): return choice(liste)

def choix_lettre(propositions): while True:

    lettre = raw_input("Appuyer sur une lettre: ")

    if lettre in propositions:
        print("cette lettre a deja ete proposee.")
    else:
        break;
propositions.append(lettre)    
return lettre

def mot_cacher(mot, propositions): m = '' for lettre in mot: if lettre in propositions: m = m+lettre else: m = m + '-' return m

mot = choisir_mot() propositions = [] nb_chance = nombres_de_coups

while True: print("Lettres deja utiliser :",propositions) print("Mot cachée : ", mot_cacher(mot, propositions))

lettre = choix_lettre(propositions)

if lettre not in mot:
    nb_chance -= 1
    print(nb_chance)

else:
    print(str(nb_chance))

if mot_cacher(mot,propositions) == mot:

    print("Bravo, vous avez gagne. Le mot etait: "+mot)
    print("Nombre de coups: "+str(nb_chance))
    break

else:
            if nb_chance==0:
                print("vous etes pendu, le mot etait: "+mot +str( nb_chance))
                break

Has his me to give the opportunity to use more often While.

The rebus

For rebus I have to use my code of the hungman that I have to modify to create the game.

Renpy

Then I eventually integrated in renpy my 2 games. Besides putting my games I have of put images for the rebus so that we can play it.

Conclusion

Very interesting project even if I was not able to finish all of the project.

 27 sept. 2018 -  Sylvain Foulon - game design 2,   Pyhton Renpy