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.

Newcomers DBPro Corner / Looking after your objects

Author
Message
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 22nd Apr 2003 08:05
Heyas ^^ Im kinda new to db (had dbp for a while, just never got around to using it >.>) although not to programming. Been programming for a few years, but only 2d games and apps, so bare with me ^_^

My question is about objects. Whats the best way to keep track of them? When you make your object and you give it an id, its one thing to hardcode alot of it but most of the time you need a dynamic solution. Example, at the moment i'm working on converting one of my old 2d games to 3d style (a simple tank shoot-em up multiplayer, everyone gets a tank and everyone has to shoot each other XD). Now I can happily load say the tank base and the tank turret and manipulate it about - I know they are objects 1 and 2. But it starts getting iffy with the shooting.
I modeled a quick shell in milkshape, exported an X file and loaded it as a mesh in dbp. Whenever the player fires it creates an object from the mesh, the object number is the value of NextBullet ect ect. To keep track of them I made an array of type Bullet (with the properties of Life, Alive and ObjectID). This is very.. well... messy :/ Even my code isnt working properly anyway because i randomly get Object Already-Exists errors. But this is just a simple tank shell.. I made an array of 99 set aside just for these shells. Things are gonna get really troublesome if I say attach a mini gun turret to the site of me tank which fires off 100 bullets a second, im gonna need a huge array to keep track of all those! And then what happens when a new player joins the game? (it is multiplayer based) - im gonna need a whole new set of duplicate arrays to keep track of everything.. and lets say its a full 16 player game *faints* - Now I just *know* im not thinking about this right. Probably because im just not used to 3d programming like this.. but theres my question

Whats the best way to keep track of objects?
How do you ensure that you dont start assigning objects duplicate ids?

Any tips here would be great ^^ There has to be an easier way of doing things
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Apr 2003 10:07
[ re bullets ]

bloodlocust wrote this for me ages ago but made it public so its ok to share.

its a bullet tutorial with extended remarks in his own wit.








[ re object management ]

There are a few ways to manage this.

The easiest way I have found is to encapsulate the 3d media integer or number into a variable thats inside your objects instancing.

so how ever u create a series of creatures whether its hardcoded,via a loop,inside an array,inside a type,inside a typed array will depend on how your code will flow on in construction.


I have found typed arrays to be the easiest way of managing groups of objects.

The NUM variable will always handle the 3d medias number so there is only change required and thats at its declaration.


An easier way to try to explain is if u set the varaible

Monster1 = 140

and used this reference throughout your code when ever the 3d media location was asked for then u only need to change the variable number and it will affect all representations of this varaible.

now thats a bit sloppy so to work around it we declare a typed array

imagine a type thats similar to a class.

in this instance we create one bugbear


managing the code this way saves a tonne of array usage.

cleaning up is a breeze also

Monster(2).NUM would be a 2nd monsters 3d media location if u created more than one monster

Monster(1).NAME would equal his name in a string variable







I spaced object groups by 100 in my game so If i need to create more than 100 of each object Ill have to simply change the NUM locations to suit.

I hope that helps, it always pays off to have your media list in a notepad next to you.

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Apr 2003 10:10
small typo
Monster(1).NAME would equal monster 1's name in a string variable

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Apr 2003 10:18
You can expand on this to suit a more realworld requirement as well

imagine a type with these declarated variables but dont stop here



Login to post a reply

Server time is: 2024-09-20 06:53:58
Your offset time is: 2024-09-20 06:53:58