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.

DarkBASIC Discussion / A Multiple Layer 2d Rpg Map...

Author
Message
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 2nd Oct 2009 02:50
Wracking my brain as to how..... i searched but to no aveil. Can anyone help me by writing some psuedo(i'd rather do the actual coding myself..) code as to how This could be done? I'm.....stuck. I need a kind soul to point me to the light.

Oh, this is my First "Job" ever for a client.
Yay. $$$.

-DD

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Oct 2009 03:14
By multi-layer, do you mean using multiple layers for creation or multiple layers for playing (i/e you can walk on and under certain terrains)

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 2nd Oct 2009 13:25 Edited at: 2nd Oct 2009 13:27
I mean Multi-layer for creation; as in...well, you can lay down say grass tiles for layer 1, then objects like flowers for 2, and like no walk areas for 3.(just an example....)

I'm actually quite scared at this project.
I'm gonna have to make a map editor(a first ever for me).
At this rate, The GDD is gonna be HUGE, and will probly span 12 pages.....!

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Oct 2009 21:08
You can check out what we were working on for DarkNOOBS a while back.

The Method I ended up liking the most was an array that stores which tile based on location (so for instance, MAP(Layer,X,Y)=TileNumber) where the tilenumber would correspond to an image number or a number on a tileset.

For the most effective saving, you will probably want it to create a new master tileset that has all USED tiles on it, then update your array with the new values and save them (perhaps together in a fileblock or something). Alternatively you could simply save the map along with some tile-based collision information, but that is up to you.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 3rd Oct 2009 02:26
Thats what i was hoping to avoid. i dont quite get what going on in the code, and i thus cant edit/salvage anything.

But, the suggestion about the array got me thinking a little...Any tips for the editor?

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 3rd Oct 2009 02:34
The basics of the editor is simple. load a tileset, and check for mouse position when you click paste the image on the bitmap and set the value in your array.

New Site! Check it out \/
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 3rd Oct 2009 02:37
I see..........

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 3rd Oct 2009 02:46
Hmm.... Just a thought, but maybe something like this for the map array:



And then you could store various numbers in each slot to mean different tiles. Maybe 0 could mean no tile, 1 could mean floor, 2 could mean wall, etc.

<-- Spell based team dueling game!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Oct 2009 02:52 Edited at: 3rd Oct 2009 02:55
It's just different numbers stored in an X/Y grid. Not really difficult. Lock the mouse to 32 pixel movements or similar. You will find it quite easy. There are a few ways. I prefer..

Dim Map(X,Y,Depth) Like Sixty said, or Dim Map(X,Z,Depth) for a 3D version.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 3rd Oct 2009 02:57
You are all saying the same thing
Quote: "
obese:
MAP(Layer,X,Y)=TileNumber"

Quote: "
Sixty Squares:
DIM Map(NumberOfLayers,NumberofXTiles,NumberofYTiles)"

Quote: "Pincho Paxton:
Dim(X,Y,Depth)"


New Site! Check it out \/
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Oct 2009 03:06
Sorry...

Meant Dim Map(X,Y,Layer)

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 3rd Oct 2009 08:10
I was able to pull of an editor (didn't finish it all the way) that allowed the user to add and remove layers as necessary. One important thing though: Make sure you identify which tiles are on the active layer. Otherwise to remove a tile you might have to go through all the layers till you figure out which one it is on.

A quick way for calculating the tile that the mouse is over is just divide its position coordinates by the size of the tiles. So if they are 32x32, you just take MouseX()/32 to figure out which column it is in and MouseY()/32 to figure out which row.

Other things: You want it to be simple to pick up and use, but don't go so much for simplicity that you cut out functionality. If you have drop-down menus, make sure the most common things have buttons on toolbar type deal, that way the user doesn't always have to go into the menus and hunt for stuff.

Also, when developing, don't make my mistake and decide to add scrollbars later. It messes stuff up. At least write it in to accommodate them when you finally get to coding them.

If you want I can find my old editor so you can see how it ran, though I know the code is messy.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 3rd Oct 2009 09:05
I've done it Here with Dark Basic Pro, this current one uses a sprite that holds all the tiles, but at the beginning I was using separate image files that were the tiles, and I indeed stored everything in a Map(Layer, X, Y) = TileID Array, For defining the layer you should work on/delete tiles on I made a global CurLayer which defined the Layer aspect of the array, meaning you could switch between them dynamically and only edit the layer you're currently on.

So it can be done and it's not even really complicated at all... I'm not sure whether Dark Basic Classic supports some of the things I'm using but this is basically the code I use to render it on the screen(Not taking into account the offset code I use for scrolling maps, thus limiting it to 24*18 tiles)



Note that this is reverted code from my current one, as that uses sprites... But Dark Basic Classic doesn't. So this is assuming that every tile is loaded as a separate image, and that you're storing the image ID's in that Array.


EDP Map Editor[2D]
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 6th Oct 2009 09:43
There's alot of steps and dificulties in making a map editor and even in a simple 2d editor is no exception.

I have quite a bit of experience in this area and it is greatly effected by your choice of media and usage of it so you'll have to build around the media.

If you'll like some more help here I think I can answer some answers and show some examples but you'll have to be specific.
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 8th Oct 2009 02:29
Okay, the problem i'm having so far is.........STARTING. What should i worry about first? and yes, help would be appresiated.

Quote: "I have quite a bit of experience in this area and it is greatly effected by your choice of media and usage of it so you'll have to build around the media."


Yes, i'm preety sure of my tile set, i had/edited it slowly all of last month.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Oct 2009 05:59
I would say first start with just a basic grid and mouse check routine. then start with(if needed) the scrolling for the map. and then start taking that mouse check and setting values and editing bitmaps and loading/saving maps. i would say GUI would be last. this is the approach i would use

New Site! Check it out \/
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 8th Oct 2009 08:50
Quote: "Okay, the problem i'm having so far is.........STARTING"


You can start by coding a method of loading your tiles from your tileset. I'm not sure how you plan to load your tiles but the method I'm using right now is a Lazy Loader type of a deal. It'll only load tiles that I'm about to use that haven't been loaded yet.


How big is your tileset and how many tiles do you plan on using?
How is your method of cutting the tiles apart?
How is your method of displaying your tiles?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Oct 2009 08:51
First thing I would do is work out the architecture. Get the map arrays working and updating correctly (randomly populate the map with tiles or use the cli to change the array values)

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 9th Oct 2009 03:03
Quote: "You can start by coding a method of loading your tiles from your tileset. I'm not sure how you plan to load your tiles but the method I'm using right now is a Lazy Loader type of a deal. It'll only load tiles that I'm about to use that haven't been loaded yet."


....hmm.....yeah, i guess that makes sense.

Quote: "How big is your tileset and how many tiles do you plan on using?
How is your method of cutting the tiles apart?
How is your method of displaying your tiles?"


1. Havnt counted but i'm looking at roughly 80-90 tiles for the whole game. The tiles are 32x32.

2. The same as the player(32x32 also...) images; I cut them, then index them with arrays.

3. Currently not worked, I was thinking of something like Silvester said..........Might there be a better way you might know of?

Quote: "First thing I would do is work out the architecture. Get the map arrays working and updating correctly (randomly populate the map with tiles or use the cli to change the array values)"


I suppose thats a great suggestion too. Once I give my 'Display Tiles' Function/Gosub a go.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 10th Oct 2009 20:50
Here are two ways to use tiles.
1: Save each tile as a different file and load them individualy.
Pros - Loading time is quicker.
Con - Takes up way more disk space than it should.

2: Save all tiles into one image and cut them up during run-time.
Pros - Use smaller disk space.
Con - Slower loading time.

If you use no.2 (I use no.2) you may have notice that when you attempt to load all your

tiles at one time, there will be a noticable lag or pause. I didn't like that so I got it to

only load a single tile I needed at one time.


The following code is a sample of what I personaly use for a Tileset of 10x?? tiles. Meaning 10 tiles

across and as many downwards as you want.



My tileset is attached. Dont mind all the black empty spaces, it's just currently undecided and I plan to fill it in maybe.

Attachments

Login to view attachments
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 10th Oct 2009 21:25
Also as for a little hint on how to get a 32*32 grid...


Not sure wether that works in DBC or not, It was made with DBP. :/


EDP Map Editor[2D]
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Oct 2009 01:46
Quote: "
If you use no.2 (I use no.2) you may have notice that when you attempt to load all your

tiles at one time, there will be a noticable lag or pause. I didn't like that so I got it to

only load a single tile I needed at one time."


Actually i'd perfer this method, but is there a way to speed it up at all? My load time is already hitting 2 min 30 sec, Just loading the Male and female Chars,hair and clothes. I should be posting a baby WIP on this board(truly a new born...) so that you guys can get a feel of what i'm pulling for....

Quote: "Also as for a little hint on how to get a 32*32 grid..."


That small bit of code actually got me thinking, i'll play around with that,thx. I may be on to somthin' big here(For me, others proboly know this stuff already.)....

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Oct 2009 20:31
You might be able to speed things up using memblocks instead of GET IMAGE, but its difficult to know.

Or you could break up the images into multiple ones, that way you only load what you need so you don't have to wait as long.

Hmmmm just thought of this one, though there are probably many bad reasons against it. What if you use the GET IMAGE command when the image is USED the first time, rather than when it is loaded? That way it isn't really grabbing that many images at once, but one or two the first time it is used.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 11th Oct 2009 20:45 Edited at: 11th Oct 2009 20:52
Quote: "but is there a way to speed it up at all? My load time is already hitting 2 min 30 sec, Just loading the Male and female Chars,hair and clothes."


This is why you dont load them all in one time. Lazy loading will only load images that you're actually about to use. The codes on my last post is what I use for my Terrain tiles, but the same method can be used on character and object images as well.

That bit of code Silvester showed is what I use too and it's very important as you'll use that all around for just about everything dealing with the screen.

If you ever decide to put your grid in a window positioned somewhere else on the map other than (0,0) you can do something like this.


If you want to draw it back on the screen at that coordinate.



Quote: "You might be able to speed things up using memblocks instead of GET IMAGE, but its difficult to know."

That's true, memblocks are much faster and much more difficult. This method is great except for the compatibility issues between computers/users. You have to be able to code it in both 16 and 32 bit modes and be able to detect it as not everybody uses the same settings.
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 19th Oct 2009 04:49
Okay just for a first, i hate memblocks and are totally racist against them..........no i just dont want to use them.

Sorry I've been away a bit, actually got pretty into my code before Db Crashed

Okay, so ive got a little idea of how to write(well, now REwrite) the whole loading thing. I'm guessing the best way is to index the images in maybe a text file(which will be read in), then, as needed, load the corresponding image, cut out the tile/sprite,and so on............Did i get it right?

As for the "maps", i'm still quite,quite lost, but i am going to start working on teh editor. i'll perhaps figure out the specifics of the lazy indexing and drawing routines as i make my way through.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 19th Oct 2009 05:17
I dont understand, how did you manage to pick up a client to write a program for when you haven't even grasped the concept of something like this? No offense but what you're trying to do really isn't that difficult.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 19th Oct 2009 07:37
If you can explain in more detail what exactly you don't understand about the maps, perhaps we can be more specific in helping, rather than just spitball possible ideas.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 20th Oct 2009 03:34
Quote: "I dont understand, how did you manage to pick up a client to write a program for when you haven't even grasped the concept of something like this? No offense but what you're trying to do really isn't that difficult."


She's a Realitive, and dude........it was kinnda difficult for me if i made a post about it

And even with the no offence, I feel.....insulted.

Quote: "If you can explain in more detail what exactly you don't understand about the maps, perhaps we can be more specific in helping, rather than just spitball possible ideas."


Figureing and Figureing more and more, and getting the feel from the "spitball possible" ideas, i think i may have a kickstart, but i'll post if i run into anymore Klunckz.....

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )

Login to post a reply

Server time is: 2024-05-09 05:18:20
Your offset time is: 2024-05-09 05:18:20