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 / ID Management Class

Author
Message
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 09:53 Edited at: 23rd Jun 2008 09:59
I found IDs very tiresome if you're not using an OOP library or something. I know, this is a simple and easy thing to do, but I also understand there are some people like me a week ago. I know, I haven't progressed a whole lot, but to me, it is a lot.



It's incomplete right now, but it works. I'll add more stuff soon. If you use this all the time, you won't have to worry about finding an open ID.

Updates:


Please don't flame me for this, I'm just trying to help newbies.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 09:59
am i wrong if i say that this looks like a good place for static members?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:00
I don't really know what static is for. Google time, or can you explain?

If you can do any models for FW, reply to the FleetWars thread.

Click here!
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:04
i heard that a static member of a class is the same for all instances...

but seeing as this class will only have once instance, it may be unneeded.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:07
show me how you would use this brilliant class
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:13 Edited at: 23rd Jun 2008 10:15
Simple:



If you can do any models for FW, reply to the FleetWars thread.

Click here!
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:16


yeah?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:17
I suppose that would work. Did you try?

If you can do any models for FW, reply to the FleetWars thread.

Click here!
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:19
Hmm, I'll revise a bit. Hold on.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:20
i probably mixed up the parameters. wouldnt be good for your program if you did it a lot though. your images and such would be reloaded, and there would be a lot of unused ones. i'd suggest a test to see if they need to be reloaded. unless you have a better way of doing it.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:22
I wouldn't load them like you did, I'd load the image before the loop.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 10:23
I keep getting a corrupted stack error...

If you can do any models for FW, reply to the FleetWars thread.

Click here!
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:25
yeah...

my game has a loop to make all of the sprites in a currently loading area.. to use this class i might have to put some more thought into how i'd work it.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 23rd Jun 2008 10:26 Edited at: 23rd Jun 2008 10:26
Quote: "I keep getting a corrupted stack error..."


show us the code
RancidRat
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 23rd Jun 2008 13:18 Edited at: 23rd Jun 2008 13:24
I also hate having to keep track of IDs....

I use a functions like GetFreeObject(int start),



the "int start" is the place from where it starts looking for a free ID.

so now I just declare it like:

int MonsterObject = GetFreeObject(100);
or I'll have a general range from which it can look for places:
int MonsterObject = GetFreeObject(FreeRange);

so for the rest of my code I just refer to MonsterObject
or I make a struct and it will be like Monster[1].object
it works great for making intance objects for bullets and so on.

I also have GetFreeImage and GetFreeSprite
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 23rd Jun 2008 16:39
Here you go much more efficient.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Jun 2008 17:07
Why the

bool foundObject = false;

?

You never use it.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
RancidRat
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 23rd Jun 2008 18:18
Thanks Mahoney

uuh yeah, suppose I dont need the foundObject thing to stop the loop then hey....

man I love learning this stuff...I just gotta learn how to use the right indentation, i always loved having everything in a straight line.

PS - sorry for hijacking the forum
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Jun 2008 18:31
Indentation can sometimes be a pain to implement. But, IMO, it helps to know what's under the control of whatelse.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 23rd Jun 2008 18:42
You can control indentation using the Tools/Options menu item. The relevant option is under Text Editor / C/C++ / Tabs. It is Indenting. (Smart is the default.)
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Jun 2008 18:47
True. Better than trying to do it yourself. But in some instances it forces me out of my preferred style.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 23rd Jun 2008 18:56
It always does that to me! I had it set right in VC 6.0, but...I just fix it manually now. It uses straight K & R formatting, which I do not like at all. I should probably work it out, but....
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jun 2008 19:36
I always indent myself, I find it easy to do it as I go. But, yeah, I came from Lua, where I learned from people who indented the C++ style, so it's all good to me.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 24th Jun 2008 01:37
Quote: "Why the

bool foundObject = false;

?

You never use it."


Correct. My mistake. Forgot to backspace the code.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 24th Jun 2008 09:06
the id system in my game is a bit touchy, i'm afraid i'll have to avoid something like this.

Login to post a reply

Server time is: 2024-09-30 01:22:29
Your offset time is: 2024-09-30 01:22:29