Skip to main content
gamedev.net
🔒 Locked

problems linking sprite data

Started by DarkSaint 2 replies 550+ views
Original Post
DarkSaint
DarkSaint
I''m working on a 2d tile game and I''m having problems coming up with a way to link the right sprite to the right Monster/Npc/Player/Object. The way my sprite renderer works is it renders a sprite if the sprite''s map coordinates are on screen. I have an array of sprites structures that can be of any type of entity. What I want to know is how I should go about linking the correct sprite to the correct type of entity when each has it''s own structure with it''s own coordinates. Any help with this would be appreciated. Any help would be appreciated. Thanks.
hplus0603
hplus0603
Typically, when the entity gets created, it will allocate a sprite (sprite slot) from the sprite manager. Call this entity.sprite_id.

Each step, the entity will move itself around using its own coordinates, and then call into the sprite, saying "set the coordinates for sprite_id to x, y".

Then, at the end of the step, the renderer calls into the sprite manager and puts all the sprites on screen.
enum Bool { True, False, FileNotFound };
DarkSaint
DarkSaint
Thanks, I was thinking about doing it that way but wanted to see if there was any better way to do it. It seems that way will work fine though.
ZoomBoy
ZoomBoy
I usually attach the Sprite Location to the character

And I put the Sprite number as well

class char
{
int HitPoints;
char Name[30];
int currentSpriteID;
int posenumber;
};


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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.