Accueil > > > CHIRACWORLD (VC++ 5.0)
CHIRACWORLD (VC++ 5.0)
Information sur la source
Description
voila un petit jeu bien sympathique et qui va pas faire plaisir a chirac :) ce jeu n'est pas fait pour critiquer la politique, c juste pasque je savais pas quoi programmer ! le but de se jeu est extremement simple : il faut choper les billets et eviter les cassettes mery ! avec les fleches gauche et droite on se deplace et avec la fleche du haut on fait lever les mains de chirac. pour choper des billets ou des cassettes mery, il faut lever les mains. le plus dur dans ce jeu ça à été de trouver, modifier et faires les images ! le code source est horrible, y'as aucun commentaire, et en plus je fait un gros mix prog objet / prog structuré , bref vous allez adorer... de plus les quelques commentaire sont en fait des parties de source que j'ai desactivé ou alors des bout de source qui correspondent à plus rien pasque la source a trop changer ! j'essayerai lors des prochaines mise a jour de faire un petit effort ! voici un petit bout du code source (chirac.cpp), le reste est dans le zip ! j'ai du virer l'image de fond pasque sinon le zip fesait plus de 200 ko et ne passait pas ! donc pour pouvoir jouer il faut creer un fichier bitmap non compressé nommé : fond.bmp désolé !
Source
- #include <windows.h>
- #include <time.h>
- #include <stdio.h>
-
- #include "Graphique.h"
- #include "Entree.h"
- #include "Gest_Media.h"
- #include "pepere.h"
- #include "billet.h"
- #include "cassette.h"
-
- struct position{
- double x,y;
- };
- #define UPDATE_FRAME_RATE 32
-
-
- Entree *LPEntree;
- //LPDIRECTSOUND LPDirectSound;
-
- //STR_joueur Joueur;
-
- // Pour le thread principal :
- HICON hIcon;
- HCURSOR hCursor;
- HWND HFenetre_principale;
- DWORD LastGetTick, NewGetTick;
- DWORD Images_par_seconde;
- double DBLTemp;
- bool Alerte,btn[3],En_Jeu;
- int Vitesse_du_jeu, tempus = 0,tbl_dbg[1000],tbl_dbg_i,x,y,OldCase;
- char kbd[256];
- position souris;
- int Score;
- pepere Chirac;
- billet Billet,*B;
- cassette Cassette,*C;
-
- bonus **Obj;
-
-
- /////////// FUNCTIONS ///////////
-
- LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
- int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
-
- int Update_Frame();
- int Update_Frame_Jeu();
- int Update_Frame_Start();
-
- /////////// FUNCTIONS => WinMain ///////////
-
- int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil){
- HWND hwnd;
- MSG msg;
- WNDCLASSEX wincl;
- int i;
-
- srand( (unsigned)time( NULL ) );
- wincl.hInstance = hThisInstance;
- wincl.lpszClassName = "Chirac";
- wincl.lpfnWndProc = WindowProcedure;
- wincl.style = CS_HREDRAW|CS_VREDRAW|CS_BYTEALIGNWINDOW;
- wincl.cbSize = sizeof(WNDCLASSEX);
- hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wincl.hIcon = hIcon;
- wincl.hIconSm = hIcon;
- hCursor = LoadCursor(NULL, NULL);
- wincl.hCursor = hCursor;
- wincl.lpszMenuName = NULL;
- wincl.cbClsExtra = 0;
- wincl.cbWndExtra = 0;
- wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
- if(!RegisterClassEx(&wincl)) return 0;
- hwnd = CreateWindowEx(0,"Chirac","Chirac World",WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,NULL,NULL,hThisInstance,NULL);
-
- HFenetre_principale = hwnd;
- ShowWindow(hwnd, nFunsterStil);
- UpdateWindow(hwnd);
-
- //if(DirectSoundCreate(NULL, &LPDirectSound, NULL)!=DS_OK) exit(1);
- //if(LPDirectSound->SetCooperativeLevel(hwnd, DSSCL_PRIORITY)!=DS_OK) exit(1);
-
- //if((i=Init_Media(hwnd))!=1) exit(i);
- if(Init_Media(hwnd)!=1) exit(0);
-
- Chirac.SetGraphClass(LPGraph);
- Chirac.SetSpriteGDHB(Media.pDDSChirac[0],Media.pDDSChirac[2],Media.pDDSChirac[3],Media.pDDSChirac[1],0,0,0,0,0);
- Chirac.SetXY(280,380);
- Chirac.Set_ZS(2,97,48,98);
-
- Cassette.SetGraphClass(LPGraph);
- Cassette.SetSpriteGDHB(
- Media.pDDSCassette[0],
- Media.pDDSCassette[0],
- Media.pDDSCassette[1],
- Media.pDDSCassette[2],
- Media.pDDSCassette[3],0,0,0,0);
- Cassette.ZS_Egal_Taille_Img();
- Cassette.SetXY(100,-50);
-
- Billet.SetGraphClass(LPGraph);
- Billet.SetSpriteGDHB(
- Media.pDDSBillet[0],
- Media.pDDSBillet[0],
- Media.pDDSBillet[1],
- Media.pDDSBillet[2],
- Media.pDDSBillet[3],0,0,0,0);
- Billet.ZS_Egal_Taille_Img();
- Billet.SetXY(100,-50);
- Obj = (bonus**) malloc(sizeof(bonus*)*10);
-
- for(i = 0;i < 10;i++){
- B = new billet(Billet);
- B->SetXY(rand()%590,-50*(i+1));
- Obj[i] = B;
- }
-
-
-
- LPEntree = new Entree;
- LPEntree->initialise(hwnd, hThisInstance);
-
- NewGetTick = GetTickCount();
-
- while(true)
- if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ){
- if( !GetMessage( &msg, NULL, 0, 0 ) ) return msg.wParam;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }else{
- NewGetTick = GetTickCount();
- if((NewGetTick-LastGetTick)>UPDATE_FRAME_RATE){
- LastGetTick = NewGetTick;
- Update_Frame();
- }
- }
- }
-
- /////////// FUNCTIONS => WindowProcedure ///////////
- LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
- int i;
- switch(message){
- case WM_SETCURSOR:
- SetCursor(hCursor);
- return TRUE;
- break;
- case WM_DESTROY:
-
- for(i = 0;i < 10;i++){
- delete Obj[i];
- }
- free(Obj);
-
- Free_Media();
- //LPDirectSound->Release();
- delete LPEntree;
- DestroyIcon(hIcon);
- DestroyCursor(hCursor);
- PostQuitMessage(1);
- break;
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- return 0;
- }
-
- /////////// FUNCTIONS => Update_Frame ///////////
-
- int Update_Frame(void){
- tempus++;
-
- LPEntree->GetEtatTouch((char *)&kbd);
- LPEntree->Getposrel(&x,&y,(bool *)&btn);
-
- Update_Frame_Jeu();
- LPGraph->flip();
- return 1;
- }
-
- void NouveauBonus(int i){
- delete Obj[i];
- switch(rand()%100){
- case 0:case 1:case 2:case 3:case 4:case 5:
- case 6:case 7:case 8:case 9:case 10:
- C = new cassette(Cassette);
- Obj[i] = C;
- break;
- default:
- B = new billet(Billet);
- Obj[i] = B;
- }
- Obj[i]->SetXY(rand()%590,-50*(i+1));
- }
-
- int Update_Frame_Jeu(){
- char texte[512];
- int i;
-
- LPGraph->Dessine(Media.pDDSFond,0,0);
-
- if(kbd[DIK_LEFT]) Chirac.DeplacementRelatif(-5,0);
- if(kbd[DIK_RIGHT]) Chirac.DeplacementRelatif(5,0);
- if(kbd[DIK_UP]) Chirac.DeplacementRelatif(0,-5);
- Chirac.Bouge(1);
- Chirac.Dessine();
-
- for(i = 0;i < 10;i++){
- if(!Obj[i]->Bouge(1)) NouveauBonus(i);
- Obj[i]->Dessine();
- if(Chirac.Touch(*Obj[i])){
- Score += Obj[i]->Score();
- NouveauBonus(i);
- }
- }
- sprintf(texte,"Score : %d",Score);
- LPGraph->ecrire(10,10,texte,RGB(255,0,0),1);
- if(kbd[DIK_ESCAPE]||kbd[DIK_F12]){
- PostMessage(HFenetre_principale, WM_CLOSE, 0, 0);
- }
- return true;
- }
-
#include <windows.h>
#include <time.h>
#include <stdio.h>
#include "Graphique.h"
#include "Entree.h"
#include "Gest_Media.h"
#include "pepere.h"
#include "billet.h"
#include "cassette.h"
struct position{
double x,y;
};
#define UPDATE_FRAME_RATE 32
Entree *LPEntree;
//LPDIRECTSOUND LPDirectSound;
//STR_joueur Joueur;
// Pour le thread principal :
HICON hIcon;
HCURSOR hCursor;
HWND HFenetre_principale;
DWORD LastGetTick, NewGetTick;
DWORD Images_par_seconde;
double DBLTemp;
bool Alerte,btn[3],En_Jeu;
int Vitesse_du_jeu, tempus = 0,tbl_dbg[1000],tbl_dbg_i,x,y,OldCase;
char kbd[256];
position souris;
int Score;
pepere Chirac;
billet Billet,*B;
cassette Cassette,*C;
bonus **Obj;
/////////// FUNCTIONS ///////////
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
int Update_Frame();
int Update_Frame_Jeu();
int Update_Frame_Start();
/////////// FUNCTIONS => WinMain ///////////
int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil){
HWND hwnd;
MSG msg;
WNDCLASSEX wincl;
int i;
srand( (unsigned)time( NULL ) );
wincl.hInstance = hThisInstance;
wincl.lpszClassName = "Chirac";
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_HREDRAW|CS_VREDRAW|CS_BYTEALIGNWINDOW;
wincl.cbSize = sizeof(WNDCLASSEX);
hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIcon = hIcon;
wincl.hIconSm = hIcon;
hCursor = LoadCursor(NULL, NULL);
wincl.hCursor = hCursor;
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
if(!RegisterClassEx(&wincl)) return 0;
hwnd = CreateWindowEx(0,"Chirac","Chirac World",WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,NULL,NULL,hThisInstance,NULL);
HFenetre_principale = hwnd;
ShowWindow(hwnd, nFunsterStil);
UpdateWindow(hwnd);
//if(DirectSoundCreate(NULL, &LPDirectSound, NULL)!=DS_OK) exit(1);
//if(LPDirectSound->SetCooperativeLevel(hwnd, DSSCL_PRIORITY)!=DS_OK) exit(1);
//if((i=Init_Media(hwnd))!=1) exit(i);
if(Init_Media(hwnd)!=1) exit(0);
Chirac.SetGraphClass(LPGraph);
Chirac.SetSpriteGDHB(Media.pDDSChirac[0],Media.pDDSChirac[2],Media.pDDSChirac[3],Media.pDDSChirac[1],0,0,0,0,0);
Chirac.SetXY(280,380);
Chirac.Set_ZS(2,97,48,98);
Cassette.SetGraphClass(LPGraph);
Cassette.SetSpriteGDHB(
Media.pDDSCassette[0],
Media.pDDSCassette[0],
Media.pDDSCassette[1],
Media.pDDSCassette[2],
Media.pDDSCassette[3],0,0,0,0);
Cassette.ZS_Egal_Taille_Img();
Cassette.SetXY(100,-50);
Billet.SetGraphClass(LPGraph);
Billet.SetSpriteGDHB(
Media.pDDSBillet[0],
Media.pDDSBillet[0],
Media.pDDSBillet[1],
Media.pDDSBillet[2],
Media.pDDSBillet[3],0,0,0,0);
Billet.ZS_Egal_Taille_Img();
Billet.SetXY(100,-50);
Obj = (bonus**) malloc(sizeof(bonus*)*10);
for(i = 0;i < 10;i++){
B = new billet(Billet);
B->SetXY(rand()%590,-50*(i+1));
Obj[i] = B;
}
LPEntree = new Entree;
LPEntree->initialise(hwnd, hThisInstance);
NewGetTick = GetTickCount();
while(true)
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ){
if( !GetMessage( &msg, NULL, 0, 0 ) ) return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}else{
NewGetTick = GetTickCount();
if((NewGetTick-LastGetTick)>UPDATE_FRAME_RATE){
LastGetTick = NewGetTick;
Update_Frame();
}
}
}
/////////// FUNCTIONS => WindowProcedure ///////////
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
int i;
switch(message){
case WM_SETCURSOR:
SetCursor(hCursor);
return TRUE;
break;
case WM_DESTROY:
for(i = 0;i < 10;i++){
delete Obj[i];
}
free(Obj);
Free_Media();
//LPDirectSound->Release();
delete LPEntree;
DestroyIcon(hIcon);
DestroyCursor(hCursor);
PostQuitMessage(1);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
/////////// FUNCTIONS => Update_Frame ///////////
int Update_Frame(void){
tempus++;
LPEntree->GetEtatTouch((char *)&kbd);
LPEntree->Getposrel(&x,&y,(bool *)&btn);
Update_Frame_Jeu();
LPGraph->flip();
return 1;
}
void NouveauBonus(int i){
delete Obj[i];
switch(rand()%100){
case 0:case 1:case 2:case 3:case 4:case 5:
case 6:case 7:case 8:case 9:case 10:
C = new cassette(Cassette);
Obj[i] = C;
break;
default:
B = new billet(Billet);
Obj[i] = B;
}
Obj[i]->SetXY(rand()%590,-50*(i+1));
}
int Update_Frame_Jeu(){
char texte[512];
int i;
LPGraph->Dessine(Media.pDDSFond,0,0);
if(kbd[DIK_LEFT]) Chirac.DeplacementRelatif(-5,0);
if(kbd[DIK_RIGHT]) Chirac.DeplacementRelatif(5,0);
if(kbd[DIK_UP]) Chirac.DeplacementRelatif(0,-5);
Chirac.Bouge(1);
Chirac.Dessine();
for(i = 0;i < 10;i++){
if(!Obj[i]->Bouge(1)) NouveauBonus(i);
Obj[i]->Dessine();
if(Chirac.Touch(*Obj[i])){
Score += Obj[i]->Score();
NouveauBonus(i);
}
}
sprintf(texte,"Score : %d",Score);
LPGraph->ecrire(10,10,texte,RGB(255,0,0),1);
if(kbd[DIK_ESCAPE]||kbd[DIK_F12]){
PostMessage(HFenetre_principale, WM_CLOSE, 0, 0);
}
return true;
}
Conclusion
désoler pour ceux qui sont de droite ... et les profs qui aiment les programmes bien structuré et commenté :) je prone l'anarchie dans les codes sources !!! j'essayerai de faire un mise a jour avec un code un peu plus "correct" :)
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|