Sign in to follow this  
Hot_Tamalle

Level Editor

Recommended Posts

Hi, I need some help to create my level editor. I've initialized Directx in a picture Box. I've made a toolbar with tile,brick and wall buttons(with images). Now i want to click a button on the toolbar and then click anywhere on the picuteBox to paste the corresponding image just like MSpaint(replacing colors with pictures). I don't know how to do this. Please advise. Some part of my code is below: private bool InitializeGraphics() { PresentParameters presp = new PresentParameters(); presp.SwapEffect = SwapEffect.Discard; presp.Windowed = true; try { m_device = new Device( 0, DeviceType.Hardware, this.pictureBox2, CreateFlags.SoftwareVertexProcessing, presp ); return true; } catch ( DirectXException ) { return false; } } private void RenderFrame() { m_device.Clear( ClearFlags.Target, Color.Black, 1.0f, 0 ); m_device.BeginScene(); m_device.EndScene(); m_device.Present(); }

Share this post


Link to post
Share on other sites
One thing you could do is store the level (if it's tile based) in an array. When you click on one of the tiles, figure out which tile it is (fairly easy to do if you're using an ortho matrix) and change that tiles value in the array to whatever (ie: 0 for tile, 1 for brick etc).

When you render, change the texture to whatever the tile is, or even better store all the tile textures in one big texture and just use the uv coordinates of the tiles (saves changing textures all the time).

Works well for my map editor anyway.

Share this post


Link to post
Share on other sites
If I understand your post right, you could register the click, divide it by your tile size, put into that part of a string[,] array with characters representing the level.

You could then reload this string array into the picturebox to get the updated image.

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