How put interacitve objects on a map

Started by
9 comments, last by kingpinzs 18 years, 10 months ago
How do people put there interactive iteams on a map? I heard that link list can be used to put the tiles on the map. but I am not sure how that would work. and would you use the same way to put your units and npc's on the map also? Any ideas will be helpful thanks
Advertisement
any one know how?
Just like you said. Have a list of objects. The implementation depends on how you like it.

You could have a general class like cInteractive or cEntity or whatever, and have all objects that are interactive derrive from it. Then have only one manager like cInteractivity or cEntityMgr, that controls the array/vector/list.
You could also have a manager for all types of objects, like cItemMgr, cNPCMgr.
Heck! You could even make this not encapsulated in classes, but just in an array/vector/list with supporting functions.

This is a more game-datastructure related question, and there are 'general ways' to do it, but I think it's much more fun to think of your own ways and make it how you want it to be. That's what programming is about, creative coding!
well first I dont know how to use classes so that will not work.

second can any one show me how to use link list in a simple dos program?

and should I use just link list or is there a better way to do it?

Did a quick google, this should clarify linked-lists in C++

http://richardbowles.tripod.com/cpp/linklist/linklist.htm
You gotta learn about classes... how do you make a game without classes... espcially with NPCs and maps?

I use a class for my characters called Entity.
In this class it has a pointer to a list. The pointer holds animation sequences, which is basically just lists of pictures used in a sequence. You then use something called an iterator to move back and forth through the list.
So, for example, I have a function called CheckAnimTime(), which just checks to see how much time has passed in my game loop and if it is time it will get the next image in the list using my iterator.

The list is a pointer because it needs to be dynamic, which means you can add sequences on the go. So you say player1->AddList(BREATHING); and then booya, you got a list you can add images to that will be used for player1's breathing sequence. You can do that for DYING, WALKING, RUNNING, ICESKATING, etc.

I am a noob at animation, but it works for me.
well you can teach me how to do classes or I can use structs instead.

I have read the article on this site for link list and also the link that was in this post and servral others I found. I think I figured out what link list are just have not figured out how to make one.

as far as I can tell link list are like a array of types stored in memory and have pointers pointing to the data and you can add,remove or rearange the data in the link list useing the pointers

If I am wrong let me know.

So can some one show me how to add data into the link list and the read the link list?

Thanks for the help so far.
You have the basic idea. Yes, a list is just another data structure. A way to store data for later manipulation and retrieval. They are not exactly like arrays though. An array gives you random access to data stored in it. If you want item "x", you can just go to element "y" in the array. If you want item "x" in a list, you have to iterate through the list until you find the node that has "x" (unless you already have a pointer to the node).

Quote:So can some one show me how to add data into the link list and the read the link list?


A starting place...
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
so if arrays are random accses then why use link list that are not? why not just have arrays? is it because you can add or take away data better or what?

EDIT: also how could I load the data from a text file into the list?

[Edited by - kingpinzs on May 26, 2005 8:10:49 PM]
You can split wooden boards with a hammer right? So why would you ever use a saw? It's all about knowing which tool is right for the job. Yes, in many cases lists can grow, shrink and sort faster than arrays. But there are no hard and fast rules. As is often the case, the answer is "it depends". You just have to know when to use which and that only comes with study and experience. It can't be taught in a round of posts on a message board.

There are some general cases where people often choose one over the other. If you need to add or remove items from a structure constantly, it may be a good idea to use a list. For example, you may want to store the items to draw on the screen for the current frame. For this you may use a list. This is because you don't know from frame to frame how many items will be in that list (it can change a lot depending on where the user is looking or what state the game is in), and you don't necessarily need access to a particular item in the list (don't need random access), you just iterate through and draw them.
Conversely, if the number of items never changes, you might just use an array. For instance, if your game always has two players, you may just store two Player objects in an array with two elements. Then you can quickly perform actions on a player by indexing the appropriate element. Again, these are just examples, there are no rules to this. Just pick the structure that makes sense for the job.

[Edited by - CodeMunkie on May 26, 2005 9:23:19 PM]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.

This topic is closed to new replies.

Advertisement