View previous topic :: View next topic |
Author |
Message |
Mexicouger

Joined: 01 May 2010 Posts: 129
|
Posted: Sun Jul 04, 2010 3:26 am Post subject: Drawing an image? |
|
|
Where would I go and What do i do if I want to draw just a simple image on the screen depending on what weapon your holding(psp version)?
Thanks, I appreciate it! |
|
Back to top |
|
 |
Arkage
Joined: 19 Nov 2009 Posts: 27
|
Posted: Sun Jul 04, 2010 3:32 am Post subject: |
|
|
Looking in sbar.c it handles quakes status bar. |
|
Back to top |
|
 |
Mexicouger

Joined: 01 May 2010 Posts: 129
|
Posted: Sun Jul 04, 2010 3:42 am Post subject: |
|
|
Thanks. I will try. Do you supppose You know what Function is the best to work with?
EDIT: I have been browsing and this is what I have come up with..
Code: | if (kurok)
{
if (cl.items & IT_SHOTGUN)
{
Sbar_DrawPic (440, -40, icon_blaster);
}
if (cl.items & IT_RIC)
{
Sbar_DrawPic (440, -40, icon_ric);
}
else if (cl.items & IT_SNIPER)
{
Sbar_DrawPic (440, -40, icon_sniper);
}
} |
That is in sbar_draw. But It only goes with the first one,
Code: | if (cl.items & IT_SHOTGUN)
{
Sbar_DrawPic (440, -40, icon_blaster);
} |
|
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Sun Jul 04, 2010 5:51 am Post subject: |
|
|
Okay... this can be done quite easily. A note about sbar.c: the sbar is drawn to the bottom region of the screen. If you want to be able to draw images anywhere on the screen, you should call for example Draw_Pic instead of Sbar_DrawPic. Now...
In gl_screen.c, you can find this function:
Code: | /*
==============
SCR_DrawLoading
==============
*/
void SCR_DrawLoading (void)
{
qpic_t *pic;
if (!scr_drawloading)
return;
pic = Draw_CachePic ("gfx/loading.lmp");
Draw_Pic ( (vid.width - pic->width)/2,
(vid.height - 48 - pic->height)/2, pic);
} |
That's a pretty simple example of drawing an image. It can be boiled down to this:
Code: |
void SCR_DrawImage(int x, int y, const char *filename)
{
Draw_Pic(x, y, Draw_CachePic(filename));
} |
Note: Draw_CachePic is the function to load the image (if it has not been loaded already).
To draw an image anywhere on the screen. Note the image must be stored in a "lmp" file, which you can create in Adquedit or maybe Fimg. Your engine may support loading from TGAs though, I don't know. Also, note that there are two draw functions:
Draw_Pic // draw an image with no transparency
Draw_TransPic // palette index 255 will be made transparent
But this only applies to "lmp" images, not TGA. If you use TGA, you can just create an alpha channel to do that transparency/translucency.
Now you just need to know where to call the function to draw the picture. Well, the simplest place is right in SCR_UpdateScreen. Near the end you'll find this code:
Code: | }
else
{
if (crosshair.value)
Draw_Character (scr_vrect.x + scr_vrect.width/2, scr_vrect.y + scr_vrect.height/2, '+');
SCR_DrawRam ();
SCR_DrawNet ();
SCR_DrawTurtle ();
SCR_DrawPause ();
SCR_CheckDrawCenterString ();
Sbar_Draw ();
SCR_DrawConsole ();
M_Draw ();
} |
Well, you can draw stuff in between the call to Sbar_Draw and the call to SCR_DrawConsole, for example.
Preferably though, you would actually draw it from inside the Sbar_Draw function in sbar.c, since what you want to do should technically be part of the sbar system. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
Mexicouger

Joined: 01 May 2010 Posts: 129
|
Posted: Sun Jul 04, 2010 5:56 am Post subject: |
|
|
I have gotten them to draw on screen, But How do I get them to change depending on the current weapon is what I am asking? I had it 1 time(they weren't the right sprites though)
I just don't get how to call depending on the weapon. well I kinda do but any examples?
New code:
Code: | if (kurok)
{
if (cl.items & IT_SHOTGUN)
{
k = Draw_CachePic ("gfx/icon_blaster.lmp");
M_DrawPic ( (320-k->width)/2, 0, k );
}
else if (cl.items & IT_RIC)
{
c = Draw_CachePic ("gfx/icon_ric.lmp");
M_DrawPic ( (320-c->width)/2, 0, c );
}
else if (cl.items & IT_SNIPER)
{
r = Draw_CachePic ("gfx/icon_sniper.lmp");
M_DrawPic ( (320-r->width)/2, 0, r );
}
} |
Thanks for the help
EDIT:
I got this done before I read your post
http://www.moddb.com/games/primepsp1/images/new-hud
But See that little orange box? I want that to switch depending on your weapon.
EDIT AGAIN!!!
YAY! I fixed it! I just used
else if (cl.stats[STAT_ACTIVEWEAPON] == IT_LIGHTNING)
I am so happy! |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|