2Din3D Sample Code Needed

Started by
2 comments, last by JSDaniel 21 years, 3 months ago
I''ve read everything I can on how to do 2D in DirectX3D (including Focus on 2D in DirectX3D) and I can''t find any example of how to do a tile sheet. You know the image that has a set of animtion tiles that are then drawn. Can anyone out ther help? Jim Daniel
Jim Daniel
Advertisement
Hello there,

I''m afraid I don''t have any sample code to help you out with this, but I can give you a few pointers on this.

Let''s suppose you already have a "tile sheet" bitmap as you put it. You''ll first need to create a texture out of it (the D3DXCreateTextureFromFile function is the simplest way IMHO).

Second, I suppose you''ll need some kind of reference to know what portions of the tile sheet you''ll use for each frame (unless all tiles are of the same size). The minimal information you''ll need for each tile is its rectangle position (x1,y1,x2,y2).

Third, to display the actual frames, I suggest using the ID3DXSprite interface, which is the simplest way to do 2d with Direct3D IMHO. The Draw function contains a lot of interesting parameters, but the one in interest here is the "CONST RECT *pSrcRect" one, which is a pointer to the rectangle position to be used in the texture for drawing.

That''s basically how you would do 2d sprite animations. Of course it''s really just a few basic pointers, you''ll need to look up on the DirectX SDK to get all the actual details, but this should be enough to get you started.

Good luck!
- Veldhar Windrider
Hi!
I know what you mean... I always learn best by first reading and then looking at some code trying to figure out what it could be. Well, anyway, while looking at gamedev.net''s isometric programming articles I found this one:

http://www.gamedev.net/reference/articles/article935.asp

The article is about 2d in 3d (and luckily for you he explains how to set up an isometric view )

With the article comes some source code at the bottom of the site...

Hope that helps out ~
Thanks for the ideas. I''ll look into the 3D sprite objects asap. I''ve already ready the article suggested and I didn''t see much to help me with my problem on how to do tiles.

Jim Daniel
Jim Daniel

This topic is closed to new replies.

Advertisement