HUD, GUI , 2d Images on screen ;]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

HUD, GUI , 2d Images on screen ;]

Post by dawasw »

:lol: As a n00b, i'm screaming for help!!

First, someone have any suggestions, or a little advice how make a little bar with health status?...

Second: Can someone give my some training code, how to load 2d images, simple on the screen, and they have to be sticking to the camera (they couldn't be "far away and unseen" on the map, i hope u understand me, i want load something all the time visible), also some good tutorial about positioning, how to position, crosshair or hud images etc. (i want to make some hud images, i mean bar of the hud will be rectangle i think, but next to this bar there eill be 4 small images, making it nicer)

I use this

Code: Select all


IGUIImage* img = env->addImage(rect<int>(10,10,98,41));

    img->setImage(driver->getTexture("base/gui/irrlichtlogoaligned.jpg"))

***And now, at the end there is:***

env->drawAll();

Well it works properly, image appear, but only when watching on the sky i still use this Irrlicht/media 20kdm2 map, and how to make it visible all the time on screen??
[/code]
2camjohn
Posts: 6
Joined: Wed Aug 04, 2004 1:15 pm

Post by 2camjohn »

I have just done a similar thing and my Image appears on the screen fine.

It is not overwritten.




Make sure that

Code: Select all

env->drawAll();
Is inside the main

while(device->run())

loop.

I hope this helps.
Space Construction Game

Texturers, Story Writers and ideas people needed.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

Well everything works properly, i have resolved this problem a bit earlier, but thx, now i am confused with making workable hud :?
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

GUI Builder

Post by Midnight »

keep your eye's peeled for the Advanced GUI Builder I'm producing in the near future..

just need to add a few more things and fix a bug here and there and it'll be ready to rock n roll.
xhrit
Posts: 140
Joined: Mon Jun 14, 2004 8:54 am
Location: earth
Contact:

...

Post by xhrit »

Here is a 10 unit health bar that turns different colours as well as becomes shorter as health drops. It may not be perfect or work right. (I ripped it out ov my game && it only changes colour there)

//draw health
int dColor, dMax, d; //init the vars
d = objects[player.nSelectedShip].nDefense; // this is current health
dMax = objects[player.nSelectedShip].proto.nMaxDefense; //Max health
if (d< (dMax/2) ){dColor = 0;} //What colour is the bar (I have only coded blue, yellow & red)
else if (d>= (dMax/2) && d < dMax){dColor = 1;} // ""
else if (d == dMax){dColor = 2;} //""

// now we loop over our 10 units
for (int i; i<10; i++)
{
if (d< (dMax/i) ) // draw only if PC has this health
{
driver->draw2DImage( m_tex_interface, core::position2d<s32>(4, 4+(i*16)),
core::rect<s32>(0+(16*dColor),240,16+(16*dColor), 256), 0, video::SColor(255,255,255,255), true);
}
}
Core2Duo E8400 3.0ghz - 2048mb DDR2 800 - geForce 9600 - Slackware12.1

Word-image-symbol programming limits, controls, and imprisons the individual.
Smash the control images, smash the control machine.
xhrit
Posts: 140
Joined: Mon Jun 14, 2004 8:54 am
Location: earth
Contact:

...

Post by xhrit »

thought ov an easier way to do it : just make a solid red 100px wide image; and always draw it on the screen in the same spot where you want it, but as the PC's health goes down, draw less ov the bar!

If PC_HEALTH is an int between 1& 100, you would do it like this :

N = PC_HEALTH;
driver->draw2DImage( m_tex_interface, core::position2d<s32>(10, 10),
core::rect<s32>(0,240,N, 256), 0, video::SColor(255,255,255,255), true);
Core2Duo E8400 3.0ghz - 2048mb DDR2 800 - geForce 9600 - Slackware12.1

Word-image-symbol programming limits, controls, and imprisons the individual.
Smash the control images, smash the control machine.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

rectdraw1 = HEALTH;
rectdraw2 = SHIELD;
driver->draw2DRectangle(video::SColor(255, 255, 0, 0),rectdraw1);
driver->draw2DRectangle(video::SColor(100, 0, 0, 255),rectdraw2);

blah blah blah...

you could do something like this also...requires no image and has an alpha value. would give you different colors in a rectangle shape.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

Thx i will try it.
Post Reply