Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


units storage

This topic is 5686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m still developping my isometric graphic engine and i have a new problem. I''m using D3D 8.1 so i can get rid of drawing order thanks to the Z buffer. So, in order to make the render fonction as simple as possible, i want my ground tiles to have a linked list of elements (units, buildings...). With this solution i just have to look into those lists when i parse the ground tiles to draw. So i no more need to parse all the layers'' array. So where''s the big deal? Well a unit can move (mm quite logic), and this is the ia engine that deals with the position changes. So i have to update the lists whenever a unit moove. But a unit(the class that is updated by pathfinfing) doesn''t know how to move from a list to another.. I can''t figure out a way to make the update as simple as possible so that''s my i''m here I hope i''m clear enought but my english becomes bad after a full coding night =)

Share this post

Link to post
Share on other sites
I went the same way a while back. Now I use linked lists for static objects, and then a different list of objects for those that can move about (critters, platforms, etc.)

You can also use offsets for your objects, so that it ''belongs'' to the tile at x,y but can move from x-10,y-10 to x+10, y+10. This does cause some situations where it''s not optimised for the view culling because you have to draw all tiles in a 10-tile border width around the visible screen.

The nice thing about using a seperate list for mobile objects is that you can also split up your movement code so that you don''t have to inspect each object to see if it can move or not.

Learning to fly is easy, but as a tortoise, the landings are really rough.

Share this post

Link to post
Share on other sites
I would recommend doing both. Have a global linked list of moving units, and have a duplicate pointer on the tile. The ''next'' pointer of the tile one should be ignored, it''s not a linked list but a pointer to the unit in the global list.

This would allow you to have the best of both worlds, searching the tile for drawing and the global list for unit processing operations.

You might want to have just one linked list on the tile of all units (moving or static too). In that case have two ''next'' pointers. One for next in the global list and one for next on the tile. This can give headaches when it comes to freeing the memory but can work. I did it once... but found it over complicated for my task and on day 2 removed the lot.

Cornutopia Games
Bytten Independent Games Magazine

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!