How are sprite/images used to associate with a character?

I hope this is the correct category… Anyways, usually when developing a game (small, larger, etc), how are the images associated with a certain character/class?

Like for example, a player chooses the hero type character and the image associated with that appears. How is this done in coding?

If anyone has any idea it’d be a big help!

Thanks

In general, it wouldn’t be more complicated than hooking a function to a button press event, and then load and display the sprite somewhere on the screen.

However, how that code would look like depends a lot on how the game engine works. It could look like this for example:

function onHeroButtonPressed()
{
    DrawingModule.ResetSprites();
    DrawingModule.AddSprite("hero_basicpose", 400, 120); //sprite ID, X coord, Y coord
    DrawingModule.RedrawScreen();
}

function onThiefButtonPressed()
{
    DrawingModule.ResetSprites();
    DrawingModule.AddSprite("thief_basicpose", 400, 120);
    DrawingModule.RedrawScreen();
}