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.

Beginners > sprites not showing

#81000 - NeoZF - Wed Apr 26, 2006 6:53 pm

I found a tutorial on how to make it show a background and i desided to change it a bit, i made my own background then i wanted it to have the word "LEET" move up and down, it runs but where its ment to say LEET theres some strange white boxes

Code:
#include "mygba.h"

#include "gfx/bg.raw.c"
#include "gfx/bg.pal.c"
#include "gfx/L.raw.c"
#include "gfx/L.pal.c"
#include "gfx/E.raw.c"
#include "gfx/E.pal.c"
#include "gfx/T.raw.c"
#include "gfx/T.pal.c"


MULTIBOOT

u16 L_x=80;
u16 E_x=96;
u16 E2_x=112;
u16 T_x=128;
u16 L_y=14;
u16 E_y=10;
u16 E2_y=6;
u16 T_y=2;
u16 L_go=0;
u16 E_go=0;
u16 E2_go=0;
u16 T_go=0;
u8 L;
u8 E;
u8 E2;
u8 T;

void Draw()
{
    ham_SetObjY(L,L_y);
    ham_SetObjY(E,E_y);
    ham_SetObjY(E2,E2_y);
    ham_SetObjY(T,T_y);
    ham_SetObjX(L,L_x);
    ham_SetObjX(E,E_x);
    ham_SetObjX(E2,E2_x);
    ham_SetObjX(T,T_x);
}

void MoveLetters()
{
    if(L_go==0)
    {
        L_y=L_y+3;
        if(L_y>56){L_go=1;}
    }
    if(L_go==1)
    {
        L_y=L_y-3;
        if(L_y<2){L_go=0;}
    }
    if(E_go==0)
    {
        E_y=E_y+3;
        if(E_y>56){E_go=1;}
    }
    if(E_go==1)
    {
        E_y=E_y-3;
        if(E_y<2){E_go=0;}
    }   
    if(E2_go==0)
    {
        E2_y=E2_y+3;
        if(E2_y>56){E2_go=1;}
    }
    if(E2_go==1)
    {
        E2_y=E2_y-3;
        if(E2_y<2){E2_go=0;}
    }
    if(T_go==0)
    {
        T_y=T_y+3;
        if(T_y>56){T_go=1;}
    }
    if(T_go==1)
    {
        T_y=T_y-3;
        if(T_y<2){T_go=0;}
    }
}   

void vblFunc()
{
    Draw();
    MoveLetters();
}

int main()
{
    ham_Init();
    ham_SetBgMode(4);
    ham_LoadBGPal((void*)bg_Palette,256);
    ham_LoadBitmap((void*)bg_Bitmap);
    ham_FlipBGBuffer();
   
    ham_LoadObjPal(&L_Palette,256);
   L = ham_CreateObj((void*)&L_Bitmap[4*8*0],0,1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,L_x,L_y);
   
    ham_LoadObjPal(&E_Palette,256);
   E = ham_CreateObj((void*)&E_Bitmap[4*8*0],0,1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,E_x,E_y);
   
    ham_LoadObjPal(&E_Palette,256);
   E2 = ham_CreateObj((void*)&E_Bitmap[4*8*0],0,1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,E2_x,E2_y);
   
    ham_LoadObjPal(&T_Palette,256);
   T = ham_CreateObj((void*)&T_Bitmap[4*8*0],0,1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,T_x,T_y);
   
    ham_CopyObjToOAM();
    ham_StartIntHandler(INT_TYPE_VBL,&vblFunc);
    while(1) {}
}


Sorry if the code is a bit hard to read, and the sprites for the letters are 24X32

#81046 - NeoZF - Wed Apr 26, 2006 10:07 pm

anyone?, ive tried loads of things, still dont work, it just comes out distorted

EDIT:
i think ive finaly found out whats wrong, the part for the sprite, anyone know how to fix it?