Advertisement
GeeckoDev

BreakOut4PSP main

Apr 14th, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.06 KB | None | 0 0
  1. /***************************************************************************
  2.  *   Copyright (C) 2008 by Geecko                                          *
  3.  *                                                                         *
  4.  *                                                                         *
  5.  *   This program is free software; you can redistribute it and/or modify  *
  6.  *   it under the terms of the GNU General Public License as published by  *
  7.  *   the Free Software Foundation; either version 2 of the License, or     *
  8.  *   (at your option) any later version.                                   *
  9.  *                                                                         *
  10.  *   This program is distributed in the hope that it will be useful,       *
  11.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  12.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  13.  *   GNU General Public License for more details.                          *
  14.  *                                                                         *
  15.  *   You should have received a copy of the GNU General Public License     *
  16.  *   along with this program; if not, write to the                         *
  17.  *   Free Software Foundation, Inc.,                                       *
  18.  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  19.  ***************************************************************************/
  20.  
  21. #include <pspctrl.h>
  22. #include <pspkernel.h>
  23. #include <pspdebug.h>
  24. #include <pspdisplay.h>
  25. #include <pspgu.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include "./librairies/graphics.h"
  29. #include "./librairies/intraFont.h"
  30. #include "./librairies/util.h"
  31.  
  32. PSP_MODULE_INFO("BreakOut4PSP-stable", 0, 1, 1);
  33.  
  34. #define printf pspDebugScreenPrintf
  35.  
  36. enum colors {       /** Définition des couleurs **/
  37.         RED = 0xFF0000FF,
  38.         GREEN = 0xFF00FF00,
  39.         BLUE =  0xFFFF0000,
  40.         LITEBLUE =  0xFFFF9628,
  41.         WHITE = 0xFFFFFFFF,
  42.         LITEGRAY = 0xFFBFBFBF,
  43.         GRAY =  0xFF7F7F7F,
  44.         DARKGRAY = 0xFF3F3F3F, 
  45.         BLACK = 0xFF000000
  46.         };
  47. enum directions {   /** Définition des directions **/
  48.             N = 1,
  49.             NEL = 2,
  50.             NER = 3,
  51.             NESR = 4,
  52.             SESR = 5,
  53.             SER = 6,
  54.             SEL = 7,
  55.             S = 8,
  56.             SOL = 9,
  57.             SOR = 10,
  58.             SOSR = 11,
  59.             NOSR = 12,
  60.             NOR = 13,
  61.             NOL = 14
  62.         };
  63. enum edges {        /** Définition des bords touchés **/
  64.            LEFT_EDGE = 1,
  65.            TOP_EDGE = 2,
  66.            RIGHT_EDGE = 3,
  67.            BOTTOM_EDGE = 4,
  68.            LEFT_BRICK = 5,
  69.            TOP_BRICK = 6,
  70.            RIGHT_BRICK = 7,
  71.            BOTTOM_BRICK = 8,
  72.            RACKET_EDGE_TOP_E_LEFT = 9,
  73.            RACKET_EDGE_TOP_LEFT = 10,
  74.            RACKET_EDGE_TOP = 11,
  75.            RACKET_EDGE_TOP_RIGHT = 12,
  76.            RACKET_EDGE_TOP_E_RIGHT = 13
  77.        };
  78.        
  79. enum movestates {       /** Définition du statut de mouvement de niveau **/
  80.            NO_MOVE = 1,
  81.            MOVING_LEFT = 2,
  82.            MOVING_RIGHT = 3,
  83.            RIGHT_MOVE_DONE = 4,
  84.            LEFT_MOVE_DONE = 5
  85.        };
  86.  
  87.             /** Callbacks **/
  88. int exit_callback(int arg1, int arg2, void *common) {
  89.           sceKernelExitGame();
  90.           return 0;}
  91.  
  92. int CallbackThread(SceSize args, void *argp) {
  93.           int cbid;
  94.           cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
  95.           sceKernelRegisterExitCallback(cbid);
  96.           sceKernelSleepThreadCB();
  97.           return 0;}
  98.  
  99. int SetupCallbacks(void) {
  100.           int thid = 0;
  101.           thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
  102.           if(thid >= 0) sceKernelStartThread(thid, 0, 0);
  103.           return thid; }
  104.  
  105.  
  106. /**-------------------------------------------------------------*
  107.  |                             Main                             |              
  108.  *-------------------------------------------------------------**/
  109.  
  110. int main(int argc, char *argv[])
  111. {
  112.     /** Divers **/
  113.     SetupCallbacks();
  114.     pspDebugScreenInit();
  115.  
  116.     /** Contrôles **/
  117.     SceCtrlData pad;
  118.     sceCtrlSetSamplingCycle(0);
  119.     sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
  120.  
  121.     /** Sprites **/
  122.     loadWindowImages();
  123.     Image* sprite_r = loadImage("graphics/sprite_racket.png");
  124.     Image* sprite_ba = loadImage("graphics/sprite_ball.png");
  125.     Image* sprite_f = loadImage("graphics/sprite_fire.png");
  126.     Image* sprite_br1 = loadImage("graphics/sprite_brick1.png");
  127.     Image* sprite_br2 = loadImage("graphics/sprite_brick2.png");
  128.     Image* sprite_br3 = loadImage("graphics/sprite_brick3.png");
  129.     Image* background = loadImage("graphics/background.png");
  130.     if ((!sprite_r || !sprite_ba) || (!sprite_f || !sprite_br1) || (!sprite_br2 || !sprite_br3)) printf ("Erreur lors du chargement des sprites !\n\nV\202rifiez si ils sont bien plac\202s dans le dossier graphics a cot\202 de l'EBOOT.");
  131.     if (!background) printf ("Erreur lors du chargement de l'image de fond !\n\nV\202rifiez si elle est bien plac\202e dans le dossier graphics a cot\202 de l'EBOOT.");
  132.  
  133.     /** Police de caractères **/
  134.     char ifi =  intraFontInit();
  135.     intraFont* ifl[2];
  136.     ifl[0] = intraFontLoad("flash0:/font/ltn8.pgf",INTRAFONT_CACHE_MED);
  137.     ifl[1] = intraFontLoad("flash0:/font/ltn0.pgf",INTRAFONT_CACHE_MED);
  138.     if (!ifi) printf("Erreur lors de l'initialisation d'intraFont !\n");
  139.     else if (!ifl[0] || !ifl[1]) printf("Erreur lors du chargement d'intraFont !\n");
  140.  
  141.     /** Niveau(x) de jeu **/
  142.     int levelbufferleft[128]= {0}, levelbuffer[128] = {0}, levelbufferright[128] = {0};
  143.     int levelnumberleft=3,levelnumber=1, levelnumberright=2;
  144.     char levelsize_left = loadLevel(levelbufferleft,levelnumberleft);
  145.     char levelsize = loadLevel(levelbuffer,levelnumber);
  146.     char levelsize_right = loadLevel(levelbufferright,levelnumberright);
  147.     if (levelsize_left<0 || levelsize<0 || levelsize_right<0) printf("Erreur lors du chargement du niveau !\n");
  148.  
  149.     /** Video **/
  150.     initGraphics();
  151.  
  152.     /** Variables **/
  153.       char
  154.       score[20] = {0}, debug[64] = {0}, death[64] = {0}, combobuf[3] = {0},
  155.       levelmovestate=0, state=0, exit_window=0, combo=0, comboval=0, combobar=0;
  156.       unsigned char
  157.       run=1, initialized=0, move=1, move_dir=N, edge=0, lose=0, pause=0, win=0, error_level=0, oldmove=0, oldButtons=0, touched=0, win_i=0;
  158.       int
  159.       levelposition=0, x_ball=0, y_ball=0, x_racket=0, x_brick=0, y_brick=0, t_brick=0, feu=0, score_var=0, active=0, death_i=0;
  160.       const int
  161.       y_racket=235;
  162.  
  163.     while (run)
  164.     {
  165.     /** Touches **/
  166.     sceCtrlPeekBufferPositive(&pad, 1);
  167.  
  168.     if ((!lose && !pause) && (!win && !error_level))
  169.       {
  170.     if(pad.Buttons & PSP_CTRL_LEFT && x_racket > 4) x_racket-=5;
  171.     else if(pad.Buttons & PSP_CTRL_RIGHT && x_racket < 476-95) x_racket+=5;
  172.     if(pad.Buttons & PSP_CTRL_LTRIGGER) levelmovestate=MOVING_RIGHT;
  173.     else if(pad.Buttons & PSP_CTRL_RTRIGGER) levelmovestate=MOVING_LEFT;
  174.     if(pad.Buttons & PSP_CTRL_START && oldButtons != PSP_CTRL_START)
  175.       {
  176.       oldmove = move;
  177.       pause =1;
  178.       move =0;
  179.       }
  180.     if(pad.Buttons & PSP_CTRL_CROSS) initialized = 0;
  181.     if(pad.Buttons & PSP_CTRL_SQUARE) move = 1;
  182.     if(pad.Buttons & PSP_CTRL_TRIANGLE) win = 1;
  183.       }
  184.     else if ((pause && !win) && (!lose && !error_level))
  185.       {
  186.       if(pad.Buttons & PSP_CTRL_START && oldButtons != PSP_CTRL_START)
  187.     {
  188.     pause =0;
  189.     move = oldmove;
  190.     reInitWindow();
  191.     }
  192.       if(pad.Buttons & PSP_CTRL_SQUARE && oldButtons != PSP_CTRL_SQUARE) exit_window=!exit_window;
  193.       }
  194.  
  195.     else if ((!pause && win) && (!lose && !error_level))
  196.       {
  197.       if(pad.Buttons & PSP_CTRL_CIRCLE) run = 0;
  198.       if(pad.Buttons & PSP_CTRL_CROSS)
  199.     {
  200.     levelnumber++;
  201.         memset(levelbuffer, 0, sizeof(levelbuffer));
  202.     levelsize = loadLevel(levelbuffer,levelnumber);
  203.     if (levelsize<0) error_level=1;
  204.     else
  205.       {
  206.       initialized =0;
  207.       win=0;
  208.       }
  209.     }
  210.       }
  211.  
  212.     else if ((!pause && !win) && (lose && !error_level))
  213.       {
  214.       if(pad.Buttons & PSP_CTRL_CIRCLE) run = 0;
  215.       if(pad.Buttons & PSP_CTRL_CROSS && oldButtons != PSP_CTRL_CROSS) initialized =0;
  216.       }
  217.  
  218.     else if ((!pause && win) && (!lose && error_level))
  219.       {
  220.       if(pad.Buttons & PSP_CTRL_CIRCLE) run = 0;
  221.       if(pad.Buttons & PSP_CTRL_SQUARE && oldButtons != PSP_CTRL_SQUARE)
  222.     {
  223.     win=0;
  224.     levelnumber=1;
  225.     levelsize = loadLevel(levelbuffer,levelnumber);
  226.     initialized =0;
  227.     error_level=0;
  228.     }
  229.       }
  230.     oldButtons = pad.Buttons;
  231.  
  232.     if(!initialized)
  233.       {
  234.       x_racket=480/2-96/2;
  235.       y_ball=y_racket-8;
  236.       move_dir=N;
  237.       move = 0;
  238.       initialized = 1;
  239.       lose = 0;
  240.       win = 0;
  241.       combo=0;
  242.       comboval=1;
  243.       /*while (active != levelsize) Remise à zéro des briques
  244.     {
  245.     active+=3;
  246.     death[death_i] = levelbuffer[active]+1;
  247.     death_i++;
  248.     }
  249.       death_i=0;
  250.       active=0;*/
  251.       memset(death, 0, sizeof(death));
  252.       }
  253.  
  254.       if (move)
  255.     {
  256.       /** Detection des bords **/
  257.       if (x_ball <= 0)
  258.         {
  259.         edge = LEFT_EDGE;
  260.         }
  261.       else if (x_ball+8 >= 480)
  262.         {
  263.         edge = RIGHT_EDGE;
  264.         }
  265.       if (y_ball <= 0)
  266.         {
  267.         edge = TOP_EDGE;
  268.         }
  269.       else if (y_ball >= 272)
  270.         {
  271.         edge = BOTTOM_EDGE;
  272.         }
  273.       if (y_ball+8 >= y_racket && y_ball+8 <= y_racket+4)
  274.         {
  275.         if (x_ball+8 >= x_racket && x_ball+2 <= x_racket+10)
  276.           {
  277.           edge = RACKET_EDGE_TOP_E_LEFT;
  278.           if (combo!=0) combo++;
  279.           }
  280.         else if (x_ball+8 >= x_racket+11 && x_ball+2 <= x_racket+30)
  281.           {
  282.           edge = RACKET_EDGE_TOP_LEFT;
  283.           if (combo!=0) combo++;
  284.           }
  285.         else if (x_ball+8 >= x_racket+31 && x_ball+2 <= x_racket+68)
  286.           {
  287.           edge = RACKET_EDGE_TOP;
  288.           if (combo!=0) combo++;
  289.           }
  290.         else if (x_ball+8 >= x_racket+69 && x_ball+2 <= x_racket+85)
  291.           {
  292.           edge = RACKET_EDGE_TOP_RIGHT;
  293.           if (combo!=0) combo++;
  294.           }
  295.         else if (x_ball+8 >= x_racket+86 && x_ball <= x_racket+95)
  296.           {
  297.           edge = RACKET_EDGE_TOP_E_RIGHT;
  298.           if (combo!=0) combo++;
  299.           }
  300.         }
  301.  
  302.       /** Detection des bords des briques **/
  303.       while (active != levelsize)
  304.         {
  305.         x_brick = levelbuffer[active*3];
  306.         y_brick = levelbuffer[active*3+1];
  307.         t_brick = levelbuffer[active*3+2];
  308.         active++;
  309.  
  310.         if (death[death_i] == 0)
  311.           {
  312.           if ((y_ball+8 >= y_brick && y_ball <= y_brick+20) && (x_ball+8 >= x_brick && x_ball+8 <= x_brick+4))
  313.         {
  314.         edge = LEFT_BRICK;
  315.         death[death_i]++;
  316.         touched=1;
  317.         }
  318.           else if ((y_ball+8 >= y_brick && y_ball <= y_brick+20) && (x_ball <= x_brick+60 && x_ball+4 >= x_brick+60))
  319.         {
  320.         edge = RIGHT_BRICK;
  321.         death[death_i]++;
  322.         touched=1;
  323.         }
  324.           else if ((x_ball+8 >= x_brick && x_ball <= x_brick+60) && (y_ball+8 >= y_brick && y_ball+8 <= y_brick+4))
  325.         {
  326.         edge = TOP_BRICK;
  327.         death[death_i]++;
  328.         touched=1;
  329.         }
  330.           else if ((x_ball+8 >= x_brick && x_ball <= x_brick+60) && (y_ball <= y_brick+20 && y_ball+4 >= y_brick+20))
  331.         {
  332.         edge = BOTTOM_BRICK;
  333.         death[death_i]++;
  334.         touched=1;
  335.         }
  336.           }
  337.         if (!combo) comboval=1;
  338.         if (combo>comboval) { comboval++; combo=1; }
  339.         if (touched)
  340.           {
  341.           if (t_brick==0) score_var += 20*comboval;
  342.           else if (t_brick==1 && death[death_i]==1) score_var += 50*comboval;
  343.           else if (t_brick==2 && death[death_i]==1) score_var += 100*comboval;
  344.           }
  345.         touched=0;
  346.         death_i++;
  347.         }
  348.     active =0;
  349.     death_i =0;
  350.  
  351.     /** Direction en fonction du bord touché **/
  352.     if (edge == TOP_EDGE || edge == BOTTOM_BRICK)
  353.       {
  354.       if (move_dir == N) move_dir = S;
  355.       else if (move_dir == NEL) move_dir = SEL;
  356.       else if (move_dir == NER) move_dir = SER;
  357.       else if (move_dir == NESR) move_dir = SESR;
  358.       else if (move_dir == NOL) move_dir = SOL;
  359.       else if (move_dir == NOR) move_dir = SOR;
  360.       else if (move_dir == NOSR) move_dir = SOSR;
  361.       }
  362.  
  363.     else if (edge == BOTTOM_EDGE && !win)
  364.       {
  365.       lose = 1;
  366.       combo = 0;
  367.       }
  368.  
  369.     else if (edge == LEFT_EDGE || edge == RIGHT_BRICK)
  370.       {
  371.       if (move_dir == N) move_dir = S;
  372.       else if (move_dir == NOL) move_dir = NEL;
  373.       else if (move_dir == NOR) move_dir = NER;
  374.       else if (move_dir == NOSR) move_dir = NESR;
  375.       else if (move_dir == SOL) move_dir = SEL;
  376.       else if (move_dir == SOR) move_dir = SER;
  377.       else if (move_dir == SOSR) move_dir = SESR;
  378.       }
  379.  
  380.     else if (edge == RIGHT_EDGE || edge == LEFT_BRICK)
  381.       {
  382.       if (move_dir == N) move_dir = S;
  383.       else if (move_dir == NEL) move_dir = NOL;
  384.       else if (move_dir == NER) move_dir = NOR;
  385.       else if (move_dir == NESR) move_dir = NOSR;
  386.       else if (move_dir == SEL) move_dir = SOL;
  387.       else if (move_dir == SER) move_dir = SOR;
  388.       else if (move_dir == SESR) move_dir = SOSR;
  389.       }
  390.  
  391.     else if (edge == RACKET_EDGE_TOP_E_LEFT)
  392.       {
  393.       if ((move_dir == S || move_dir == SOL) || (move_dir == SOR || move_dir == SOSR)) move_dir = NOSR;
  394.       else if ( move_dir == SEL) move_dir = NOR;
  395.       else if (move_dir == SER) move_dir = NOL;
  396.       else if (move_dir == SESR) move_dir = N;
  397.       }
  398.  
  399.     else if (edge == RACKET_EDGE_TOP_LEFT)
  400.       {
  401.       if (move_dir == S) move_dir = NOL;
  402.       else if (move_dir == SOL || move_dir == SOR) move_dir = NOR;
  403.       else if (move_dir == SOSR) move_dir = NOSR;
  404.       else if ( move_dir == SEL) move_dir = N;
  405.       else if (move_dir == SER) move_dir = NEL;
  406.       else if (move_dir == SESR) move_dir = NER;
  407.       }
  408.  
  409.     else if (edge == RACKET_EDGE_TOP || edge == TOP_BRICK)
  410.       {
  411.       if (move_dir == S) move_dir = N;
  412.       else if (move_dir == SOL) move_dir = NOL;
  413.       else if (move_dir == SOR) move_dir = NOR;
  414.       else if (move_dir == SOSR) move_dir = NOSR;
  415.       else if ( move_dir == SEL) move_dir = NEL;
  416.       else if (move_dir == SER) move_dir = NER;
  417.       else if (move_dir == SESR) move_dir = NESR;
  418.       }
  419.  
  420.     else if (edge == RACKET_EDGE_TOP_RIGHT)
  421.       {
  422.       if (move_dir == S) move_dir = NEL;
  423.       else if (move_dir == SOL) move_dir = N;
  424.       else if (move_dir == SOR) move_dir = NOL;
  425.       else if (move_dir == SOSR) move_dir = NOR;
  426.       else if (move_dir == SEL || move_dir == SER) move_dir = NER;
  427.       else if (move_dir == SESR) move_dir = NESR;
  428.       }
  429.  
  430.     else if (edge == RACKET_EDGE_TOP_E_RIGHT)
  431.       {
  432.       if ((move_dir == S || move_dir == SEL) || (move_dir == SER || move_dir == SESR)) move_dir = NESR;
  433.       else if (move_dir == SOL) move_dir = NER;
  434.       else if (move_dir == SOR) move_dir = NEL;
  435.       else if (move_dir == SOSR) move_dir = N;
  436.       }
  437.  
  438.     /** Deplacer la balle **/
  439.     if      (move_dir == N)    { y_ball-=3; x_ball+=0; }
  440.     else if (move_dir == NEL)  { y_ball-=3; x_ball+=3; }
  441.     else if (move_dir == NER)  { y_ball-=3; x_ball+=4; }
  442.     else if (move_dir == NESR) { y_ball-=4; x_ball+=6; }
  443.     else if (move_dir == SESR) { y_ball+=4; x_ball+=6; }
  444.     else if (move_dir == SER)  { y_ball+=3; x_ball+=4; }
  445.     else if (move_dir == SEL)  { y_ball+=3; x_ball+=3; }
  446.     else if (move_dir == S)    { y_ball+=3; x_ball+=0; }
  447.     else if (move_dir == SOL)  { y_ball+=3; x_ball-=3; }
  448.     else if (move_dir == SOR)  { y_ball+=3; x_ball-=4; }
  449.     else if (move_dir == SOSR) { y_ball+=4; x_ball-=6; }
  450.     else if (move_dir == NOSR) { y_ball-=4; x_ball-=6; }
  451.     else if (move_dir == NOR)  { y_ball-=3; x_ball-=4; }
  452.     else if (move_dir == NOL)  { y_ball-=3; x_ball-=3; }
  453.    
  454.     if ((move_dir == NESR || move_dir == NOSR) || (move_dir == SESR || move_dir == SOSR)) combo=1;
  455.     else combo = 0;
  456.     }
  457.      else if (!move && !pause)
  458.       { x_ball=x_racket+96/2-6/2; } // La balle suit la raquette
  459.  
  460.     while (active != levelsize) /** Gagné ? **/
  461.       {
  462.       if (death[death_i] == 1) win_i++;
  463.       death_i++;
  464.       active++;
  465.       }
  466.     if (win_i == levelsize) win=1;
  467.     death_i=0;
  468.     active=0;
  469.     win_i=0;
  470.  
  471.     if(levelmovestate == MOVING_RIGHT)
  472.       {
  473.       levelposition+=10;
  474.       if (levelposition==480)
  475.     {
  476.     levelmovestate=RIGHT_MOVE_DONE;
  477.     }
  478.       }
  479.     else if(levelmovestate == MOVING_LEFT)
  480.       {
  481.       levelposition-=10;
  482.       if (levelposition==-480)
  483.     {
  484.     levelmovestate=LEFT_MOVE_DONE;
  485.     }
  486.       }
  487.      
  488.     else if(levelmovestate == LEFT_MOVE_DONE)
  489.       {
  490.  
  491.       }
  492.      
  493.     else if(levelmovestate == RIGHT_MOVE_DONE)
  494.       {
  495.       memset(levelbufferright, 0, sizeof(levelbufferright));
  496.       memcpy(levelbufferright,levelbuffer,sizeof(levelbuffer));
  497.       memset(levelbuffer, 0, sizeof(levelbuffer));
  498.       memcpy(levelbuffer,levelbufferleft,sizeof(levelbufferleft));
  499.       memset(levelbufferleft, 0, sizeof(levelbufferleft));
  500.       //
  501.       levelposition=0;
  502.       levelmovestate = NO_MOVE;
  503.       }
  504.  
  505.     /** Affichage **/
  506.     guStart();
  507.     clearScreen(BLACK);
  508.  
  509.     blitImageToScreen(0 ,0 ,480, 272, background, 0, 0); // Image de fond
  510.     blitAlphaImageToScreen(0 ,0 ,96, 10, sprite_r, x_racket, y_racket); // Sprite de la raquette
  511.     if (y_ball <= 272) blitAlphaImageToScreen(0 ,0 ,8, 8, sprite_ba, x_ball, y_ball); // Sprite de la balle
  512.  
  513.     while (active != levelsize)   /** Affichage des briques **/ // Penser au clipping !!
  514.     {
  515.     x_brick = levelbuffer[active*3]+levelposition;
  516.     y_brick = levelbuffer[active*3+1];
  517.     t_brick = levelbuffer[active*3+2];
  518.     active++;
  519.     if (death[death_i] == 0)
  520.       {
  521.       if (t_brick == 0) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br1, x_brick, y_brick); // Sprite de la brique
  522.       else if (t_brick == 1) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br2, x_brick, y_brick); // Sprite de la brique
  523.       else if (t_brick == 2) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br3, x_brick, y_brick); // Sprite de la brique
  524.       }
  525.     death_i++;
  526.     }
  527.     death_i =0;
  528.     active =0;
  529.  
  530.     if (levelmovestate == MOVING_RIGHT)
  531.       {
  532.       while (active != levelsize_left)
  533.     {
  534.     x_brick = levelbufferleft[active*3]+levelposition-480;
  535.     y_brick = levelbufferleft[active*3+1];
  536.     t_brick = levelbufferleft[active*3+2];
  537.     active++;
  538.     if (t_brick == 0) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br1, x_brick, y_brick); // Sprite de la brique
  539.     else if (t_brick == 1) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br2, x_brick, y_brick); // Sprite de la brique
  540.     else if (t_brick == 2) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br3, x_brick, y_brick); // Sprite de la brique
  541.     }
  542.       active =0;
  543.       }
  544.      
  545.     else if (levelmovestate == MOVING_LEFT)
  546.       {
  547.       while (active != levelsize_right)
  548.     {
  549.     x_brick = levelbufferright[active*3]+levelposition+480;
  550.     y_brick = levelbufferright[active*3+1];
  551.     t_brick = levelbufferright[active*3+2];
  552.     active++;
  553.     if (t_brick == 0) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br1, x_brick, y_brick); // Sprite de la brique
  554.     else if (t_brick == 1) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br2, x_brick, y_brick); // Sprite de la brique
  555.     else if (t_brick == 2) blitAlphaImageToScreen(0 ,0 ,60, 20, sprite_br3, x_brick, y_brick); // Sprite de la brique
  556.     }
  557.       active =0;
  558.       }
  559.  
  560.    
  561.     if (feu == 40) feu=0;
  562.     if (feu > 30) blitAlphaImageToScreen(68 ,0 ,18, 18, sprite_f, 5, 250);
  563.     else if (feu > 20) blitAlphaImageToScreen(48 ,0 ,18, 18, sprite_f, 5, 250); // Sprites
  564.     else if (feu > 10) blitAlphaImageToScreen(27 ,0 ,18, 18, sprite_f, 5, 250); // du feu
  565.     else if (feu >= 0) blitAlphaImageToScreen(0 ,0 ,18, 18, sprite_f, 5, 250); 
  566.     feu++;
  567.  
  568.     sprintf(combobuf,"%dX", comboval);
  569.     if (combo) intraFontSetStyle(ifl[1],1.00f,RED,0,INTRAFONT_ALIGN_LEFT);
  570.     else if (!combo) intraFontSetStyle(ifl[1],1.00f,DARKGRAY,0,INTRAFONT_ALIGN_LEFT);
  571.     intraFontPrint(ifl[1],2,17,combobuf);
  572.     sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  573.     sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  574.     sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  575.  
  576.     sceGuFinish();
  577.     sceGuSync(0,0);
  578.  
  579.     combobar = combo*30/comboval;
  580.     if (combobar<=2) combobar=3;
  581.     else if (combobar>=31) combobar=30;
  582.     drawLineScreen(2,21,31,21,BLACK);
  583.     putPixelScreen(BLACK, 2, 22);
  584.     drawLineScreen(3,22,combobar,22,RED);
  585.     putPixelScreen(BLACK, 31, 22);
  586.     drawLineScreen(2,23,31,23,BLACK);
  587.  
  588.     guStart();
  589.  
  590.     sprintf(score,"score = %d", score_var);
  591.     intraFontSetStyle(ifl[0],1.00f,BLACK,0,INTRAFONT_ALIGN_RIGHT);
  592.     intraFontPrint(ifl[0],475,12,score);
  593.     sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  594.     sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  595.     sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  596.  
  597.     if (lose)
  598.       {
  599.       intraFontSetStyle(ifl[0], 1.25f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  600.       intraFontPrint(ifl[0],480/2,272/2,"Vous avez perdu !");
  601.       intraFontSetStyle(ifl[0], 1.00f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  602.       intraFontPrint(ifl[0],240,260,"X pour recommencer, O pour retourner au XMB :(");
  603.       sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  604.       sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  605.       sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  606.       }
  607.  
  608.     if (win && !error_level)
  609.       {
  610.       intraFontSetStyle(ifl[0], 1.25f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  611.       intraFontPrint(ifl[0],480/2,272/2,"Vous avez gagne !");
  612.       intraFontSetStyle(ifl[0], 1.00f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  613.       intraFontPrint(ifl[0],240,260,"X pour aller au niveau suivant, O pour retourner au XMB :)");
  614.       sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  615.       sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  616.       sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  617.       }
  618.  
  619.     if (pause)
  620.       {
  621.       sprintf(debug,"%d, %d, %d, %d, %d, %d... %d", levelbuffer[0], levelbuffer[1], levelbuffer[2], levelbuffer[3], levelbuffer[4], levelbuffer[5], levelsize);
  622.       state = drawWindow(240,136,exit_window);
  623.       intraFontSetStyle(ifl[0], 1.25f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  624.       intraFontPrint(ifl[0],480/2,272/2,"En pause...");
  625.       intraFontSetStyle(ifl[0], 0.75f, BLACK,0,INTRAFONT_ALIGN_CENTER);
  626.       intraFontPrint(ifl[0],480/2,252,debug);
  627.       sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  628.       sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  629.       sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  630.       }
  631.  
  632.     if (error_level)
  633.       {
  634.       intraFontSetStyle(ifl[0], 1.25f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  635.       intraFontPrint(ifl[0],480/2,272/2,"Il n'y a pas de niveau suivant !");
  636.       intraFontSetStyle(ifl[0], 1.00f, BLACK, WHITE,INTRAFONT_ALIGN_CENTER);
  637.       intraFontPrint(ifl[0],240,260,"Carre pour retourner au 1er niveau, O pour retourner au XMB :)");
  638.       sceGuTexMode(GU_PSM_8888, 0, 0, 0);
  639.       sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  640.       sceGuTexFilter(GU_NEAREST, GU_NEAREST);
  641.       }
  642.     sceGuFinish();
  643.     sceGuSync(0,0);
  644.     sceDisplayWaitVblankStart();
  645.     flipScreen();
  646.     }
  647.  
  648.     sceKernelExitGame();
  649.     return 0;
  650. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement