Archived

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

ZoomBoy

Highlighting stuff on the screen

Recommended Posts

In many games there are people and objects that are highlighted when the cursor is placed over them. The highlight usually comes in the exact shape of the object. Any Ideas on how that''s done? I would assume that they : expand the original sprite by a few pixels copy it to a separate surface change the pixels to the high-lighting colour(Green or red) paste the coloured sprite to the screen paste the original sprite to the screen on top of the coloured sprite ZoomBoy Developing a 2D RPG with skills, weapons, and adventure. See my character editor, old Hex-Tile editor, diary, 3D Art resources at Check out my web-site

Share this post


Link to post
Share on other sites
Or, use a different "hilighted" version of the sprite and switch when the mouse moves over the active object.

VERY simple example:

class CSprite
{
protected:
// methods goes here...

protected:
byte *m_current; // current pic to be rendered
byte *m_spriteActive; // outlined version
byte *m_spriteNorm; // "normal"...
int m_x;
int m_y;
int m_width;
int m_height;
};


bool CSprite::checkIntersect(int x, int y)
{
if ((x>m_x) && (x<(m_x+m_width)))
if ((y>m_y) && (x<(m_y+m_height)))
{
m_current = m_spriteActive;
return true;
}

m_current = m_spriteNorm;
return false;
}


Call checkIntersect with the cursors current x and y location and
always render which will point to a correct
(outlined or not) version of the spriteimage.

Regards

/Tooon


Share this post


Link to post
Share on other sites
That''s a good idea.
I''ve got a custom blitter for my diamond-tiles cutter(it takes square art, scans line after line(storing it into an array), and then transforms it into a diamond tile.

I''d just have to set the two previous pixels to Green when they encounter a non-transparent pixel. I''ll also need a flag set up to tell me when to transform from Green->sprite/sprite->Green when doing a scanline.

ZoomBoy
Developing a 2D RPG with skills, weapons, and adventure.
See my character editor, old Hex-Tile editor, diary, 3D Art resources at
Check out my web-site

Share this post


Link to post
Share on other sites