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 / question about OOP

Author
Message
zao420
19
Years of Service
User Offline
Joined: 5th Aug 2003
Location: Canada
Posted: 14th Jul 2005 10:51
Hi guys.
I am using Ians framework witch uses objects instead of object numbers. I am working on my item system right now and ran into a little problem. does antone know if there is a way to loop though all the objects to see if one of the varibles are greater then 0. i could check one at a time to see but that seams like alot of code for a simple thing.

this is how my item class works




thats pretty mucg the basics of it.
any ideas

http://cavesoft.no-ip.com
WIP Version of my site. Usally it is offline.
http://dev-cavesoft.no-ip.com
Troll Fiddler
18
Years of Service
User Offline
Joined: 19th Jan 2005
Location: Mayo, Ireland
Posted: 14th Jul 2005 20:17
I assume all your items will be in an inventory array at some point? Just loop through the array of objects checking the values you want to check. Or is that not what you are asking?

I'm sick at the moment so not online much. Might take a while to respond if someone else doesn't first.

T.
IanM
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Jul 2005 02:36 Edited at: 15th Jul 2005 02:37
Are you trying to make the BasicItem class responsible for allocation/freeing of 3D objects?

I think you are going about that the wrong way: A 3D object is not an item - it is a representation of an item. You probably want a class something like this:



Your item class should not be responsible for objects - how would you deal with doors or walls? They are not 'items', but they may have a associated object. It looks like you may be trying to create a 'kitchen sink' class, that attempts to deal with everything.

Anyway, however you do it, you can just store pointers (preferably shared_ptr<> ) in a vector, deque or list, and iterate through them as you need to, pretty much as TF said.

If you look around a bit, you can see how I added a collision detection check between objects held in a list - you can do this in the same way.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2023-02-02 14:23:18
Your offset time is: 2023-02-02 14:23:18