Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / map editor hel

Author
Message
mcd2424
20
Years of Service
User Offline
Joined: 9th Dec 2003
Location:
Posted: 10th Dec 2003 00:18
I am trying to create a map editor. I have created the matrix but need to be able to select one or more tiles in the matrix with a mouse so I can apply textures or adjusts the tiles height. Does anybody have any ideas on how to do this? Below is the code I have so far.

thanks
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Dec 2003 10:48 Edited at: 10th Dec 2003 10:50
Yeah, it's really simple to get a ground moulding system in place. I'm not gonna give you the code because I could'nt be sure it would work as I don't have DBPro handy, but I'll explain it as best I can.

Firstly, we need to know what 2D coordinate has been clicked and has been edited. I like to standardise the mouse with complex GUI stuff, so store the mouse position:

MUSX=mousex()
MUSY=mousey()
MUSC=mouseclick()

Do this at the start of the loop.

Now, for each edit point or node of the matrix you need to ascertain it's screen location. This is straightforward, but you'll need a dummy object, just a hidden cube that you can throw about without affecting anything. You also need a global return variable for X and Y coordinates, so lets call them RETX and RETY, if your using DBC then you would have to use an array instead. Assuming object number 1000 is not taken, that can be the dummy object:

MAKE OBJECT CUBE 1000,1 : HIDE OBJECT 1000

Then, you can easily make a 3D to 2D screen converter.



So now you can quickly grab the screen coordinates of any point in space, including matrice nodes (Assuming height data is in array called MATHEIGHT# and selected node signified by SELX and SELZ):



The above code can be called in the main loop or in an editing mode - it simply draws all the nodes on screen and stores the node under the mouse in SELX and SELZ if the mouse is clicked.
You'll need to adjust the height array once the mouse is dragging the heights, something like:



The above code should be called after the node drawing routine. The routine UPDATEMATRIX should just set the heights from MATHEIGHT# and update the matrice.

For texturing, all you really need to do is store the tile numbers in an array and affect them in the same way. I like to put the matrix texture as a sprite onto the screen but scaled down - then make a little clicking thing for selecting textures, really easy to do, just remember that if your drawing boxes or lines over a sprite, you'd have to make it translucent with the alpha setting. You could draw the nodes in the middle of the tiles easily enough, it can be quite disorienting having to texture when your not 100% which tile out of 4 your affecting.


Van-B


I laugh in the face of fate!

Login to post a reply

Server time is: 2024-09-21 11:53:48
Your offset time is: 2024-09-21 11:53:48