Sign in to follow this  
FrozenSnake

Using DirectX9 (Tiles) with C++

Recommended Posts

First of all I have checked this http://www.gamedev.net/reference/list.asp?categoryid=44 But the ones that are about DirectX seems only to be using DirectDraw. I wonder if anyone know any articles, tutorials or books that teaches the reader how to create their own tileengine. I want to create (at first) a single player game that uses tiles. But as you might understand I do not find anything that is up to date that teach the reader to do this. I had help to make a similar thing in OpenGL but the coder doesn't know DirectX and I have no clue how to do this in DirectX. The type to tilebased game I want to do is similar to my opengl version. But I want to use DX9 with D3D. Here is a screenshot of the OpenGL version: http://data.fuskbugg.se/skalman01/testRender.jpg I checked the book "Advanced 2D Game Development" but it's index didn't show anything about "tile". I was going to buy the book but change my mind now. Anyone that can help me find what I am looking for? Hope this thread describe what I am looking for.

Share this post


Link to post
Share on other sites
How do you draw in OpenGL?
It should be possible to do it the same way in D3D9, just that you need to keep your vertices in an array, since you can't do immediate mode like glVertex3f(). Apart from that there's nothing special about a tile-engine, try the normal tutorials for D3D9 and it should be easy to draw quads as tiles. You can also use the sprite interface, but I would learn the basics first, it's basically the same thing but can be easier when drawing 2D sprites.
Tutorials and Samples for Direct3D 9
ID3DXSprite

Share this post


Link to post
Share on other sites
Thanks for the reply. I ain't sure but I think this is what you meant.
void Render::texture(unsigned int x, unsigned int y, unsigned int id)
{
glBindTexture(GL_TEXTURE_2D, id);
x = x + 32 - twidth[id];
y = y + 32 - theight[id];

glBegin(GL_QUADS);
glTexCoord2f(0 , 0 );
glVertex2f (x , y );
glTexCoord2f(0 , 1 );
glVertex2f (x , y + theight[id]);
glTexCoord2f(1 , 1 );
glVertex2f (x + twidth[id], y + theight[id]);
glTexCoord2f(1 , 0 );
glVertex2f (x + twidth[id], y );
glEnd();
}


I will read the stuff you linked, thanks for the reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this