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.

DS development > A little big problem

#45885 - Lord_Rafa - Thu Jun 16, 2005 12:07 am

Hi I make a galaxian game whit the PA lib but I don know how put a background and sprites from bmp image this is my code:

Code:
#include "PA.h"   


#include "gfx/cruiser1.raw.c" 
#include "gfx/ship7.c"
#include "gfx/ship7.h"


#include "gfx/sprite.pal.c"


#include "gfx/fond.raw.c" 
#include "gfx/fond.map.c" 
#include "gfx/bg.pal.c" 


void PA_test(const char *text);

s16 x = 0;
s16 y = 0;

s16 A = 0;
s16 D = 0;

s16 M = 0;
s16 N = 0;

s16 S = 0;
s16 B = 0;
s16 fin = 0;

int main(int argc, char ** argv) {


PA_Init();

PA_InitVBL();

PA_LoadPal(PAL_SPRITE0, sprite_Palette);
PA_LoadPal(PAL_SPRITE1, sprite_Palette);

PA_LoadPal(PAL_BG1, bg_Palette);

PA_LoadSpriteExtPal(1, 2, (void*)sprite_Palette);


PA_CreateSprite(1, 0, (void*)cruiser1_Bitmap, OBJ_SIZE_32X32, 1, 0, 223, 160);
PA_CreateSprite(1, 3, (void*)cruiser1_Bitmap, OBJ_SIZE_32X32, 1, 0, 112, 0);

x = 224;
y = 160;
A = -1;
B = -1;
M = 112;
N = 1;


PA_LoadSimpleBg(1, 3, fond_Tiles, fond_Map, BG_256X256, 1, 1);

PA_InitText(0, 0);
PA_SetTextCol(0, 20, 20, 20);
while (fin == 0) {

if ( (x>=0) && (x<=224)) {
   x += Pad.Held.Right - Pad.Held.Left;


}
if (x<0) {
   x=0;
}
if (x>224)
{
   x=224;
}



PA_SetSpriteXY(1,0,x,y);

if (M==224) {N=-1;}
if (M==0) {N=1;}
M=M+N;
PA_SetSpriteX(1,3,M);

if ((Pad.Newpress.L)&&(A==-1)) {
   A=160;
   D=x;
   PA_CreateSprite(1, 1, (void*)ship7Data, OBJ_SIZE_16X16, 0, 0, D, A);
    }
if (A>-1) {A=A-1;}
PA_SetSpriteY(1,1,A);

if (A==0)
{
   PA_DeleteSprite(1,1);
   if (D==M)
   {
          PA_DeleteSprite(1,0);
            PA_DeleteSprite(1,1);
          PA_DeleteSprite(1,3);
         fin = 1;
   }
}


if ((Pad.Newpress.R)&&(B==-1)) {
   B=160;
   S=x+16;
   PA_CreateSprite(1, 2, (void*)ship7Data, OBJ_SIZE_16X16, 0, 0, S, B);
    }
if (B>-1) {B=B-1;}
PA_SetSpriteY(1,2,B);

if (B==0)
{
   PA_DeleteSprite(1,2);
   S=M;
   if (S==M)
   {
          PA_DeleteSprite(1,0);
            PA_DeleteSprite(1,1);
         PA_DeleteSprite(1,3);
         fin = 1;
   }
}
   
PA_WaitForVBL();

}

while (1)
{
PA_OutputSimpleText(0, 14, 8,"FIN");
}
  return 0;
}

void PA_test(const char *text){};

#45909 - Mollusk - Thu Jun 16, 2005 1:48 pm

Check out http://teamnnc.free.fr/html/modules.php?name=Forums&file=viewtopic&t=2&sid=218ec982c5b551b732efc58e12455e1d, there's a part on converting your graphics

#45955 - Lord_Rafa - Fri Jun 17, 2005 3:32 am

thanks for your help