Page 1 of 1

Need help for a hud

Posted: Mon Jun 25, 2007 4:56 pm
by Aënahel
Hello ! :D I'm working on a First Person Shooter, and I want to add a hud (like stats, current weapon, ammo, radar, timer etc etc).

But I don't know how to manage :oops: . I placed a 2d weapon looking like counter strike on my screen, but I only know how to set pictures. I would like to be able to remove them, to move them etc...

My questions are :

1) How do you move/remove/resize images with Irrlicht ?
2) How do you create a timer ? ("00:57:96" format) which wou can start/stop, and how do you place it on your screen ?
3) How do you make a radar, showing a circular sector of the map, with green and red dots for the players ?
4) (if possible ^^') How to move other player with artificial intelligence ? :mrgreen:

And if you know how to do other cool things for my hud, just tell me please ^^.

Thanx,
Aen :)

Posted: Mon Jun 25, 2007 5:15 pm
by Dorth
1) see sprite tutorial
2a) get access to Irrlicht timer, b) I leave to you to convert to string in the format you want, c) see the gui example (or pre-render number/letters sprite then use the sprite tutorial)
3) For the background: read the sprite tutorial, for the line, search for Draw2DLine, for the glowing after effect, either search for rotating billboard/sprite on the forum or apply the texture on a quad then rotate it, for the dots, either use sprite, a Draw2DLine, or an equivalent for points, for finding where to draw, it all depends how your system works. I'll take a guess and assume you want it to display enemies based on their x, z position and only if they are within a certain range in y? in which case, go through the list of all potential allies and enemies, make a point at coordinate

vector3df NPCPos = NPC.getAbsolutePosition();
vector3df PlayPos = Player.getAbsolutePosition();

If (NPCPos.y - PlayPos.y > -Blah && NPCPos.y - PlayPos.y < Blah)
{
DrawPointSomehow((NPCPos.x - PlayPos.x) * Modifier_of_size_on_your_map_for_x, (NPCPos.z - PlayPos.z) * Modifier_of_size_on_your_map_for_z);
}
4) Search for Artificial Intelligence everywhere. That in itself is a topic extremely hard if you're looking for anything good.

Posted: Wed Jun 27, 2007 9:38 am
by dejai
This is a very intresting thred and I am also intreseted in this topic.

Posted: Wed Jun 27, 2007 9:17 pm
by LemonMan
I am interested in how the radar will turn out. :)

Posted: Thu Jun 28, 2007 1:15 pm
by Aënahel
Thanx a lot, Dorth :D

These are useful hints. But I was wondering how to access Irrlicht's timer, in order to get real time ? :?

Posted: Thu Jun 28, 2007 5:36 pm
by vitek
device->getTimer() will return you a pointer to the Irrlicht timer. It has methods for accessing the time as milliseconds since some arbitrary start time.

If you want to get the wall clock time, you should use one of the C library time functions. strftime() [or wcsftime()] can format the date/time as a string in pretty much any format you want. If you just want the time/date as data, you can use localtime().

Travis