So I'm working on my 3rd program, which contains (among other thing) my first attempt to make a sprite. It's basically a hexadecimal number that can be incremented or decremented by pressing Right or Left respectively. It mostly works properly, HOWEVER it doesn't show up until I press Left or Right to change the value.
Specifically, what I expect to happen is that when the screen changes to the sound test, the number shows a value of 1, and changes when you press Left or Right. But what really happens is that when the screen changes, the number does not show up until I press Left or Right.
Here is the segment of code I'm using for the sprite, for reference:
Is there something I'm missing here? Any help would be appreciated.
Specifically, what I expect to happen is that when the screen changes to the sound test, the number shows a value of 1, and changes when you press Left or Right. But what really happens is that when the screen changes, the number does not show up until I press Left or Right.
Here is the segment of code I'm using for the sprite, for reference:
Code:
pal_spr(palData);//set palette for sprites
sprXPosition=15;
sprYPosition=15;
ppu_waitnmi(); // wait 1 frame
oam_clear(); // just in case this is why the number doesn't appear at first
sprite=oam_spr(sprXPosition,sprYPosition,0x7C,0,sprite); // create sprite
while(1)
{
controllerInput=pad_trigger(0);
if(controllerInput&PAD_LEFT)
{
if(SoundNumber>0) --SoundNumber;
oam_clear(); // clear OAM so numbers do not overlap
sprite=oam_spr(sprXPosition,sprYPosition,0x7C+SoundNumber,0,sprite);
}
if(controllerInput&PAD_RIGHT)
{
if (SoundNumber<11) ++SoundNumber;
oam_clear(); // clear OAM so numbers do not overlap
sprite=oam_spr(sprXPosition,sprYPosition,0x7C+SoundNumber,0,sprite); // redraw number to reflect current sound ID
}
if(controllerInput&PAD_A) sfx_play(SoundNumber,0);
if(controllerInput&PAD_B) break;
sprXPosition=15;
sprYPosition=15;
ppu_waitnmi(); // wait 1 frame
oam_clear(); // just in case this is why the number doesn't appear at first
sprite=oam_spr(sprXPosition,sprYPosition,0x7C,0,sprite); // create sprite
while(1)
{
controllerInput=pad_trigger(0);
if(controllerInput&PAD_LEFT)
{
if(SoundNumber>0) --SoundNumber;
oam_clear(); // clear OAM so numbers do not overlap
sprite=oam_spr(sprXPosition,sprYPosition,0x7C+SoundNumber,0,sprite);
}
if(controllerInput&PAD_RIGHT)
{
if (SoundNumber<11) ++SoundNumber;
oam_clear(); // clear OAM so numbers do not overlap
sprite=oam_spr(sprXPosition,sprYPosition,0x7C+SoundNumber,0,sprite); // redraw number to reflect current sound ID
}
if(controllerInput&PAD_A) sfx_play(SoundNumber,0);
if(controllerInput&PAD_B) break;
Is there something I'm missing here? Any help would be appreciated.