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

The best way to put units into a game?

This topic is 5728 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

Heya all. I have been busy coding an isometric engine for the last six months or so, i''ve coded tools to generate isometric tiles and import graphics into the engine. The engine itself has the graphics, map and user input sections working, and i want to add units to it now. I''ve had a look at the articles but i can''t seem to locate one that tells me a good way of putting units into an engine. Could someone perhaps point me to an article or offer some suggestions? The game is an arcade rpg similar to diablo, so i''m looking at putting a lot of units in. Their data structures shouldnt be more than about 15 items i think. Should i put the units in as objects which maintain themselves and check the map when they need to move? Do i put them into a unit manager which runs through arrays of unit data structures? Also, what is a good way of writing an interface between the units and map for pathfinding and collision detection? Thanks -ET

Share this post

Link to post
Share on other sites
A popular way of doing it is to have a world class, which contains is the map. This class will have some form of list(s) in it (vector/linked list, whatever you want to do) that stores the objects data. Depending on your game, you might want to have different lists for enemies, npc's, items etc, or you can just use one list to store all objects (provided you inherited eveything from a base class). The world class will have a draw method which will draw everything (by calling the draw methods for each object on the map). You can easily control and limit what objects you want to draw etc (ie depending on your position etc).

this is just a very basic overview, but i hope it gave you some ideas.

[edited by - Tylon on March 24, 2002 2:50:12 PM]

Share this post

Link to post
Share on other sites
Thanks, but thats a little too vague I know sort of what i'm trying to get, but theres a few details that i'm not sure how to get right... Let me get a bit more specific here.. coz i'm running into quite a few problems here...

At the moment i have a map class, it holds the map which is an array of whatever size, it has a camera object inside it which holds the current position of the viewport.

I then have a unit manager which connects to the map manager, so it can see the map and access it to find out what is where. Inside the unit manager i create the units. The units take care of their own movement and drawing procedures, but i'm having problems with visibility from within a unit. The unit doesnt know where it is on the map, and so the draw procedure needs external input. Now, i can solve this by connecting each unit to the map manager aswell and let the units query the map manager about various things, that seems like a bit of a long way around. So what i need to know is how to relate the units to the map properly. From which object do i calculate where the unit is on the map and if the unit is on the screen? I'm just getting myself confused here.


[edited by - Evil_Toaster on March 24, 2002 4:32:31 PM]

Share this post

Link to post
Share on other sites
You should put that post in The Iosmetric forum to get help from all the crazy iso people!!


Doin an isometric game my self.... but it''s more along the lines of X-com...........

Share this post

Link to post
Share on other sites
I would suggest searching the isometric forum for words such as "units". I know of about 3 such discussions there, and definately when concerned about unit size and tile sizes, etc.

Anyways, here is the short answer to your question:
(A)(best way) You can divide your map into "sectors" or "quads" so that when your camera can view any of these, you run through a vector or linked-list saved for that sector and draw the units in that list.

(B)(easy way?) simply keep your objects sorted by world position. Since you know the range of tiles you can draw by your camera, use this also to draw only objects within camera view as well. This will hurt you later though when you got thousands of objects to search though. Hence the above (a) suggestion helps to cull out unnecessary drawing.


[edited by - GalaxyQuest on March 25, 2002 6:12:20 PM]

Share this post

Link to post
Share on other sites

sorry for off topic posts...

rapso, and anyone who likes it

Question concerning TFTD and other old games:
On what kind of PC do you play it?
Your old 486 / P-133 or something?

My problem is, that TFTD and UFO are not playable
on newer computers, like my duron 700.

Has anyone found a *GOOD* slow-down program,
that isn''t so "jumpy" like many I tried out?
I suppose slow-down programs can work properly
in DOS only.

But all programs I found are crap.
Maybe I''ll have to try it myself, but if so many
programs of that kind don''t work, I suppose it''s not so

Share this post

Link to post
Share on other sites
I''ve codet one, but you know, it''s very simple, somthing like this:

void main()
int _delay=0xffff;
int _sleep=20;
for(int a=0;a<_delay;a++);

you''ve to experiment with the delay and sleep values.

sometimes it works pretty well,
but the best way to play it, is my little pentium60 server


Share this post

Link to post
Share on other sites
by the way, if you liked tftd, you will probably also like Incubation, which was freely downloadable from theunderdogs, but it seems to be gone now

I just some someone makes an online version of it someday ... i know theres LSN, but thats only the battles, i think the base management in geoscape etc was just as much part of the game

Share this post

Link to post
Share on other sites


I also nearly got a shock,
when I, as usual, typed in the url,
expecting to load the great site.
But what did I see instead?? Some f*cking uninteresting
whatever business page. DOHH!!

I thought, IDSA m/fs finally got ''em killed.
(hey, you m/fs, it''s ABANDONware, no f*cking buck will
be lost for any company !!!)


they only changed url,
just a minus character between the two words!

Share this post

Link to post
Share on other sites


rapso Member since: 10/25/2000 From: Germany

gruss zurück, unrasierter,
hab gelesen, du machst ''ne 2d-engine?

gib nicht mir die schuld, der verdammte uralt-braun
wird langsam stumpf, wie war das, man bekommt eine
vergütung für den alten, wenn man einen neuen braun kauft?
muss ich mir noch überlegen...

hhmm... where did you get that information??
I like playing some isometric games, but I''m not making a 2D engine.
Well, if I have time (rarely), I continue working
on my 3D engine, and some other stuff.
Well, I did a pretty simple 2D, some time ago...
Only suited for C and C red alert / warcraft like games.
I think baldur''s gate is "slighlty" better


weasalmongler Member since: 1/13/2002 From: United Kingdom
Posted - 29 March 2002 7:00:12 AM

Ich spreche keine Deutsch. Was ist das auf English, bitte?


Well, at least a bit

I greeted the other german fellow, and he asked me,
if I was programming a 2D engine. Nope.

the unshaven bastard

Share this post

Link to post
Share on other sites

uhh, didn''t watch this thread for a while,
are u still watching it?

I don''t have a hpage yet, but I''m going to put up a very simple one (when I will have the time...),
with some links to downloadable stuff...

just downloaded "selfhtml", didn''t do any www stuff before,
it''s f*cking boring to me...

Share this post

Link to post
Share on other sites