PDA

Voir la version complète : [Projet GBA] Demande d'aide pour un projet


daathnahonn
24/04/2006, 12h25
Bonjours a tous,

Je suis très novice dans la programmation sur GBA, mais je dois pourtant faire un projet scolaire de jeu

Et la, je bloque sur les sprites... pas sur leur affichage, car j'ai pris exemple sur les codes sources livré avec HAM, mais sur la génération d'un RAW a partir d'un bmp.

Voici mon image BMP :
http://www.playeradvance.org/forum/attachment.php?attachmentid=287

Et le "résultat" a l'écran :
http://www.playeradvance.org/forum/attachment.php?attachmentid=288

Et pour finir, si ca peut servir (genre il est foireux), voici le code source

#include <mygba.h>

MULTIBOOT

#include "gfx/graphics.raw.c"
#include "gfx/master.pal.c"

#define ANIM_UP 0
#define ANIM_RIGHT 256*3
#define ANIM_DOWN 256*6
#define ANIM_LEFT 256*9

void redrawPlayer();
void hblFunc();
void queryKeys();

u8 newframe=0;
u32 frames=0;
u8 pause=0;
u8 TmpReac=0;

u16 dir_anim=ANIM_DOWN;

u8 animcnt=0;
u8 mario;

u8 mario_x;
u8 mario_y;

u8 in_motion=0;

int main(void)
{
ham_Init();
ham_SetBgMode(0);

ham_LoadObjPal(&graphics_Palette,256);

ham_StartIntHandler(INT_TYPE_VBL,&hblFunc);

if(ham_InitRAM(RAM_TYPE_SRAM_256K))
{
ham_LoadIntFromRAM("x", &mario_x);
ham_LoadIntFromRAM("y", &mario_y);
ham_LoadIntFromRAM("Direction", &dir_anim);

}
else
{
mario_x = (GBA_SCREEN_WIDTH / 2)-8;
mario_y = (GBA_SCREEN_HEIGHT / 2)-24;
}

mario = ham_CreateObj((void*)&graphics_Bitmap[dir_anim+256],0,1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,mario_x,mario_y );


while (TRUE)
{
/*if(pause == 1)
{
ham_StartIntHandler(INT_TYPE_VBL,&hblFunc);
}
else if(pause == 2)
{
// Affichage des scores
//ham_StartIntHandler(INT_TYPE_VBL,&hblFunc);
}*/
}
return 0;
}

/*void start()
{

if(F_CTRLINPUT_START_PRESSED)
{
pause = 1;
}
}*/

void hblFunc()
{
if(!(frames%5) && in_motion)
{
ham_UpdateObjGfx(mario,(void*)&graphics_Bitmap[dir_anim+256*(animcnt%3)]);
animcnt++;
in_motion=0;
}

ham_CopyObjToOAM();
if(TmpReac <= 0)
{
queryKeys();
TmpReac = 1;
}
TmpReac--;

redrawPlayer();
frames++;
}

void queryKeys()
{
if(pause == 0)
{
if(F_CTRLINPUT_UP_PRESSED)
{
dir_anim= ANIM_UP;
mario_y--;
in_motion=1;
return;
}

if(F_CTRLINPUT_DOWN_PRESSED)
{
dir_anim= ANIM_DOWN;
mario_y++;
in_motion=1;
return;
}

if(F_CTRLINPUT_LEFT_PRESSED)
{
dir_anim= ANIM_LEFT;
mario_x--;
in_motion=1;
return;
}

if(F_CTRLINPUT_RIGHT_PRESSED)
{
dir_anim= ANIM_RIGHT;
mario_x++;
in_motion=1;
return;
}
}
if(F_CTRLINPUT_START_PRESSED)
{
if(pause != 0)
{
pause = 0;
ham_SetObjVisible(mario, 1);
}
else
{
pause = frames;
ham_SetObjVisible(mario, 0);
}
TmpReac = 10;
return;

}
}

void redrawPlayer()
{
ham_SetObjXY(mario, mario_x, mario_y);
ham_SaveIntToRAM("x", mario_x);
ham_SaveIntToRAM("y", mario_y);
ham_SaveIntToRAM("Direction", dir_anim);
}

En gros, je pense que je n'utilise pas la bonne méthode pour générer le RAW.C de l'image...

Merci d'avance pour toute aide

Dr.Vince
24/04/2006, 12h37
salut !!

bah quelle méthode utilises-tu justement pour générer le raw ?? et la palette ??

daathnahonn
24/04/2006, 12h42
J'ai essayé plusieurs programmes (GBATiMaSe, Tile Studio, etc). Pour les derniers essai, j'ai utilisé le prog de HAM, Gfx2gba (avec les commandes -fsrc -m -pmaster.pal -t8 graphics.bmp

Nesgba
24/04/2006, 13h27
poste la rom toi aussi ;)