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 / Handling Objects and ID's

Author
Message
LoneWolf155
13
Years of Service
User Offline
Joined: 28th Sep 2011
Location:
Posted: 25th Oct 2011 05:01
Hello

I have ran into a problem while programming my game. First of all, it is a 2D game in which I am using the Dark GDK. My problem lies with unique ID values for different images that are created in the program. I created a list that handles my objects (I remove and add as needed) but I'm not sure how to go about giving each object its own Dark GDK sprite ID (especially since I will eventually delete each object).

Here is an example of my list to get you an idea of what I'm working with:


Just so it is known, this isn't exactly how I have my code set up but you should get the idea of what I'm working with. Anyway, as you can see I currently have every sprite set with the ID of 25 which results in only one laser being on screen at once.

How should I manage the sprite ID's along with my list of objects?
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 25th Oct 2011 13:41 Edited at: 25th Oct 2011 13:46
You could use a Stack to manage and recycle IDs. I would also add a integer member to CLaser to cross-reference the Sprite ID.

Declaration


Initialization


Start Using ID


Stop Using ID


LoneWolf155
13
Years of Service
User Offline
Joined: 28th Sep 2011
Location:
Posted: 25th Oct 2011 23:14
Thanks!! That is an excellent idea!!
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 26th Oct 2011 03:53 Edited at: 26th Oct 2011 03:56
PS: The IndexManager class is dynamic, and will add new integer IDs if you go beyond the pre-defined MAXIMUM_INDICES.

Login to post a reply

Server time is: 2024-11-19 06:49:54
Your offset time is: 2024-11-19 06:49:54