Accueil > > > JEU DU 21.
JEU DU 21.
Information sur la source
Description
Le but du jeu est de se rapprocher le plus possible de 21 en lancant un dé, vous vous arrêtez quand vous le voulez en cliquant sur "arrêter" et la vous passez la main a la machine qui essayera de faire mieux. La partie se termine quand vous ou l'ordianteur a atteint un total de 10 points, bonne chance ... Bon je ne suis pas tres fort en interface graphique si vous avez des conseils je suis preneur :D .
Source
- # -*- coding: cp1252 -*-
- #---- Jeu de 21 by Bouceka ----
-
- #---- Appel de module ----
- from Tkinter import *
- from random import randrange
-
- #---- Variable utilisé ----
- player,machine = 0,0
- i,cumulm,cumulp = 0,0,0
- scorem ,scorep = 0,0
- deci = ''
-
-
- #---- Fonctions ----
-
- def Jeu():
- global cumulm ,cumulp
- player = randrange(1,7)
- machine = randrange(1,7)
- cumulp = cumulp + player
- cumulm = cumulm + machine
-
- tex2['text'] = "Nombre:",player
- tex3['text'] = "Player:",cumulp
-
-
-
- def Arret():
- global cumulm,cumulp,scorem,scorep
- tex4['text'] = "Machine:",cumulm
- if(abs(21 - cumulm) < abs(21 - cumulp)):
- scorem = scorem + 1
- tex7['text'] = "Machine point:",scorem
-
- elif(abs(21 - cumulm) > abs(21 - cumulp)):
- scorep = scorep + 1
- tex6['text'] = "Player point:",scorep
-
- elif(abs(21 - cumulm) == abs(21 - cumulp)):
- scorep = scorep + 1
- scorem = scorem + 1
-
- tex6['text'] = "Player point:",scorep
- tex7['text'] = "Machine point:",scorem
-
- if(scorep == 10):
- tex5['text'] = "Tu as gagné !"
-
- elif(scorem == 10):
- tex5['text'] = "Tu as perdu..."
-
- cumulp,cumulm = 0 , 0
-
- def rejouer():
- global cumulm,cumulp,scorem,scorep
- cumulm,cumulp,scorem,scorep = 0,0,0,0
-
- tex2['text'] = "Nombre: 0"
- tex3['text'] = "Player: 0"
- tex4['text'] = "Machine: 0"
- tex5['text'] = ""
- tex6['text'] = "Player point: 0"
- tex7['text'] = "Machine point: 0"
-
-
-
- #---- Interface Graphique ----
-
-
- fen = Tk()
- fen.title("Jeu de 21 by Bouceka")
-
- Button(fen,text =" Go ! ",command =Jeu).grid(row =1,column =1)
-
- Button(fen,text ="Arrêter",command =Arret).grid(row =2,column =1)
-
- Button(fen,text ="Rejouer",command =rejouer).grid(row = 3,column =1)
-
- tex2 = Label(fen,text ="Nombre: 0")
- tex2.grid(row =2,column =2,sticky =W)
-
- Label(fen,text =" |->Lancé du dé<- |",fg ='blue').grid(row =1,column =2)
-
- Label(fen,text="|->Evolution du joueur<-|",fg ='blue').grid(row =1,column =3,)
-
- tex3 = Label(fen,text ="Player: 0")
- tex3.grid(row =2,column =3,sticky =W)
-
- tex4 = Label(fen,text ="Machine: 0")
- tex4.grid(row =3,column =3,sticky = W)
-
- Label(fen,text="<->->->->->Score des joueurs<-<-<-<-<->",fg ='blue').grid(row =6,column =1,columnspan =3)
-
- tex5 = Label(fen,text="")
- tex5.grid(row = 7,column =3)
-
- tex6 = Label(fen,text="Player point: 0")
- tex6.grid(row =7,column=1,columnspan =2)
-
- tex7 = Label(fen,text="Machine point: 0")
- tex7.grid(row =8,column=1,columnspan =2)
-
- fen.mainloop()
-
# -*- coding: cp1252 -*-
#---- Jeu de 21 by Bouceka ----
#---- Appel de module ----
from Tkinter import *
from random import randrange
#---- Variable utilisé ----
player,machine = 0,0
i,cumulm,cumulp = 0,0,0
scorem ,scorep = 0,0
deci = ''
#---- Fonctions ----
def Jeu():
global cumulm ,cumulp
player = randrange(1,7)
machine = randrange(1,7)
cumulp = cumulp + player
cumulm = cumulm + machine
tex2['text'] = "Nombre:",player
tex3['text'] = "Player:",cumulp
def Arret():
global cumulm,cumulp,scorem,scorep
tex4['text'] = "Machine:",cumulm
if(abs(21 - cumulm) < abs(21 - cumulp)):
scorem = scorem + 1
tex7['text'] = "Machine point:",scorem
elif(abs(21 - cumulm) > abs(21 - cumulp)):
scorep = scorep + 1
tex6['text'] = "Player point:",scorep
elif(abs(21 - cumulm) == abs(21 - cumulp)):
scorep = scorep + 1
scorem = scorem + 1
tex6['text'] = "Player point:",scorep
tex7['text'] = "Machine point:",scorem
if(scorep == 10):
tex5['text'] = "Tu as gagné !"
elif(scorem == 10):
tex5['text'] = "Tu as perdu..."
cumulp,cumulm = 0 , 0
def rejouer():
global cumulm,cumulp,scorem,scorep
cumulm,cumulp,scorem,scorep = 0,0,0,0
tex2['text'] = "Nombre: 0"
tex3['text'] = "Player: 0"
tex4['text'] = "Machine: 0"
tex5['text'] = ""
tex6['text'] = "Player point: 0"
tex7['text'] = "Machine point: 0"
#---- Interface Graphique ----
fen = Tk()
fen.title("Jeu de 21 by Bouceka")
Button(fen,text =" Go ! ",command =Jeu).grid(row =1,column =1)
Button(fen,text ="Arrêter",command =Arret).grid(row =2,column =1)
Button(fen,text ="Rejouer",command =rejouer).grid(row = 3,column =1)
tex2 = Label(fen,text ="Nombre: 0")
tex2.grid(row =2,column =2,sticky =W)
Label(fen,text =" |->Lancé du dé<- |",fg ='blue').grid(row =1,column =2)
Label(fen,text="|->Evolution du joueur<-|",fg ='blue').grid(row =1,column =3,)
tex3 = Label(fen,text ="Player: 0")
tex3.grid(row =2,column =3,sticky =W)
tex4 = Label(fen,text ="Machine: 0")
tex4.grid(row =3,column =3,sticky = W)
Label(fen,text="<->->->->->Score des joueurs<-<-<-<-<->",fg ='blue').grid(row =6,column =1,columnspan =3)
tex5 = Label(fen,text="")
tex5.grid(row = 7,column =3)
tex6 = Label(fen,text="Player point: 0")
tex6.grid(row =7,column=1,columnspan =2)
tex7 = Label(fen,text="Machine point: 0")
tex7.grid(row =8,column=1,columnspan =2)
fen.mainloop()
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
modification de jeu morpion en python [ par apprenti2008 ]
salut a tous ! SVP j'ai vraiment besoin d'aide , je suis en première année MASS , le prof nous a demander de créer un jeu morpion en python , le princ
[Jeu par navigateur] Miraemos - Projet sérieux [ par jesslaly ]
Bonjour,Je suis Jessica, étudiante qui a monté un projet depuis une année maintenant.Je me suis lancée dans un projet assez intéressant de jeu en lign
jeu de la vie [ par dia100daly ]
je veux poster un code. Mais j'aimerai savoir si c'etait vraiment la peine car c'est la première fois. Pour plus de détail voir sur Wikipédia ( jeu de
codage Windows jeu de caractères [ par creaduff ]
Bonjour,Avant tout, précisons que je ne suis pas un aigle en Python ! Voici mon problème:J'ai écrit une petit programme permettant d'accéder à ma boit
Réalisation d'un plus ou moins sur Tkinter [ par kuritsu ]
Bonsoir tout le monde, et je vous souhaite la bonne année à tous par la même occasion. Je viens de me mettre à la programmation sous Python, et j'avo
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|