Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / This function to get a free sprite number seems to be returning numbers that are in use

Author
Message
Marth Koopa
16
Years of Service
User Offline
Joined: 23rd Apr 2008
Location:
Posted: 12th Oct 2009 02:27


I call this function when I want to assign a sprite number that is not in use to one of my sprites (example, boss[Uberdude].spriteNum = getfreeSN(), I figured this would be a good way to manage sprites.

Some times it's returning a sprite number that is currently being used, making more than 1 sprite have the same number, which results in the last dbSprite command that used the shared sprite number being the one that shows up.

I can't figure out what it could be doing wrong. It should be starting at 11 every time it is called, then increasing it every time it finds out that sprite number is in use, then returning the value when it finds that it is not being used.

Is this a DGDK(7.4a) problem, or am I missing something incredibly obvious that's causing the problem?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Oct 2009 06:26
I'm not sure what your problem is. It looks like it should work. Have you tried stepping through the function to look at your data in motion?

Maybe try

spritenumber = 11;
while (dbSpriteExist (spritenumber++) == 1);
return spritenumber;

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 12th Oct 2009 13:50
Try this, Ive never really tested this so i cant make any guarantees.(In fact I didn't write this code)

Pseudo Code


if(You.AddCode.toPost)TGC.Users.CanHelp = true;
else return NoCodeMessage;

Login to post a reply

Server time is: 2024-11-20 13:40:29
Your offset time is: 2024-11-20 13:40:29