Sign in to follow this  
NLScotty

Map editor

Recommended Posts

Hello,

 

I'm thinking about creating my own map editor, with my own saving to file code etc. My goal is something like this : http://www.youtube.com/watch?v=_Wpc1c7syTA .

 

I'll be using tiles, as a tile could be the size 70x30 (not sure yet). Since I need way more horizontal lenght, cause I will only use it for platformers. I wonder how it is possible that he can create tiles on every place on the map. Is he using tiles, and have the picture of the tile start at given coordinates? Or is this a right way to do it?

 

So instead of a tile having 1 picture, it now has a picture at a given coordinate inside the tile.

 

Grz

Share this post


Link to post
Share on other sites

Well there are many ways to do this. You can break down your map into a grid and load only cells that are visible. Each cell would have a list of picture IDs, their coordinates and any other special parameters such as portals/fire/etc... Then it simply becomes a matter of fetching a handle to the actual picture from the loaded ID. 

Share this post


Link to post
Share on other sites

He is definetly not using tiles because game object have no alignent in the scene. You're probably confused between 'tile world representation' and 'tiled textures'.

 

tile world representation - that means that he is using tiles to place object. each object lies on a tile. 

 

tiled textures - one texture can contain one ore more images. each image can represent different object(or some part of an object). Each different image on the texture is called tile. Later in code a tile is defined with structure that looks like this { textureName: 'example-grass-tiles.some_extension, tileTopLeftPoint (0,0), tileBottomRightPoint(50, 50) ; }.

 

So when he displays a tile he is writing something like this : 

Draw(objectPosition, myTile.texture, myTileTopLeftPoint, myTileBottomRightPoint); //a tile defined by myTile variable is going to be drawn at point objectPosition);

Share this post


Link to post
Share on other sites

He is definetly not using tiles because game object have no alignent in the scene.

I agree he's not using tiles in the general sense, but I do think they have some sort of alignment. This is so from the fact that all blocks are fitting properly with each other.

They're most likely block assets of varied sizes that were all painted under the same grid.

 

To create those assets, the artist sets up in his painting program an infinite grid with a spacing of 32x32 pixels, for example, and draws freehand but under that reference grid and with some game-design established constraints, such as "platform heights that are two grid cells high", "slopes that always finish in exact cells" etc.

219p8wz.jpg

 

On the editor, you just need to snap these blocks under a grid of the same size as the reference one used by the artist (in this case, that grid of 32x32 spacing), so they fit together.

Edited by Kryzon

Share this post


Link to post
Share on other sites

He is definetly not using tiles because game object have no alignent in the scene. You're probably confused between 'tile world representation' and 'tiled textures'.

 

tile world representation - that means that he is using tiles to place object. each object lies on a tile. 

 

tiled textures - one texture can contain one ore more images. each image can represent different object(or some part of an object). Each different image on the texture is called tile. Later in code a tile is defined with structure that looks like this { textureName: 'example-grass-tiles.some_extension, tileTopLeftPoint (0,0), tileBottomRightPoint(50, 50) ; }.

 

So when he displays a tile he is writing something like this : 

Draw(objectPosition, myTile.texture, myTileTopLeftPoint, myTileBottomRightPoint); //a tile defined by myTile variable is going to be drawn at point objectPosition);

 

ok thanks guys. So if I understand everything: My map class, will have an array with all the tiled textures, like a square in the map. In this square i will code my tiles. But there could be overlapping between these squares right?

 

In code

class Tile // ur struct
{
    POINT leftTop, RightTop; // the x,y from the square (tiled texture)
}

class TiledTexture
{
     List<Tile> m_currentTiles; // all tiles from this square
}

class Map
{
    const int texture_size = 150; // so a square is 150x150, for example
    TiledTexture[][] m_textures;
}

class Camera
{
     // checks which tiled textures are visible and draws those.
}

Is it also a good idea, that when a tiled texture IS visible, instead of drawing all textures one by one, make one big texture of it and draw that to the screen?

Share this post


Link to post
Share on other sites

You need additional file to express where tiles are locaded.

you can use something simple like

<tile_name> <texture_name> <TopLeftCoords> <BottomRigthCoords> or

<tile_name> <texture_name> <TopLeftCoords> <WidthAndHeight> or watherver

 

Example file :

 

myTileDesk.txt :

grass1 grass_tex.bmp 0 0     50 50

grass2 grass_tex.bmp 50 0    100 50

rock1  rock_tex.bmp 0 0       50 50

 

 

Also if you prefer you can use different file that describes tiles for each texture it is up to you

 

 

Later in code:

 

Tile

{

std::string name;

Texture* pTexture;

RECT coords;
}

 

class MyTileManager
{

 

public :

 

Tile* GetTileByName(char* tileName);

 

   private:

vector<Texture> textures;

vector<Tile> tiles;

 

}

 

and probably later

 

DrawTile(Tile*, xPos, yPos);

 

Or some similar structure

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