Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I've been having some problems with a function I implemented. Its saying " Argument type is not compatible with formal parameter" whenever I use CheckRange. I'm stumped, I don't know what's causing it. It may have something to do with me not using pointers correctly, I don't know. Razz

The function:

Code:
void CheckRange(int x, bool* WithinScreen, bool* WithinGun)
{
    if (x+225>=0 && x<=320)
    {
        *WithinScreen=true;
    }else{
        *WithinScreen=false;
    }
    if (x+225>=188 && x<=131)
    {
        *WithinGun=true;
    }else{
        *WithinGun=false;
    }
}

The part where it gives me an error:

Code:

        if (kTurn & kb_Left)
        {
            CheckRange(Zombie.x, Zombie.WithinScreen, Zombie.WithinGun);
            if (ShowFiring)
                --ShowFiring;
            if (CanShoot)
                --CanShoot;
            if (Zombie.WithinScreen)
            {
                gfx_FillRectangle(Zombie.x,30,225,210);
            }
            if (Zombie.x>=450)
            {
                Zombie.x=-225;
            }else{
                Zombie.x+=8;
            }
            CheckRange(Zombie.x, Zombie.WithinScreen, Zombie.WithinGun);
            if (Zombie.WithinScreen)
            {
                gfx_SetPalette(sprites_pal,sizeof(sprites_pal),0);
                gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                gfx_SetPalette(xlibcsprites_pal,sizeof(xlibcsprites_pal),0);
                for(i=0;i<2;i++)
                {
                    if (Zombie.ShowBloodSplatter[i])
                    {
                        gfx_TransparentSprite(BloodSplatter,Zombie.ShowBloodSplatter[i]+Zombie.x,100);
                    }
                }
                if (Zombie.WithinGun)
                {
                    if (ShowFiring)
                    {
                        gfx_TransparentSprite(SilencedPistolFiring,131,154);
                    }else{
                        gfx_TransparentSprite(SilencedPistol,131,174);
                    }
                }
            }
            update(Zombie.x, Player.ammo);
        }
        if (kTurn & kb_Right)
        {
            CheckRange(Zombie.x, Zombie.WithinScreen, Zombie.WithinGun);
            if (ShowFiring)
                --ShowFiring;
            if (CanShoot)
                --CanShoot;
            if (Zombie.WithinScreen)
            {
                gfx_FillRectangle(Zombie.x,30,225,210);
            }
            if (Zombie.x<=-225)
            {
                Zombie.x=450;
            }else{
                Zombie.x-=8;
            }
            CheckRange(Zombie.x, Zombie.WithinScreen, Zombie.WithinGun);
            if (Zombie.WithinScreen){
                gfx_SetPalette(sprites_pal,sizeof(sprites_pal),0);
                gfx_TransparentSprite(EnemySprite,Zombie.x,30);
                gfx_SetPalette(xlibcsprites_pal,sizeof(xlibcsprites_pal),0);
                for(i=0;i<2;i++){
                    if (Zombie.ShowBloodSplatter[i])
                    {
                        gfx_TransparentSprite(BloodSplatter,Zombie.ShowBloodSplatter[i]+Zombie.x,100);
                    }
                }
                if (Zombie.WithinGun){
                    if (ShowFiring)
                    {
                        gfx_TransparentSprite(SilencedPistolFiring,131,154);
                    }else{
                        gfx_TransparentSprite(SilencedPistol,131,174);
                    }
                }
            }
            update(Zombie.x, Player.ammo);
        }
The second and third arguments are specified as bool *, but you're passing (what I assume is) bool. Using invocations like the following should work:

Code:
CheckRange(Zombie.x, &Zombie.WithinScreen, &Zombie.WithinGun);
Also rethink the structure of your code... That's quite a bit of duplication you have there Wink Why are you setting the palette so many times?
Runer112 wrote:

Code:
CheckRange(Zombie.x, &Zombie.WithinScreen, &Zombie.WithinGun);

Thanks, Runer! Smile It works now!

Yeah, all the palette stuff comes from me thinking that since I use 2 palettes, I need to initialize each one before I display the sprite. Laughing I thought it was causing my program to freeze, but turns out it I decremented in a for loop when I meant to increment. This made an infinite for loop. Whoops. Razz
I am working on a sprite rn for you
The palette is a global entity applied by the LCD driver upon each refresh, not by rendering code upon each drawing call. Setting the palette should generally be a one-time thing done at the start of your program, with all graphics sharing that palette.

Setting the palette per drawing call does not do what you think it does. Whatever was the last palette set when the LCD refresh occurs will be applied to the entire screen.

If you convert all of your sprite data in a single convpng group, this will create a global palette shared by all sprites in the group.


Update!
School is finally over for me, and I survived my finals. Smile I'm starting to work on this again, and I've gotten shooting done (sort of). There's still a lot of graphical stuff I have to fix.
Could you do a mini-map like a circle to show enemies/your looking direction? I think it would give players a sense of direction.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement