gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Visual HAM Question [Switching Sprite and Moving]

#95422 - dylanb - Sat Jul 29, 2006 9:40 am

how do i make a sprite change and the character move when i press a button like the up button and then it moves back when the button is unpressed.

if(F_CTRLINPUT_UP_PRESSED) {
change sprite
move sprite
}
can someone tell me

#96264 - Nave Adair - Wed Aug 02, 2006 4:56 am

I haven't used vHAM and the HAM lib in a while, but this is what I remember, might remember wrong.

Code:

ham_UpdateObjGfx(object,sprite);
ham_SetObjXY(object,new x,new y);


Taken right from a random example I opened in the vHAM sample folder:
Code:

ham_UpdateObjGfx(g_Monster,(void*)&monster_Bitmap[g_DirectionAnim+256*(g_AnimCnt%3)]);
ham_SetObjXY(g_Monster,     // The sprite number we want to move
                      g_MonsterX,    // x position of the
                      g_MonsterY);   // y position of the sprite


Hope I can help a bit.[/code]