SETTING A GUN AIMER

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
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

SETTING A GUN AIMER

Post by killzone721 »

all of you know those aimers when u see them in fps games... the gun aimers. for people who don't know, i am talking about the cross thing from which you aim... hopefully u guys know what i mean now.

i know how to set it up, just set an image OF THE AIMER in the middle of the screen. the thing is how to make the background transparent

like in the case when u set up a billboard, there is function u use to set the backgorund of the billboard transparent, by setting the backgorund of the billboard to black which enables it to be transparent,

is there anything similar like to set the background color to black or any color of the aimer to make it transparent

THXS FOR ALL THE HELP :wink:
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

Hi,

just use a HUD (head up display) texture and do the following:

Code: Select all

// load the hud texture
hudTexture = driver->getTexture( "media/graphics/hud/hud.png" );
// color black will be transparent
driver->makeColorKeyTexture( hudTexture, video::SColor( 0, 0, 0, 0 ) );
And in your game loop just draw it (you have to define, where your cross is located in the texture):

Code: Select all

driver->draw2DImage( hudTexture, core::position2d<s32>( xCenter - 16, yCenter - 16 ), core::rect<s32>( 168, 99, 168 + 33, 99 + 33 ), 0, video::SColor( 255, 255, 255, 255 ), true ); 
Regards - Xaron
ry
Posts: 8
Joined: Mon Dec 12, 2005 4:15 am
Contact:

Post by ry »

If you have a look at the examples and look into the Collision one, under the Billboard section you will find the line

Code: Select all

bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
That makes the Billboard transparent and also with color of the aimer, and removing the black at the same time
I hope this has helped you
Ry
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

I don't know, why someone should use billboards for that (2d) purpose?

Regards - Xaron
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

Xaron i don't know how to DECLARED hud...

IF YOU DON'T KNOW WHAT IT MEAN BY DECLARING... DECLARING IS SIMILAR TO WHEN YOU MAKE A DEVICE SAYING Irrlichtdevice * device=0;

can you please tell me how to declare a hud though like

/*whatever*/ * hud = 0;
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

try this. (credit to the other posters for most of the code, im just putting it together mostly)

Code: Select all

ITexture* hudTexture = driver->getTexture("replace this with your crosshair (aimer)'s filename" );
// color black will be transparent
driver->makeColorKeyTexture( hudTexture, video::SColor( 0, 0, 0, 0 ) );
device->getGUIEnvironment()->addImage(hudTexture, position2d<s32>((device->getVideoDriver()->getScreenSize().Width - hudTexture->getOriginalSize().Width) / 2, (device->getVideoDriver()->getScreenSize().Height - hudTexture->getOriginalSize().Height) / 2));
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

AndyCR .............. THANKS A LOT :wink:

AND A LOT OF THANKS TO THE PEOPLE WHO CAME OUT WITH THIS IDEA

BUT

CREDIT GOES TO AndyCR CAUSE HE PUT THE CODE TOGETHER ... AND IT WORKS :wink:
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
Frodenius
Posts: 64
Joined: Sun Aug 29, 2004 11:24 am
Location: Germany/Frankfurt
Contact:

Post by Frodenius »

stop screaming. please.
worst programming style ever seen...
Post Reply