Homebrew Sprite Animation bug

JDandy

Well-Known Member
Member
Joined
Sep 22, 2008
Messages
299
Trophies
0
Age
34
XP
84
Country
Netherlands
Your source code would be more helpful.
What are you using? PAlib?
If so, do you have the palette set properly? etc etc.

I don't think anyone can help you by looking at an .nds file
 

sleight

Well-Known Member
OP
Newcomer
Joined
Nov 23, 2008
Messages
73
Trophies
0
XP
63
Country
Gambia, The
JDandy said:
Your source code would be more helpful.
What are you using? PAlib?
If so, do you have the palette set properly? etc etc.

I don't think anyone can help you by looking at an .nds file

guess you're right ,but I was in hurry and it's not that much code..
..k here it is:

CODE#include
#include "gfx/all_gfx.c"
#include "gfx/all_gfx.h"
#include "loosey.h"


void newgame();

int main(int argc, char ** argv)
{
ÂÂÂÂÂÂÂÂPA_Init();
ÂÂÂÂÂÂÂÂPA_InitVBL();
ÂÂÂÂÂÂÂÂPA_InitSound();
ÂÂÂÂÂÂÂÂPA_InitText(0,0);
ÂÂÂÂÂÂÂÂPA_InitText(1,0);
ÂÂÂÂÂÂÂÂPA_LoadTiledBg(0,2,title_bottom);
ÂÂÂÂÂÂÂÂPA_LoadTiledBg(1, 3, title_top);
ÂÂÂÂÂÂÂÂPA_LoadSpritePal(0,0,(void*)title_Pal);
ÂÂÂÂÂÂÂÂPA_CreateSprite(0, 1,(void*)title_load_Sprite, OBJ_SIZE_64X32, 1, 0, 166, 90);
ÂÂÂÂÂÂÂÂPA_CreateSprite(0, 0,(void*)title_newgame_Sprite,OBJ_SIZE_64X32,1,0, 32, 90);
ÂÂÂÂÂÂÂÂPA_PlaySimpleSound(0, loosey);
ÂÂÂÂÂÂÂÂwhile (1)
ÂÂÂÂÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (PA_SpriteTouched(0)) newgame();

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_WaitForVBL();
ÂÂÂÂÂÂÂÂ}

ÂÂÂÂÂÂÂÂreturn 0;
}

void newgame()
{

ÂÂÂÂÂÂÂÂ//PA_DeleteSprite (0,1);
ÂÂÂÂÂÂÂÂPA_DeleteSprite (0,0);
ÂÂÂÂÂÂÂÂPA_EasyBgLoad(0,2,luminecrossing);
ÂÂÂÂÂÂÂÂPA_EasyBgLoad(1, 3,clouds1);
ÂÂÂÂÂÂÂÂPA_InitParallaxX(1,0,0,0,128);
ÂÂÂÂÂÂÂÂs32 scrollx = 150;
ÂÂÂÂÂÂÂÂs32 scrolly = 40;
ÂÂÂÂÂÂÂÂs32 scroll = 0;
ÂÂÂÂÂÂÂÂs32 x=100;
ÂÂÂÂÂÂÂÂs32 y=30;
ÂÂÂÂÂÂÂÂPA_LoadSpritePal(0,1,(void*)rin1_Pal);
ÂÂÂÂÂÂÂÂPA_CreateSprite(0, 2,(void*)rin_sprites1_Sprite, OBJ_SIZE_64X64,1, 1, 150, 64);


ÂÂÂÂÂÂÂÂwhile(1)ÂÂÂÂÂÂÂÂ {
ÂÂÂÂif(Pad.Newpress.Up) PA_StartSpriteAnim(0, 3, 4, 5, 6);
ÂÂÂÂif(Pad.Newpress.Down) PA_StartSpriteAnim(0, 6, 7, 8, 6);
ÂÂÂÂif(Pad.Newpress.Right) {
ÂÂÂÂÂÂÂÂPA_StartSpriteAnim(0, 2, 4, 7, 6);
ÂÂÂÂÂÂÂÂPA_SetSpriteHflip(0, 2, 1);
ÂÂÂÂ}
ÂÂÂÂif(Pad.Newpress.Left) {
ÂÂÂÂÂÂÂÂPA_StartSpriteAnim(0, 2, 4, 7, 6);
ÂÂÂÂÂÂÂÂPA_SetSpriteHflip(0, 2, 0);
ÂÂÂÂ}

ÂÂÂÂif(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_SpriteAnimPause(0, 2, 1);
ÂÂÂÂy += Pad.Held.Down - Pad.Held.Up;
ÂÂÂÂx += Pad.Held.Right - Pad.Held.Left;
ÂÂÂÂPA_SetSpriteXY(0, 2, x, y);

ÂÂÂÂPA_WaitForVBL();

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂscroll += 1;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_ParallaxScrollX(1, -scroll);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂscrollx += (Pad.Held.Right - Pad.Held.Left)*4;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂscrolly += (Pad.Held.Down - Pad.Held.Up)*4;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_EasyBgScrollXY(0,2,scrollx,scrolly);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_WaitForVBL();
ÂÂÂÂÂÂÂÂ}

ÂÂÂÂÂÂÂÂreturn 0;};


I guess the palette is ok and sprite seems to be loaded correctly too... (i think so because i tried with another sprite first before designin my own and it worked fine)
 

JDandy

Well-Known Member
Member
Joined
Sep 22, 2008
Messages
299
Trophies
0
Age
34
XP
84
Country
Netherlands
Ok, having played it and taken a look at your code...

//PA_DeleteSprite (0,1); is commented out by the // (like you said), so it's normal that that Load sprite stays on screen.

There's this though:

if(Pad.Newpress.Up) PA_StartSpriteAnim(0, 3, 4, 5, 6);
if(Pad.Newpress.Down) PA_StartSpriteAnim(0, 6, 7, 8, 6);

I just took a look, and PA_StartSpriteAnim goes (screen, sprite, frame, frame, speed)
and your character sprite is number 2, so shouldn't it be;

if(Pad.Newpress.Up) PA_StartSpriteAnim(0, 2, 4, 5, 6);
if(Pad.Newpress.Down) PA_StartSpriteAnim(0, 2, 7, 8, 6);

?

I think that might be your solution; it only glitches the load sprite when walking up/down, after all.


Hope this solves it, it looks interesting!
Good luck.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: https://www.youtube.com/watch?v=76bIuU_g6A8