i'm coding a new version of my HB , Picoozir, and i would like to add some gfx features. Here is a piece of code that allows to select a chopper with the left and right arrows, the next chopper scrolls on the screen. I dont know why but it works 5 or 6 times and the PSP crashs. I tried with SDL and with PSPGU/Grpahics.h but it's the same . I think i got memory management troubles . Could someone help me to handle an understand the gfx secret :)
Here are my 2 functions :
Code: Select all
void Scrolling_Helico(char Sens[10], int num_helico)
{
int heli_precedent;
int i=0;
Image *backgin;
Image *backgheli;
char Path_Heli_In[100];
backgheli = loadImage("Images/fond_heli.png");
clearScreen(0x000000);
blitImageToScreen(0,0,480,272,backgheli,0,0);
if (Sens=="Gauche")
{
heli_precedent=num_helico+1;
blitAlphaImageToScreen(0,0,480,272,fleche_gauche_enfoncee,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite,0,0);
flipScreen();
}
if (Sens=="Droite")
{
heli_precedent=num_helico-1;
blitAlphaImageToScreen(0,0,480,272,fleche_gauche,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite_enfoncee,0,0);
flipScreen();
}
sprintf(Path_Heli_In,"Images/select_%d.png",num_helico);
backgin = loadImage(Path_Heli_In);
if (Sens == "Droite")
{
for (i=0;i<400;i=i+30)
{
blitImageToScreen(0,0,480,272,backgheli,0,0);
blitAlphaImageToScreen(480-i,0,i,272,backgin,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_gauche,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite_enfoncee,0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
for (i=400;i<480;i=i+5)
{
blitImageToScreen(0,0,480,272,backgheli,0,0);
blitAlphaImageToScreen(480-i,0,i,272,backgin,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_gauche,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite_enfoncee,0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
}
if (Sens == "Gauche")
{
for (i=0;i<400;i=i+30)
{
blitImageToScreen(0,0,480,272,backgheli,0,0);
blitAlphaImageToScreen(0,0,i,272,backgin,480-i,0);
blitAlphaImageToScreen(0,0,480,272,fleche_gauche_enfoncee,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite,0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
for (i=400;i<480;i=i+5)
{
blitImageToScreen(0,0,480,272,backgheli,0,0);
blitAlphaImageToScreen(0,0,i,272,backgin,480-i,0);
blitAlphaImageToScreen(0,0,480,272,fleche_gauche_enfoncee,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite,0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
}
}
void Choix_Helico()
{
int num_helico=1;
char Path_Heli_Transp[100];
bool redessiner=true;
Image *fond;
Image *heli_transp;
fond = loadImage("Images/fond_heli.png");
heli_transp = loadImage("Images/select_1.png");
while (1)
{
blitImageToScreen(0,0,480,272,fond,0,0);
blitAlphaImageToScreen(0,0,480,272,heli_transp,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_gauche,0,0);
blitAlphaImageToScreen(0,0,480,272,fleche_droite,0,0);
//guStart();
//if (Langue==1)
// {
// intraFontPrint(ltn1, 140, 17, "Bienvenue dans PicoozIR");
// intraFontPrint(ltn1, 360, 260, "By Pacopad");
// }
// if (Langue==2)
// {
// intraFontPrint(ltn1, 140, 17, "Welcome in PicoozIR");
// intraFontPrint(ltn1, 360, 260, "By Pacopad");
// }
//sceGuFinish();
//sceGuSync(0,0);
sceDisplayWaitVblankStart();
flipScreen();
u32 buttons;
while ((buttons = PollButtons(NULL)) == 0)
sceDisplayWaitVblankStart();
if (buttons & PSP_CTRL_SELECT)
break;
if (buttons & PSP_CTRL_TRIANGLE)
{
Pilotage_Picooz();
// Recharge_Fond(num_helico);
}
if (buttons & PSP_CTRL_CROSS)
{
switch (num_helico)
{
case 1:
Pilotage_Picooz();
break;
case 2:
Pilotage_Picooz_Sky();
break;
case 3:
Pilotage_Atlas();
break;
case 4:
Pilotage_Tandem();
break;
case 5:
Pilotage_Fairy();
break;
}
redessiner=true;
}
if (buttons & PSP_CTRL_SQUARE)
{
// Pilotage_Picooz_MX();
//Recharge_Fond(num_helico);
}
if (buttons & PSP_CTRL_CIRCLE)
{
// Pilotage_Picooz_Sky();
//Recharge_Fond(num_helico);
}
if (buttons & PSP_CTRL_LEFT)
{
if (num_helico>1)
{
num_helico--;
Scrolling_Helico("Gauche",num_helico);
}
sprintf(Path_Heli_Transp,"Images/select_%d.png",num_helico);
heli_transp=loadImage(Path_Heli_Transp);
}
if (buttons & PSP_CTRL_RIGHT)
{
if (num_helico<4)
{
num_helico++;
Scrolling_Helico("Droite",num_helico);
}
sprintf(Path_Heli_Transp,"Images/select_%d.png",num_helico);
heli_transp=loadImage(Path_Heli_Transp);
}
}
}