34Fermer36
philip-lynxLe 10/11/2010 à 21:02
code source, 2ème partie:
if (gspause==0) { ++temparoch; // animation des rochers if (temparoch>5) { temparoch=0;++aroch; if (aroch>15) aroch=0; } SCBDATA(SCBroch) = rochtab[aroch%18]; SCBX(SCBroch) = rochx; SCBY(SCBroch) = rochy; SCBDATA(SCBroch2) = rochtab[aroch%18]; SCBX(SCBroch2) = roch2x; SCBY(SCBroch2) = roch2y; // ********* rocher 1 : if (eroch==0 & nbrnexu==0) { rochx=180; if (goroch<32) ++goroch; // petite temporisation avant apparition du 1er rocher if (goship==1 & goroch>31 & stopm==0) { rasam=rasa; rasa=random()%4; // de 0 à 3 if (rasa==rasam) // Si le même nombre sort 2 fois de suite, alors... { rasar=random()%2; // de 0 à 1 if (rasar==0) ++rasa; if (rasar==1) --rasa; } if (rasa>3) rasa=0; if (rasa<0) rasa=3; if (gshat==1) // hasard "aidé" { //++atest; gshat=0; if (rasa>1) rasa=rasa-gshas; if (rasa<2) rasa=rasa+gshas; if (rasa>3) rasa=0; if (rasa<0) rasa=3; } if (tyroch==0) rochy=rasa*24; if (tyroch==1) { ++chroch; if (chroch==3) chroch=1; if (chroch==1) {SCBHS(SCBroch) = 0x100;SCBVS(SCBroch) = 0x100;} if (chroch==2) {SCBHS(SCBroch) = 0x150;SCBVS(SCBroch) = 0x150;} if (rasa==3 & chroch==2) rasa=0; rochy=rasa*34; } eroch=1;rochx=180;temprochx=0;rochy=rochy+3; // Taille rocher1: 24*24 ; objectif : // 4 positions de départ Y pour le rocher : rochy = 3 ou 27 ou 51 ou 75 // espacement de 3 lignes en haut et en bas : 3 et 99 (75 + 24 (nbre de ligne du rocher1)) } } if (eroch==1) { rochx=rochx-vroch; if (rochx<-36) {eroch=0;rochx=180;SCBX(SCBroch) = rochx;} // si rocher1 sort de l'écran, alors remise à 0 de sa création. // collision rocher1/shiplayer !!! if (gsblip==1 & stopm==0) { if (rochy+12>posy-4 & rochy+12<posy+28) // test colision rocher 24*24 { if (rochx+12>posx & rochx+12<posx+40) { eroch=0;goroch=0;rochx=180; boumgb=1;aaroch=16; stopm=1;energ=0;SCBX(SCBjauge) = 200; // panne sèche: arrêt du moteur à hélice } } if (eroch==1 & chroch==2 & rochy+24>posy-4 & rochy+24<posy+28) // test colision rocher 36*36 { if (rochx+24>posx & rochx+24<posx+40) { eroch=0;goroch=0;rochx=180; boumgb=1;aaroch=16; stopm=1;energ=0;SCBX(SCBjauge) = 200; // panne sèche: arrêt du moteur à hélice } } } } // ********* rocher 2 : if (eroch2==0 & nbrnexu==0) { roch2x=180; // if (goroch2<128-(gshas*8)) ++goroch2; // petite temporisation avant apparition du 1er rocher // if (goship==1 & goroch2>127-(gshas*8) & stopm==0) // vroch=1; // if (level==3 | level==4) vroch=2; // if (level==5 | level==6) vroch=3; // if (level==7) vroch=4;// trop rapide if (goroch2<32+(216-(vroch*72))) ++goroch2; // petite temporisation avant apparition du 1er rocher if (goship==1 & goroch2>31+(215-(vroch*72)) & stopm==0) { rbsam=rbsa; rbsa=random()%4; // de 0 à 3 if (rbsa==rbsam) // Si le même nombre sort 2 fois de suite, alors... { rbsar=random()%2; // de 0 à 1 if (rbsar==0) ++rbsa; if (rbsar==1) --rbsa; } if (rbsa>3) rbsa=0; if (rbsa<0) rbsa=3; //rasa=3; //atest=rasa; //atest=rbsa; if (rbsa==rasa) //(rbsa==3)//atest) //(atest==rasa)//(atest==0) si le même que le rocher 1, alors... { // rbsa=1; // ++atest; //rbsa=1; rbsar=random()%2; // de 0 à 1 if (rbsar==0) ++rbsa; if (rbsar==1) --rbsa; if (rbsa>3) rbsa=0; if (rbsa<0) rbsa=3; } if (tyroch2==0) roch2y=rbsa*24; if (tyroch2==1) { ++chroch2; if (chroch2==3) chroch2=1; if (chroch2==1) {SCBHS(SCBroch2) = 0x100;SCBVS(SCBroch2) = 0x100;} if (chroch2==2) {SCBHS(SCBroch2) = 0x150;SCBVS(SCBroch2) = 0x150;} if (rbsa==3 & chroch2==2) rbsa=0; roch2y=rbsa*34; } eroch2=1;roch2x=180;temprochx2=0;roch2y=roch2y+3; // Taille rocher1: 24*24 ; objectif : // 4 positions de départ Y pour le rocher : rochy = 3 ou 27 ou 51 ou 75 // espacement de 3 lignes en haut et en bas : 3 et 99 (75 + 24 (nbre de ligne du rocher1)) } } if (eroch2==1) { roch2x=roch2x-vroch; if (roch2x<-36) {eroch2=0;roch2x=180;SCBX(SCBroch2) = roch2x;} // si rocher1 sort de l'écran, alors remise à 0 de sa création. // collision rocher2/shiplayer !!! if (gsblip==3 & stopm==0) { if (roch2y+12>posy-4 & roch2y+12<posy+28) // test colision rocher 24*24 { if (roch2x+12>posx & roch2x+12<posx+40) { eroch2=0;goroch2=0;roch2x=180; boumgb=1;aaroch=16; stopm=1;energ=0;SCBX(SCBjauge) = 200; // panne sèche: arrêt du moteur à hélice } } if (eroch2==1 & chroch2==2 & roch2y+24>posy-4 & roch2y+24<posy+28) // test colision rocher 36*36 { if (roch2x+24>posx & roch2x+24<posx+40) { eroch2=0;goroch2=0;roch2x=180; boumgb=1;aaroch=16; stopm=1;energ=0;SCBX(SCBjauge) = 200; // panne sèche: arrêt du moteur à hélice } } } } // if (eroch>0) // affichage // { // SCBDATA(SCBroch) = rochtab[aroch%18]; // SCBX(SCBroch) = rochx; // SCBY(SCBroch) = rochy; //DrawSprite(SCBroch); // } // test3: //SCBDATA(SCBchiffres) = chiffrestab[10%12]; //SCBX(SCBchiffres) = rochx+12; //SCBY(SCBchiffres) = rochy+12; //DrawSprite(SCBchiffres); // fin test3 // ********* rhume (vilain 1) : if (vil==0 & goship==1) { if (govil<tgovil) //32 { vilx=160;++govil; // petite temporisation avant l'attaque virale } //if (govil==tgovil & stopm==0 & nbrnexu==0) //31 if (stopm==0 & nbrnexu==0) //31 { vilx=160; hasam=hasa; hasa=random()%6; // de 0 à 5 // if (hasa==hasam) ++hasa; // if (hasa>5) hasa=0; if (hasa==hasam | hasa==rasam) // Si le même nombre sort 2 fois de suite, alors... { hasar=random()%2; // de 0 à 1 if (hasar==0) ++hasa; if (hasar==1) --hasa; } if (hasa>5) hasa=0; if (hasa<0) hasa=5; vil=1;vilx=160;tempvilx=0;vily=hasa*16;vily=vily+3;avil=0;tempavil=0; // Taille vilain1: 16*16 ; objectif : // 6 positions de départ Y pour le vilain1 : vily = 3 ou 19 ou 35 ou 51 ou 67 ou 83 // espacement de 3 lignes en haut et en bas : 3 et 99 (83 + 16 (nbre de ligne du vilain1)) } } // // test1: // SCBDATA(SCBchiffres) = chiffrestab[10%12]; // SCBX(SCBchiffres) = posx+30; // SCBY(SCBchiffres) = posy+9; // DrawSprite(SCBchiffres); // SCBX(SCBchiffres) = posx+30; // SCBY(SCBchiffres) = posy+12; // DrawSprite(SCBchiffres); // SCBX(SCBchiffres) = posx+40; // SCBY(SCBchiffres) = posy+9; // DrawSprite(SCBchiffres); // SCBX(SCBchiffres) = posx+40; // SCBY(SCBchiffres) = posy+12; // DrawSprite(SCBchiffres); // fin test1 if (vil==1) { ++tempvilx; // vitesse du vilain 1 en fonction du niveau. if (tempvilx>speedvil) { tempvilx=0;--vilx; } // vilx=vilx-speedvil; // if (level==2 & tempvilx>0) // { // tempvilx=0;--vilx; // } ++tempavil; // animation du vilain 1 /*************************************************************************** ** Les conditions suivantes ralentissent le jeu ! Alors j'opte pour une ** ** seule condition... il faut limiter le nbre de condition. ***************************************************************************/ // if (tempavil==41) tempavil=1; // if (tempavil>0 & tempavil<11) avil=0; // 1 à 10 // if (tempavil>10 & tempavil<21) avil=1; // 11 à 20 // if (tempavil>20 & tempavil<31) avil=2; // 21 à 30 // if (tempavil>30 & tempavil<41) avil=1; // 31 à 40 if (tempavil>10) { tempavil=0;++avil; if (avil>2) avil=0; } // SCBDATA(SCBrhume) = rhumetab[avil%7]; // SCBX(SCBrhume) = vilx; // SCBY(SCBrhume) = vily; // DrawSprite(SCBrhume); if (vilx<-16) {vil=0;govil=0;} // si vilain1 sort de l'écran, alors remise à 0 de sa création. // test2: // SCBX(SCBchiffres) = vilx; // SCBY(SCBchiffres) = vily+8; // DrawSprite(SCBchiffres); // fin test2 // capture du vilain1 !!! // atest=0; // if (vily+8>posy+9 & vily+8<posy+12) atest=1; // if (vily+6>posy+7 & vily+8<posy+16) atest=1; if (stopm==0) { if (vily+8>posy+7 & vily+8<posy+16) { if (vilx>posx+30 & vilx<posx+40) { // atest=1; vil=2;avil=3;tempavil=0; } } } // vily // posx // posy } if (vil==2) // virus capturé le nanoship ! { // avil=3; vily=posy+3;vilx=posx+38; tempd=0; // ici, on stoppe temporairement la jauge. if (tempavil<31) ++tempavil; // animation du vilain 1 if (tempavil>0 & tempavil<11) avil=4; // 1 à 10 if (tempavil>10 & tempavil<21) avil=3; // 11 à 20 if (tempavil>20 & tempavil<31) avil=4; // 21 à 30 if (tempavil==31 | boumgb>0) { tempavil=0;vil=0;govil=0; vilx=160;SCBX(SCBrhume) = vilx; if (boumgb==0) { energ=energ+4;++score; if (energ>10) energ=10; } // --energ; // if (energ<1) energ=10; } } if (vil>0) // affichage { SCBDATA(SCBrhume) = rhumetab[avil%7]; SCBX(SCBrhume) = vilx; SCBY(SCBrhume) = vily; // DrawSprite(SCBrhume); } } // if (gspause==0) DrawSprite(SCBroch); // Affichage sprites chainés (rocher + rhume) // ********* jauge d'énergie du shiplayer: if (gsblip==2) { if (energ>0 & gspause==0 & nbrnexu==0) // Si le shiplayer a encore de l'énergie, alors... { ++tempd; // ...incremente une petite tempo if (tempd>11) // 59 { tempd=0;--energ; if (energ==0) { stopm=1; // panne sèche: arrêt du moteur à hélice SCBX(SCBjauge) = 200; // mettre image jauge hors de l'écran. } } } //energ=1; if (energ>0 & gspause==0) { --energ; // energ de 1 à 10 --> mais de 0 à 9 pour le n° image SCBDATA(SCBjauge) = jaugetab[energ%10]; SCBX(SCBjauge) = 55; SCBY(SCBjauge) = 4; // DrawSprite(SCBjauge); ++energ; } } DrawSprite(SCBjauge); // Affichage sprites (jauge ) if (stopm>0 & gspause==0) { if (boumgb>0) // explosion du shiplayer { ++aaroch; if (aaroch==18) { aaroch=16;nbboum++; // nombre de boum ++scboom; if (scboom>4) scboom=1; } SCBDATA(SCBroch) = rochtab[aaroch%18]; if (scboom==1) { SCBHS(SCBroch) = 0x100;SCBVS(SCBroch) = 0x100; SCBX(SCBroch) = posx+10;SCBY(SCBroch) = posy-1; } if (scboom==2 | scboom==4) { SCBHS(SCBroch) = 0x140;SCBVS(SCBroch) = 0x140; SCBX(SCBroch) = posx+6;SCBY(SCBroch) = posy-4; } if (scboom==3) { SCBHS(SCBroch) = 0x180;SCBVS(SCBroch) = 0x180; SCBX(SCBroch) = posx+2;SCBY(SCBroch) = posy-7; } DrawSprite(SCBroch); SCBHS(SCBroch) = 0x100;SCBVS(SCBroch) = 0x100; } // | cette barre verticale veut dire OR/OU en langage C if (nbboum>31 | outship>31) // outship voir plus haut (pour faire une recherche, appuyez sur Ctrl + F) { SCBX(SCBroch) = 200;SCBX(SCBroch2) = 200; // mettre image rocher et virus hors de l'écran. nbboum=0;scboom=0;outship=0; --gslife; // perd un ship... stopm=0;etape=1;tempa=0;energ=10;goship=0;posx=-40;posy=39;boumgb=0;aaroch=0; govil=0;vil=0;vilx=0;tempvilx=0;vily=0;avil=0;tempavil=0; hasa=0;hasam=0;hasar=0; goroch=0;eroch=0;rochx=0;rochy=0; goroch2=0;eroch2=0;roch2x=0;roch2y=0; temprochx=0;aroch=0;temparoch=0; rasa=0;rasam=0;rasar=0; rbsa=0;rbsam=0;rbsar=0; nbrnexu=0;nbrnext=0; if (gslife>0) // ...mais s'il en reste encore, alors retour à l'étape 1. { etape=1; } if (gslife<1) // ...mais s'il n'en plus, alors game over. { etape=8;tempa=0;xpush=-48;ypush=34; } } } // ********* passage au prochein niveau if (nbrnexu>0) { if (nbrnexu==1 & vil<1 & eroch<1 & eroch2<1) { nbrnexu=2; // joueur n'a plus le contrôle du shiplayer } if (nbrnexu==3) // passage au level suivant { SCBX(SCBroch) = 200;SCBX(SCBroch2) = 200; // mettre image rocher et virus hors de l'écran. //nbboum=0;outship=0; //--gslife; // perd un ship... stopm=0;etape=1;tempa=0;energ=10;goship=0;posx=-40;posy=39;boumgb=0;aaroch=0; govil=0;vil=0;vilx=0;tempvilx=0;vily=0;avil=0;tempavil=0; hasa=0;hasam=0;hasar=0; goroch=0;eroch=0;rochx=0;rochy=0; goroch2=0;eroch2=0;roch2x=0;roch2y=0; temprochx=0;aroch=0;temparoch=0; rasa=0;rasam=0;rasar=0; rbsa=0;rbsam=0;rbsar=0; nbrnexu=0;nbrnext=0; // if (gslife>0) // ...mais s'il en reste encore, alors retour à l'étape 1. // { etape=1;++level; } } } // if (etape==2) // ********************************************************************************************* // if (etape==3) // { // } // ********************************************************************************************* if (etape>7) { SCBDATA(SCB) = gameover; SCBX(SCB) = 70; SCBY(SCB) = 34; DrawSprite(SCB); if (etape==9) { if (!(joystick & BUTTON_LEFT)) { etape=0;SCBX(SCB)=0;SCBY(SCB)=0;SCBDATA(SCB)=fond1; SCBX(SCBchiffres2) = 200; SCBX(SCBchiffres3) = 200; } } if (etape==8) // game over. { SCBDATA(SCB) = pushup; SCBX(SCB) = xpush; SCBY(SCB) = ypush; DrawSprite(SCB); if (xpush<8 & elvl==5) xpush=xpush+2; if (xpush>7) { xpush=7; ++tempa; // bulle info clignote doucement if (tempa>63) tempa=1; if (tempa>0 & tempa<32) ypush=34; if (tempa>31) ypush=200; if (joystick & JOY_RIGHT) { tempa=0;xpush=-48;ypush=34; etape=9; } } } } // ********************************************************************************************* // ********* affichage du score : if ((etape==1 & drap1==1) | etape==2 | etape==8 | etape==9) { if (score<1000) { unite = score % 10; dizaine = score / 10 % 10; centaine = score / 100 % 10; // unité: SCBDATA(SCBchiffres1) = chiffrestab[unite%12]; SCBX(SCBchiffres1) = 150; SCBY(SCBchiffres1) = 53; // dizaine: SCBDATA(SCBchiffres2) = chiffrestab[dizaine%12]; SCBX(SCBchiffres2) = 150; SCBY(SCBchiffres2) = 53-4; // centaine: SCBDATA(SCBchiffres3) = chiffrestab[centaine%12]; // 0 SCBX(SCBchiffres3) = 150; SCBY(SCBchiffres3) = 53-8; } DrawSprite(SCBchiffres1); // Affichage sprites chainés (score) /*************************************************************************** ** Test (lignes suivantes a désactivées) ** ***************************************************************************/ /* //unite = gshas % 10; unite = nbrnexu % 10; // unité: SCBDATA(SCBchiffres1) = chiffrestab[unite%12]; SCBX(SCBchiffres1) = 130; SCBY(SCBchiffres1) = 23; DrawSprite(SCBchiffres1); // Affichage valeur testé unite = rasa % 10; // unité: SCBDATA(SCBchiffres1) = chiffrestab[unite%12]; SCBX(SCBchiffres1) = 130; SCBY(SCBchiffres1) = 53; DrawSprite(SCBchiffres1); // Affichage valeur testé //unite = rbsa % 10; //unite = roch2x % 10; //dizaine = roch2x / 10 % 10; //centaine = roch2x / 100 % 10; unite = goroch2 % 10; dizaine = goroch2 / 10 % 10; centaine = goroch2 / 100 % 10; // unité: SCBDATA(SCBchiffres1) = chiffrestab[unite%12]; SCBX(SCBchiffres1) = 120; SCBY(SCBchiffres1) = 53; // dizaine: SCBDATA(SCBchiffres2) = chiffrestab[dizaine%12]; SCBX(SCBchiffres2) = 120; SCBY(SCBchiffres2) = 53-4; // centaine: SCBDATA(SCBchiffres3) = chiffrestab[centaine%12]; // 0 SCBX(SCBchiffres3) = 120; SCBY(SCBchiffres3) = 53-8; DrawSprite(SCBchiffres1); // Affichage valeur testé unite = atest % 10; dizaine = atest / 10 % 10; // unité: SCBDATA(SCBchiffres1) = chiffrestab[unite%12]; SCBX(SCBchiffres1) = 100; SCBY(SCBchiffres1) = 53; // dizaine: SCBDATA(SCBchiffres2) = chiffrestab[dizaine%12]; SCBX(SCBchiffres2) = 100; SCBY(SCBchiffres2) = 53-4; DrawSprite(SCBchiffres1); // Affichage valeur testé */ /*************************************************************************** ** Fin Test ** ***************************************************************************/ } // ********************************************************************************************* //Fchiffres(8,92,etape); // test de variable (mais où est le debogueur ?) if (etape==2 & gspause>0) { SCBDATA(SCB) = ipause; SCBX(SCB) = 73; SCBY(SCB) = 30; DrawSprite(SCB); } Vsync(); SwapBuffers(); } /************************************************************************** ** FIN de la BOUCLE PRINCIPALE ** **************************************************************************/ }