Highlighting stuff on the screen
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
They would use a custom blitting function that can detect edges. If blitting a source pixel that is transparent but a neighbouring pixel in the source image is not transparent, then this pixel should be blitted as the highlight colour.
Steve 'Sly' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams
Tools Developer
Krome Studios
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
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement