Archived

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

LordKaT

Health Meter

Recommended Posts

LordKaT    122
Hey all, Ive been working on this RPG for the longest of time, well, its only a hobby of mine anywho Anyways.. I came up with a kinda interesting idea.. see, my battle system is turn base, somewhat like final fantasy, except all the character stats/actions are placed in a circle for example, theres this colorful circle with actions spread around it (fight, defend, run, ect..), in the middle has the characters hp/mp, y''know that standard stuff.. my question is.. with DirectX 8.1, is it possible to get that circle to become a sort of health meter? Ie: as the character was hurt, more and more of the circle becomes transparent, sortta like a circular health meter Right now Im using the 2d techniques described in peter walshs book "the zen of direct3D game programming" Thanks for any advice! --LordKaT

Share this post


Link to post
Share on other sites
Fruny    1658
First don''t confuse combat system and user interface.

Ok, an answer (not DX-specific).
You can build an array of vertices defining your circle.
Add as the first point of the array the center of the circle.
Use that as a vertex array, rendering a number of vertices (proportional to the life of your character) as a closed polygon.

Since the center of the circle is among the vertices, the shape will look like a pie missing a wedge. To have a full circle, you have to choices : either duplicate the first vertex of the circle''s circumference as a last point (which may cause some rendering artifacts), or declare a special case when the character is at full health.

Share this post


Link to post
Share on other sites
Lonely    122
You could have a square poly, with a circle texture (with the triangular borders transparent)

Then as health decreased, you can just scale down the poly, and the circle will go with it.

You can also make the circle grey, and modify the color of the texture, so if the health is full the color is green or blue or whatever... and as health falls it fades to red, or black, or whatever

-Lonely

Share this post


Link to post
Share on other sites
Taharez    203
Hey

Just make a triangle fan centered on the character like so:

and remove / scale triangles as the health goes down. It would be cool with a similar mana bar around it too..
You'll have a bit of a problem with this if you're doing your game in all 3d, I couldn't really tell from your description, but I'm sure you'll manage.

Good luck with your project!

Edited by - Taharez on January 13, 2002 6:51:33 PM

Share this post


Link to post
Share on other sites
Mark Duffill    156
You could have a vert buffer with the complete ring shape in the above picture. Then if you order the triangles correctly you can reduce the circle to a smaller and smaller arc via passing a smaller number of primitives to the DrawPrimitve() function.

ie

DrawPrimitive( D3DPT_TRIANGLELIST , 0, 20 ); // full circle
DrawPrimitive( D3DPT_TRIANGLELIST , 0, 10 ); // half circle
DrawPrimitive( D3DPT_TRIANGLELIST , 0, 1 ); // Almost dead!

etc.

You can place it in world space like any ordinary object. If you want to change the colour you can modify the ambient/material colour, or change texture used on the object.

Share this post


Link to post
Share on other sites