0/5 (13 avis)
Vue 10 397 fois - Téléchargée 664 fois
#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; }
1 févr. 2002 à 17:14
MAIS J'ESPERE QUE TU ES EFFECTIVEMENT BIEN DESOLE POUR CEUX QUI SONT DE DROITE!!!(je sens que je vais bientôt faire un petit jeu avec lionel jospin!)...
Mais j'avoue, que même moi je me suis bien pris a ce jeu.
Bon courage(ta prochaine cible, ce sera madelin??)
1 févr. 2002 à 22:06
on pourrai meme faire une compil ou on choisi le personnage que l'on veut incarné !
23 mars 2002 à 11:45
par contre je c pas si ca ne le fait ke chez moi mais ya pas de clear enfin je peu dire ke toutes les images laissent des trainées
23 avril 2002 à 11:49
"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é ! "
voila mais surtout faut pas oublier de voter chirac car il est quand meme moin pourri que lepen (qui va pas tarder a avoir un jeu a son nom egalement) !
moi qui suit de gauche je vais devoir voter pour chirac :(
6 mars 2003 à 03:53
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.