You can do it however way you want, within the confines of programming, math and your time. No, that doesn't tell you much, but let's just begin by saying that there's alot of ways good and bad, established and novel that could result in an apparent connection between a sprite and a character. Apparent, as in apparent to you, or anyone else playing.
1. Have hero sprites and heroes. Very specific programming, but straightforward too. Heroes can select a specific hero sprite, so that when you render heroes, you select the hero sprite from an index provided by the hero. (index into an array)
2. Have the heroes be able to link directly to a sprite, and the sprite can draw itself. (reference / pointer)
3. Have the heroes be able to draw themselves, creating a draw() member function. (draw() member function)
4. Have the heroes inherit drawing capabilities, which you override and implement, enabling them to draw themselves. (draw() inherited from Drawable class)
5. Same as #4, except you are running a script instead, allowing both you and your colleagues/team to manage many aspects from the outside using a simple text-editor.
and so on
It's not a complete list, but I tried to cover the most common ways.
Number #3 and #4 is very common.
A hero could have all the information needed both directly and indirectly, forming a decently well-encapsulated class.
The hero class itself contains information needed to identify specifics about the character.
Let's have Hero inherit from Drawable, telling us that this hero can in fact be drawn, on a screen. All it means is that you promise that your hero can be drawn on a screen.
That way we can have a custom hero class, say KnightHero which inherits the draw() call, and write his draw() function which has access to all KnightHeros information.
Now that draw() function needs to be implemented in such a way that the hero is represented on screen.
In your renderer, you can now add KnightHero to a list of candidates that can be drawn. Loop through that list and simply call draw().
That is the basic OOP ways, I believe.
A sprite is just an image, that you can place on screen. It can be super-small, or be the background itself. It could also be an animated character. As such, it is only a concept, and you must implement using programming somehow.
Edited by Kaptein, 27 April 2014 - 07:25 PM.