Jump to content
  • Advertisement


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


Sprites in DirectX 8.1 -- Any suggestions?

This topic is 5724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, How do you handle sprites in DirectX 8.1? Do you just draw boxes with textures and change the texture based on what animation they''re doing? Or what are some good ways to do sprites in DirectX 8.1? I''m at a loss for how it would work.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I use a vertex buffer filled with four vertices rendered as a triangle strip for each sprite.

I am wondering if it would be better to do this:
make an array of four vertices and use DrawPrimitiveUP.

but I heard vertex buffers are better.

but what about for sprites when only four vertices are being rendered.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

float x, y, z;
DWORD color;
float u, v;


class CSprite


~CSprite() { Destroy(); }

HRESULT Create(LPDIRECT3DDEVICE8 pDevice, const int nWidth, const int nHeight, const int NumFrames = 1, const DWORD dwColor = 0xFFFFFFFF);
VOID Destroy();

HRESULT LoadFrame(int nFrame, LPCTSTR pSrcFile, DWORD dwColorKey = 0);

VOID SetDimensions(const int nWidth, const int nHeight);

VOID SetPosition(int x, int y);

HRESULT Draw(int x, int y);
VOID UpdateAnimation();

VOID SetVisibility(BOOL bVisible)
m_bVisible = bVisible;

VOID SetAnimationSpeed(int nAnimSpeed)
m_bAnimating = TRUE;
m_nAnimSpeed = nAnimSpeed;

VOID SetCurrentFrame(int nFrame);

friend BOOL SpriteCollision(CSprite* Sprite1, CSprite* Sprite2);


HRESULT CreateVertexBuffer();
HRESULT UpdateVertices();




int m_X, m_Y;

int m_nWidth;
int m_nHeight;

DWORD m_dwColor;

int m_NumFrames;

BOOL m_bVisible;

int m_nCurrentFrame;

BOOL m_bAnimating;
int m_nAnimSpeed;

BOOL m_bOneTimeAnim;


BOOL SpriteCollision(CSprite* Sprite1, CSprite* Sprite2);

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!