• Advertisement

Archived

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

Got my Engine Woprkin..but how to i display units?

This topic is 5835 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've got my isometric engine working and it takes in and displays my map for me and i'm well pleased with that. (Doing this Project in VC++ 6 and DirectX8) But i've no idea how to get my main character up on the map. I dont know what format to make the animation as... the colour i should put the back ground(invisible transparent) as, how many bits of animation i should have for the main character(he can walk in 8 different directions, maybe two for each direction, left foot forward & right foot forward. How to load them in then, how the computer can tell which frame is which. What values need to be saved about my main character who will be moved about by clickin on a location on the map(with the mouse ;-p )and the character will then walk to there. Will need to hold the Characters x,y coordinate , destination x,y coordinate a flag if he is movin or not. Maybe some pointer to where all the graphics for this character are stored....just guessing about the graphics...thats really where i need all your help! If there is examples of code or graphics i'd appreciate it! B_Doyle1@yahoo.com_NO_Spam (leave out _NO_Spam) ;-D Thanks for taking the time to help Briam Edited by - Woody FX on February 24, 2002 10:41:41 AM

Share this post


Link to post
Share on other sites
Advertisement
There is no one way to do it. I suggest you write out everything you need. Then think about how to do them, and write that out too. At this point you should be able to actually code them.

Share this post


Link to post
Share on other sites
Yeah....but read what i asked....that is a good way to find what i need but not how to do it...

I''ve asked the question because i''m stuck at this point... not able to figure out the answer myself

Thanks Brian

Share this post


Link to post
Share on other sites
You could go and have a look at Nehe''s Zelda. This is a tiled based game. Only it''s written with OpenGL and not Directx but maybe you can learn how to do it.

Good luck

Share this post


Link to post
Share on other sites
I''ve got a grasp of DirectX....and i''m really running out of time
plus a lot of other stuff that i''ve got to study for college as exams are in 2 weeks....so no time to start in to some thing new like openGL

But thanks for your input
Brian

Share this post


Link to post
Share on other sites
Maybe you''d a have a structure/record/class for a frame of the characters animation.

- frame name
- binary graphic data
- whatever

Then maybe you''d have an array of these frames.

Maybe you''d know which frames make up a (e.g. walking) animation and on each refresh of the display you''d write the relevant one to the screen.

Maybe you''d also store the x,y location of the unit so that your display routine can calculate where to put the graphic.

Maybe.

Share this post


Link to post
Share on other sites
I want to tell you to: study, then code...

But I''ll give a little hint about the animation.
Draw your pictures (same width) and make a VERY "tall" image. Copy each frame in some logical order (S #1, S #2, SE #1 etc). Load the whole image in and here''s some code:

  

#define PIC_SIZE 64*128

#define S_1 0
#define S_2 PIC_SIZE
#define SE_1 (2*PIC_SIZE)
#define SE_2 (3*PIC_SIZE)
etc...

int direction,
frame;

char *pic = loadCrap("jox.blah");

if (walking) frame = (frame + 1) & 1;

if (turning) direction += angle;

drawImage(someX, someY, 64, 128, pic + frame + direction*2);



Just give the offset of the wanted picture and draw. No extra lookup-files or crappy stuff, everything''s in one file.

Share this post


Link to post
Share on other sites
Thanks Coelurus, nice code!

Can you elaborate a bit on what all the

#define S_1 0#define S_2 PIC_SIZE#define SE_1 etc....etc

is about


char *pic = loadCrap("jox.blah"); what is goin on here

you are saying load the file(graphics) but how does the program tell which is frame 1 and 2 etc

Thanks Brian

Share this post


Link to post
Share on other sites
Hmm, thought I removed the defines... Strange that there were no line breaks... Ah, never mind.

First, get into some image-program. Then draw all of your frames in different images. Then create a tall image and paste the old images right under each other. A long serie-strip, in the other direction.

About loadCrap(), or a better suited name, loadPic(). This just loads an image, like you have always loaded a .bmp or whatever. Nothing strange in this one.

Say we only have one picture for every direction of the figure, south, west, north and east in that particular order. If the player is walking to the south, we draw the picture from offset "picpointer+0". If the player walks to the left, we draw the west picture from "picpointer+picsize". And so on. Since the big image with all smaller pictures is stored in tall strip, a simple scanline-copying method of drawing the pictures will suffice.

Now, onto the animation. Say we have two frames per direction (_yuk!_). Then we store each group of frames for a special direction after eachother. If the player is walking south, we cycle through the first and second pictures, right? If the player walks to west, we draw picture #3-4! Get it?

I don''t see why or how the program needs to know this. If all characters in the game have a picture-list like the above (groups of frames stored under eachother), the same procedure can be used for all characters.

If you really need some code on this, tell me and I''ll try to hack something together.

Share this post


Link to post
Share on other sites
If you have something handy i wouold apprecate it...but dont go killin your self over it!

You are a star!

Doylo

Share this post


Link to post
Share on other sites
Don''t count on getting it very soon... I must fix my computer, got a job to do, then I''m going to a LAN during the weekend. But I''ll try write something together as quick as I can.

Share this post


Link to post
Share on other sites

  • Advertisement