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
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE [WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE[WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE par FREMYCOMPANY
Je pense qu'ils ont besoin d'une piqure de rappel chez Microsoft : c'est bien gentil d'avoir une interface jolie, mais si c'est pour avoir un truc qui ne convainct pas dedans, c'est peine perdue.
---->
Système ouvert ----> Fermé ?
P...
Cliquez pour lire la suite de l'article par FREMYCOMPANY
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|