Sign in to follow this  

Unity [.net] Need Help With Tilemap

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

Has anyone here made a game that uses Direct3D to display a 2D tilemap in C#? I am having a real hell of a time drawing a single tile correctly. My textures keep coming out slightly distorted. I posted a detailed explanation of my problem in the DX forum. Anyways, my code looks solid so I'm beginning to suspect either driver problems or .Net bug. I've Googled around and can't find any tilemaps implemented in a .Net language to look at. This is such a pain. Doing a tilemap with GDI+ was super easy, but too slow. Thus my need for D3D. If I can't get this to work I may need to fall back on DirectDraw (yuck).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
what were you thinking about!!>!?!?!!?!?!?! DUDE Check out the D3DXSprite interface!!!! your code is solid but one function can do what all of ur code is doing!!! but 3x's better

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
sry in ur case , C#, look under the Direct3D namespace for the Sprite class i found it in the dx managed doc

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
DONT YOU DARE USE DirectDraw!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
P.S. Reason: dont ask stupid questions, ill pwn you

Share this post


Link to post
Share on other sites
Whateva. I'll use 12 deprecated APIs which constitute hate crimes. Whateva I do what I wan!

On the DX sprite interface:

I hear it's slow and have no interest in sinking time into it and later determining that it is, indeed, slow. What I'm doing is pretty simple and did not require much time at all to get running. It also makes panning and zooming and rotation trivial. Dunno if the sprite interface does that. Dun care.

Share this post


Link to post
Share on other sites
EITHER use the textured vertex buffer:


CustomVertex.PositionTextured[] verts = new CustomVertex.PositionTextured[4];
verts[ 0 ] = new CustomVertex.PositionTextured( x,y,0.0f, 0.0f, 0.0f );
verts[ 1 ] = new CustomVertex.PositionTextured( x,y,0.0f, 0.0f, 1.0f );
verts[ 2 ] = new CustomVertex.PositionTextured( x,y,0.0f, 1.0f, 1.0f );
verts[ 3 ] = new CustomVertex.PositionTextured( x,y,0.0f, 1.0f, 0.0f );



Use a triangle fan to render it.
The last two arguments are how to display the texture

The texture has these coordinates
0.0f,0.0f ------ 0.0f,1.0f
| /|
| / |
| / |
|/ |
1.0f,0.0f ------ 1.0f,1.0f

So just assign the vertices to the proper texture coordinate and the texture will render coorectly.

OR use sprites.
Just create a sprite and load a texture with a color key and then render it.

Sprite spr = new Sprite(device);
Texture tex = TextureLoader.FromFile(device, "texture.bmp", 0, 0, 0, Usage.Dynamic, Format.Unknown, Pool.Default, Filter.None, Filter.None, Color.FromArgb(255,255,0,0).ToArgb());


Share this post


Link to post
Share on other sites

This topic is 4560 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.

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