begin process at 2012 02 12 08:10:53
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Jeux

 > JEU DE CARTES ITALIENNES EN VISUAL C++

JEU DE CARTES ITALIENNES EN VISUAL C++


 Information sur la source

Note :
7 / 10 - par 3 personnes
7,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Jeux Niveau :Débutant Date de création :27/01/2003 Date de mise à jour :10/02/2003 00:25:39 Vu / téléchargé :6 806 / 488

Auteur : MaurusAP

Ecrire un message privé
Site perso
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
This article present a simple game card, programmed with MFC, for the graphics and the user feedback, and at lower level I used the STL of C++ to manage the classes for the deck, the players, the game. The same low level structure, could be reused for a different future game (Poker? Bridge...is too difficult I guess!) I used a dialog based application in the MFC wizard.

Description

The italian game card "Sette e mezzo" or "Seven and half" is a tipical Christmas game. You have to bet your "virtual" dollars and then take a card from the deck until you feel that your points are enough and under 7 and half that is the maximum allowed point. Then is the Pc's turn to play and it will take cards until it will arrive over your points or until it will loose, because over 7 and half!
    

Source

  • The whole code and project is in the zip file!
  • Here there is only a description.
  • Classes
  • I used 2 classes for the MFC dialog boxes and classes for the lower level C++/STL engine. CDeck for the deck of cards, CGameCard for the 40 cards, CPlayer for the 2 players you and your Pc and GameNapoletano for the whole game.
  • Some code
  • I used a function to load .jpg and .bmp from files and to render them to the DC: // This function loads a file into an IStream.
  • void myUtilities::LoadPictureFile(LPCTSTR szFile, LPPICTURE &gpPic)
  • And this function uses the OLE technology To map cards picture with the key code that identify the card I used the std::map. For each card I built a key code using its value and its family (there are 40 cards, 10 cards and 4 families) typedef std::map<int, LPPICTURE, std::less > PicCardType;
  • So in the OnPaint function of the main dialog box I show all the current cards in the game, using a std::vector, where I pushed the pointer to the picture card: std::vector<LPPICTURE>
  • Before that, every random card, taken from the deck, has to be found in the map already built, by its key code. // take the idCard from the current card
  • int idCard = card.GetIdCard();
  • // with the idCard we can find the iterator to the picture by the map
  • m_itMyCard = m_CardMap.find(idCard);
  • When the 40 cards are all gone, I have to reshuffle the deck, but I have not to use the card still on the table! So I have to use another deck where I copied all the cards used and reshuffle that one...
  • Conclusion
  • I wrote this code for hobby. Next step will be a poker card game, hopefully reusing the same structure and inheriting from the same classes... Feel free to suggest me your code, and your opinion is always appreciated. Tell me where I have to change, where the code really sucks and what you would do instead.
  • Thank you
The whole code and project is in the zip file!
Here there is only a description.

Classes
I used 2 classes for the MFC dialog boxes and classes for the lower level C++/STL engine. CDeck for the deck of cards, CGameCard for the 40 cards, CPlayer for the 2 players you and your Pc and GameNapoletano for the whole game. 
Some code
I used a function to load .jpg and .bmp from files and to render them to the DC: // This function loads a file into an IStream.
void myUtilities::LoadPictureFile(LPCTSTR szFile, LPPICTURE &gpPic)

And this function uses the OLE technology To map cards picture with the key code that identify the card I used the std::map. For each card I built a key code using its value and its family (there are 40 cards, 10 cards and 4 families) typedef std::map<int, LPPICTURE, std::less > PicCardType;

So in the OnPaint function of the main dialog box I show all the current cards in the game, using a std::vector, where I pushed the pointer to the picture card: std::vector<LPPICTURE>

Before that, every random card, taken from the deck, has to be found in the map already built, by its key code.    // take the idCard from the current card
   int idCard = card.GetIdCard();
   // with the idCard we can find the iterator to the picture by the map
   m_itMyCard = m_CardMap.find(idCard);

When the 40 cards are all gone, I have to reshuffle the deck, but I have not to use the card still on the table! So I have to use another deck where I copied all the cards used and reshuffle that one... 
Conclusion
I wrote this code for hobby. Next step will be a poker card game, hopefully reusing the same structure and inheriting from the same classes... Feel free to suggest me your code, and your opinion is always appreciated. Tell me where I have to change, where the code really sucks and what you would do instead. 

Thank you 
    

 Conclusion

Mauro (Maurus) Mindoli
email:
mindolimauro@rocketmail.com

Hobbye s: Soccer, Chess, Programming, Progressive Rock, Video Games
    

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources de la même categorie

Source avec Zip Source avec une capture JEUX SERPENT par antho974
Source avec Zip Source avec une capture PENDU EN SDL par Damsou91
Source avec Zip STATE MACHINE MODIFICATION MATH BUCKHAM par billybones79
Source avec Zip AUTRE GRILLE DE SUDOKU par Eneur
Source avec Zip Source avec une capture SOKOBAN EN C POUR DÉBUTANT (VERSION AMÉLIORÉE BASÉE SUR LE T... par eustatika

Commentaires et avis

Commentaire de MaurusAP le 27/01/2003 23:07:28

Bonjour,
j'aimerais bien de recevoir de commentaires sur le jeu, mais surtout sur le code.
Si vous voyez des modifies nécessaire à faire ou des bugs n'hesitez pas l'écrire ici.
Je aime bien ameliorer ma programmation en MFC et C++ (et mon français aussi!)

Ciao!

Commentaire de c2lamerd le 26/06/2003 16:58:53

c'est a chier

Commentaire de xBJx le 11/07/2003 10:56:12

Je ne suis pas d'accord avec c2lamerd. On peut d'ailleurs supposer qu'avec un pseudo pareil, il ne fasse que critiquer.
Le programme est assez bien fait à part peut-être le pointeur qui n'est pas très pratique, même si la modification du pointeur est intéressante.

bon courage pour le français

Commentaire de zouki2003 le 01/05/2004 09:32:41

Comment faire pour jouer car il n'y a pas de fichier exe et comme moi et l'informatique ca fait  2 lol

Commentaire de ephores le 01/04/2005 21:41:05

bien bien, j'essayerais d'apprendre pour faire pareil ;-)

Commentaire de khmayes le 17/03/2009 18:57:37

c'est trop fort comme application fait avec mfc wizard application. comment tu as fait pour arriver à écrire ce code. J'aimerai arriver des applications comme cele ci . est ce que tu peux me donner un help exemple un cours ou tutoriel.merci

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,482 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales