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.

2D All the way! / Ok. Im lost. 2D Map Editor Help?

Author
Message
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 21st Jun 2011 01:00
I cant even tell you how many attempts ive made at creating a decent Map editor(Tile based, that is...). Ive tried my hardest to code one on my own, thats just not gonna happen lol. SO, i finally took the time out to read that sticky, 2d Principles Db/Db Pro Part I, and found that he did touch on it a bit. only, he never really finished explaining his code, and i wanted to code it myself....Does anyone know of a tutorial on the forum that explains a way to build a map editor for tile based games? Thank you.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jun 2011 14:45 Edited at: 22nd Jun 2011 14:54
DD! Haven't seen you for a while

What exactly are you having problems with? Maybe I can help if you post some code of what you already have?

I've made a 2D tile editor before, so I'm going to post some tips. Do you have DBC or DBP? I remember you using DBP for that TDS project, so...

This code is all off the top of my head, may contain errors.


1) First thing I do is think about what the tiles are going to do. For example, some might be walls, so you'll need to define wall tiles to have collision. You might have sticky walls, so you will need to define if they are sticky or not. You might have water tiles, so you have to define that the player moves slower on water tiles etc.

I keep it all in a UDT:



2) Right, now that that's out of the way, next thing I do is write the editor. First of all, the background:



Next, load up all tiles. Here it's important that you have an "empty" tile as well, here loaded as "air.bmp".



great! Now on to the main loop!



3) saving your map. This part shouldn't be all too hard, all I do is write all of the data stored in the Tile() array to a file. Now I'm not sure if save array also saves the UDTs, so I'm going to be safe and write my own little saving section:



And that's the basics of a tile editor. I know I didn't explain how to set things like grip, speed, collision etc. and the reason is because I'm running out of time But I'm sure it shouldn't be too hard to do.

Another tip I have is to have default settings for the tiles. So for example, dirt has a default grip of 0.9, water has a default slip of 0.5 etc. So be sure to set every tile you place to their default values.

Cheers!

TheComet

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 22nd Jun 2011 22:48
Comet! Hello!!!!!!! Omg its been a while. And this map editor is for the TDS, I havent given up. Just reworking it. You got any projects in the works?(Cant see ur sig, if thats got a link. Proxy,Remember? lol... )

Dude, you are simply a life saver. This is exactly the type of explaination I needed! I think im well on the right track! Thank you......But ummmmmmm i just cant understand what you meant by a wall being sticky? You mean like for sliding collision?

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jun 2011 23:56
Quote: "But ummmmmmm i just cant understand what you meant by a wall being sticky? You mean like for sliding collision?"


Ah lol, no, I meant just like in... sticky Nothing to do with code or anything, I meant that the wall might have slime on it and thus it's sticky.

Yeah, I'm working on a Super Smash Bros. style of game, been developing it for almost 2 years now It's really advancing forward, check it out here if you're interested : http://forum.thegamecreators.com/?m=forum_view&t=162266&b=8 Proxy, I know what you mean

Well glad I could offer you some help, let me know if you need any additional explanation

TheComet

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 23rd Jun 2011 01:26
Okay! I remember Mega Mash Mothers! I'll test for ya . Im gonna ask a question first, then head over Collision.. Lol, how does one handle collision in game? Sliding?(I know this is big. Sorry. )

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jun 2011 11:13 Edited at: 23rd Jun 2011 11:16
Collision... Let me see what I can come up with I think the easiest method here would be the "feel before move" method.

So somewhere in your code, you're going to have a section where you physically move your player. Something like this:



So instead of doing that, we are going to store these next coordinates where the player should end up in temporary variables:



OK, so now comes the part where we "feel" if there is a wall in the way or not:



That would be basic collision checking. Now if you implement that, you will notice that whenever a player walks into a wall, the player will be unable to slide across the wall. It will just get stuck until you move away from the wall. To have sliding, you will have to do 2 more checks.

Instead of just resetting the new positions to the old positions, we will check what would happen if the player were to stay on one of the axises (is that plural for axis?). Something like this:



Full section:



Hope that clears some things up, again, this is all coded off the top of my head and I don't know if it will work

Also, I just noticed something about the post I made first here... For performance issues it would be better to change this:



Into this, and put it BEFORE your main loop:



Then when you place a tile, update the tile with the appropriate image.

Cheers!

TheComet

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 23rd Jun 2011 20:36
Dude, I cant thank you enough at all!!!! Omg, this is so simple but i couldnt come up with it. Thanks!

rem draw all tiles
for x=0 to 63
for y=0 to 63
Sprite Tile(x,y).index,x*tilewidth,y*tileheight,Tile(x,y).index
next y
next x

I do belive that would cause a weird ehhhhh experiance. Maybe this would be better? Again, thank you so much.



Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 24th Jun 2011 02:26
I think I have a nice little start to my editor! I cant seem to work out indexing tile data though. I have a routine that cuts them out from a big pic, however whats making me scratch my head is indexing them, to be used by the editor and to render in game......Ive thought about usng an array, but i dont think that'll work....

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 24th Jun 2011 07:04
K, also, if you want, im uploading my progress so far. Here goes! Enjoy. source is in the zip as well. Thanks so much!

Attachments

Login to view attachments
seppgirty
FPSC Developer
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location: pittsburgh, pa.
Posted: 25th Jun 2011 18:39
WOW guys, this is some great info for newbe's like me. KEEP POSTING maybe throw some ISO view code in here.

gamer, lover, filmmaker
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Jun 2011 18:50
Do you mind if I do a lot of changes to your source code?

TheComet

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Jun 2011 20:18
OK, here is a revamp of your project:



Move the mouse to the edges of the screen to scroll around, left click places a block, right click removes a block, holding space lets you choose a block.

You need to try and keep a good structure in your code, the version you gave me was a little bit messy (please no offense ). If you keep a good and clear structure, you will be able to get much further with programming. I'm not saying I'm the gold standard though, just find a way to keep yourself organized

If you have any questions, I'll be happy to help you out

TheComet

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 29th Jun 2011 01:06
Oh wow, i just like Lost a couple days of sleep over coding this,but now my editor works in [almost] full!(Every thing you mentioned above, and it has a set collision mode and multiple layers/tilesets!) Sorry my code is quite messy.......bad habit i'll have to stop


Ill take a look at ur version, comet, THANKS!!!!! you are a hero.

Login to post a reply

Server time is: 2024-03-29 11:15:32
Your offset time is: 2024-03-29 11:15:32