Jump to content
  • Advertisement
Sign in to follow this  
zlatko_bre_1985

Sprite class

This topic is 4842 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

i have been rewriting my sprite class to use vertex buffer and texture.Previously i used D3DXCreateSprite Function to create a sprite. 1)Is it worth to implement sprite class on my own? 2)Does ID3DSprite has support for multitexture sprite , rotation,scaling and so on ? I decided to not use a FVF format but instead to use Vertex Declaration. I have D3DVERTEXELEMENT9 populated, called CreateVertexDeclaration(),SetVertexDeclaration() and now what? 3)How to create a vertex buffer with LPDIRECT3DVERTEXDECLARATION9? Any resources? 4)If VB is creating via CreateVertexBuffer() is a D3DUSAGE_AUTOGENMIPMAP and POOL_MANAGED good creation flags?

Share this post


Link to post
Share on other sites
Advertisement
Regarding your first question, I'd say that it's worth while to create your own sprite class.
As to your 4th question, myself I use D3DPOOL_DEFAULT.

Share this post


Link to post
Share on other sites
1) Depends on what you need. ID3DXSprite is very fast, it got a nice performance boost in Summer 2004 SDK update.

2) Rotation, scaling etc. yes, but no multitexturing.

3) First, you create array of D3DVERTEXELEMENT9 structures. Make sure that last element in array is D3DDECL_END. Then you use IDirect3DDevice9::CreateVertexDeclaration() to create the declaration. Check out SDK docs for more details.

4)You cannot use D3DUSAGE_AUTOGENMIPMAP with vertex buffers, only with textures. D3DPOOL_MANAGED keeps a copy of your buffer in system memory, where it can be restored if device is lost. I have always used D3DPOOL_DEFAULT when creating vertex buffers.

I hope this helps. [smile]

Share this post


Link to post
Share on other sites
It is indeed very worth while creating your own sprite class. This is because, dependant on the genre of the game, a sprite would contain many different attributes. For instance, a sprite in an RPG would have say MP, HP, and DF etc... whereas a sprite in a racing game would have Velocity and TireSize etc...

So what you could do is to do both. Inherit from D3DXSprite and add in your own sprite attributes. That way you can benefit from not having to reinvent the wheel, as in sprite potions etc..., from D3DX’s D3DXSprite optimizations and you will be able to fully customize the sprite.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think rpg_code_master ought to rethink his designs. There is no good design reason a sprite should have attribute like MP, HP or DF. A higher level game entity should (for example, an NPC) and it might have a sprite attached to it. Has-A, not Is-A.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!