Jump to content

  • Log In with Google      Sign In   
  • Create Account


Need advice with linked lists...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 habus   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 October 1999 - 02:11 PM

Hi!

For the little shooter I'm doing I want to have a linked list to hold
my objects and other for the images. But I have a doubt here, should I
use this schema - 2 linked list - or :
1 List for images
1 For objects that don't need to be validated - background tiles, explotions,
planets in the first plane,etc.. -
1 For objects to validate - spaceships, bullets, lives and so on - ..

I used the last one in a DOS side view game I did once but I'm not sure if
the first method will affect the performance - the second one does less
collition detection -. The first one allow me to deal with everything in just
one class and the map editor could be used for both..

What method do you use to hold your information - objetcs - and images?
Any advice?

Thanks in advance.


Sponsor:

#2 Zenroth   Members   -  Reputation: 127

Like
Likes
Like

Posted 29 October 1999 - 09:45 AM

Hmm not quite sure what your trying to do there. Why not just store the image with the object? Not quite sure what you are asking.
Personaly i just use a linked list for my objects and the objects have the images with them.
something Like this.

typedef struct Monster_{
int type;
directdraw suface buffer;
struct Monster_* next;
struct Monster_* prev;
} Monster;


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 29 October 1999 - 10:58 AM

If you are building all the lists a initialization time, I would use a structure that had pointers to your images and put them on a multi-directional linked list. That way you can cycle through the images for animation purposes.

typedef node {

nodePtr *left;
nodePtr *right;
image *imagePtr;

} nodePtr;

Of course, this is C syntax, and if you are using c++ or another language, then you would have to alter things accordingly.

I like using linked list for animation, but tend to be careful that I am not doing any allocation at runtime. It can really cause some problems. Using pointers will help you out. Especially if you are doing a shooter and want to cat animations onto other animaitons, etc. You can extend your animations or limit them depending on how deep you sycle the list and what other lists you insert or attach to the parent list.

Skott


#4 mason   Members   -  Reputation: 128

Like
Likes
Like

Posted 29 October 1999 - 11:23 AM

The way I've always done it was to have a list of entities *seperate* from their images, i.e.:

struct Monster {
pointer to direct draw surface
int curframe;
int hitpoints;
int attackstrength;
int movementspeed;
// whatever
}

By using a pointer to a surface instead of an actual surface, you gain 2 things:

1) Multiple instances of Monster can share the same direct draw surface, saving gfx card memory;

2) it's easy to have monsters with the same stats, but different appearances. This is the classic "red blob/green blob/blue blob" technique used by lots of old NES games (FF springs to mind).

Keep in mind that even though your images are outside the struct, each struct needs to know what frame of animation it's on... otherwise, all of your monsters will all have to be on the same frame at the same time, which doesn't look realistic.

Mason McCuskey
Spin Studios
www.spin-studios.com


#5 habus   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 October 1999 - 02:11 PM

Thanks for all your posts!

The way I'm doing it its to have a class for holding the foe info, something like this:

Class miFoe{
int iKind;
int iFrame,iMaxFrame;
int iHp, iSpeedx,iSpeedy,...
}

the var iKind allow me to search in the images lists to display the correct one..

With the technique used by mason, Do you search the right image every time you create a new object?? Is this faster than just looking for the image when you update the screen?..





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS