It is currently Mon Dec 18, 2017 10:56 am

All times are UTC + 9:30 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [CW2] Map editor
PostPosted: Thu Mar 26, 2009 12:29 am 
Offline
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
a MapEditor is another state so it extends CWState

but we can't reuse cw1 code... since it is very specific.
Code:
            //Roads
            if (ter.getIndex() == 3) {
                if (north != null) {
                    if (north.getIndex() == 3 || north.getIndex() == 4 || (north.getIndex() >= 9 && north.getIndex() <= 14) || north.getIndex() == 16) {
                        n = true;
                    }
                }

plugins can have different terrains with different Ids, so instead the map editor should have an algorithm that can connect adjacent tiles(if that is possible)
each terrain needs to know to what direction it can connect to.
a terrain can have a canConnectToAll(Direction) method and a canConnectToAtLeastOne(direction)

Terrains of the same type need to be connected:
same type: ie road, river, pipe == terrain type.
Each terrain has directions it can connect to: North, South, East, West No directions means it can't connect.
There can be a perfect match, and a best effort match.

horizontal road can connect to West, East
vertical road can connect to North, South
NorthEast Bend road can connect to North, East
....


ie Road (perfect match)
a horizontal road is put on 0,0 -> col, row
a horizontal road is put on 0,2
a horizontal road is put on 0,1

terrain on (0,0) (0,1) (0,2) should change to vertical road


adjTerrs = Get Terrains of the same terrain type around the clicked tile(0,0) , (0,2)
dirs = Get Directions of the same terrain type relative to the clicked tile(North, South)

Search for a perfect match:
for all terrains filter out the road types
for each road
if the dirs match the terrain directions we have a perfect match.


ie Road (best effort match)
a horizontal road is put on 0,0 -> col, row
a horizontal road is put on 0,1

terrain on (0,0) and (0,1) should change to vertical road


adjTerrs = Get Terrains of the same terrain type around the clicked tile(0,0)
dirs = Get Directions of the same terrain type relative to the clicked tile(North)

Search for a perfect match:
for all terrains filter out the road types
for each road
dirs don't match the terrain directions, no perfect match.

Search for a best effort match:
search for a road that can connect to at least 1 of the dirs
= 2 matches vertical road and northEast bend
grab the first

That would work for roads, rivers, pipes.

problems: coast, delta terrains are special, there are 4 bridges if the first bridge is always chosen then the last 3 can never be placed?
anybody got ideas about how to handle any problem above?


Last edited by stef569 on Fri Mar 27, 2009 7:54 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [CW2] Map editor
PostPosted: Thu Mar 26, 2009 2:30 am 
Offline
User avatar

Joined: Fri May 04, 2007 3:18 am
Posts: 520
Well, connectors have always been a problem. The other problem is we can't count on the pictureID's to be accurate. Tiles are probably gonna have to report what is in either direction of themselves, via Dijkstra or some other method of tracking Tiles. Then, depending on which direction is reporting, the computer can use the combinations of directions/ID to decide which image to draw. It's kinda tricky though.

For the bridges/roads.
-The suspension can be used for bridges that connect over sea.
-The regular can be used for bridges that connect over rivers.
Bridges are essentially road tiles that cover rivers and seas, but can't turn directions. (But they can turn directions in AWDoR.) IMO, just make them road connectors.

I'll give this more thought.

JSR...


Top
 Profile  
 
 Post subject: Re: [CW2] Map editor
PostPosted: Thu Mar 26, 2009 5:53 am 
Offline
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
Quote:
The other problem is we can't count on the pictureID's to be accurate.

If each terrain has an unique id(including horizontal, vertical) and the tilesheet is correct then that's not an issue.

Ok, so we can add canPlaceOverSea for a suspension
and
canPlaceOverRiver for a regular bridge.

good idea make bridges road types so they connect to roads. Placing a bridge has some extra logic too:
north and south == sea or
north ==sea and south == suspension or
south == sea and north == suspension
-> suspension
we can use the terrain height to determine if a terrain is a river(-1) or sea(-2)

cities are also of the road type...
that leaves delta and coasts


Top
 Profile  
 
 Post subject: Re: [CW2] Map editor
PostPosted: Mon Apr 20, 2009 10:11 pm 
Offline
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
Map maker is coming along nicely(terrains only):
Image
Only 1 thing remains the coasts misses a part :P

if coasts are part of the ocean then following reasoning explains why the part is missing:
A ocean terrain is placed when all 4 directions(N,E,S,W) are of the ocean type.
I'll have to add North east somehow


Top
 Profile  
 
 Post subject: Re: [CW2] Map editor
PostPosted: Wed Apr 22, 2009 4:02 am 
Offline
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
Another mapmaker update that handles 8 directions instead of 4.
Image
note that there are still missing parts in the coasts this is because there is no good terrain for that position. There is no coast bend with a piece of land on the opposite. Probably have to add those to the image strip. Now on to units and cities


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 9:30 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Blue Moon by Trent © 2007
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group