SFML community forums

General => SFML projects => Topic started by: Breakman79 on March 20, 2010, 07:32:12 am

Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on March 20, 2010, 07:32:12 am
Hi fellow SFML programmers.  Since I'm new here I thought I'd start off by posting something that I think a lot of people would find useful.  I didn't see any finished SFML tilemap engines so I ported Mappy's to SFML and C++ as an exercise in learning C++


The library can display:

New Release: May 19, 2010

Issues Fixed:
-Tile #0 is no longer drawn.  This was causing a transparency issue with maps using images greater than 8-bit color depth and drawing more than one layer.

Improvements:
-Added SetMapStartPosition and SetMapDimensions functions while overloading some of the drawing functions so those values can be set once instead of being passed every time.  Overloaded the constructor so that map filename, and the position and dimensions can all be set at once.

Other Notes:
-The Demo isn't working quite as well in this release as the last.  I was working on rewriting but I wanted to get the fix out for WitchD0ctor so I left it as is.  Need to overload the DrawMapParallax and DrawMapRow functions.

The new download can be found here: http://www.mediafire.com/file/kwczgm5wzzn/SFMLMappy_2010_05_19.zip


The Mappy TileMap editor can be found here: http://www.tilemap.co.uk/mappy.php


Questions, comments, bugs reports are greatly welcomed.
Title: Mappy tilemap engine playback library port for SFML
Post by: Nothingness0x on April 01, 2010, 12:50:36 am
one question : How do you put collisions ? And how it is saved on the file ? (wanna know to know how to program the map reader)

Can we use animated tiles like water ? How

Thanks and good job
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 01, 2010, 06:26:36 pm
In the Mappy editor you can add the collision information by double clicking on a graphic block in the "Still Block" area which brings up the "Block Properties" screen.  On it there is a section for Collisions with check boxes for top left, top right, bottom left, and bottom right.

To retrieve the collision information using the playback library you can use the GetMapBlockInPixels method.  It returns a struct containing all of the information of the graphic block located at position at the requested x and y coordinate with 0,0 starting at the top left of the map.

Yes, you can add tile animations.  In the editor if you right click on the "Still Block" area it will switch to "Anim Blocks" where you can add a new block (Ctrl-N) and double clicking it you can add the different animations, delay, and how is it looped.  The zelda.fmp map I included in the download has a bunch of example animations including some simple water animations.

Let me know if you need anything else.  I'm still working on this library to add more improvements and hopefully I'll have time to create a simple game for an example.
Title: Mappy tilemap engine playback library port for SFML
Post by: Nothingness0x on April 02, 2010, 01:50:52 am
Yes I still have some other questions actually :

1)Can I load my own tiles on the editor ?
Or do I gotta use only specific tiles provided by the editor ?

2)and If for exemple I put a tree on my map, how do you manage the fact that the character can pass behind the tree without being blocked (I mean the character pass behind the tree and disapear behind because the tree is draw after the character ), whereas if the character pass in front of the tree, the tree is drawed after the character because the character is in front of the tree, and the collision area must be somewhere in the middle of the character.


3) When you click on a tiles or a groupe of tiles, it would be great if your mouse pointer take the image of the tiles you clicked on, because it's hard to aim with the basic mouse pointer and you dunno what you took, because right now all i see is a white thing.

4) is it possible to take several tiles at the same time ? I mean if i have a house who is made of 6 tiles for exemple, I should be able to take the whole 6 tiles house at the same time and draw it on the map without having to draw my house tiles per tiles

5) If i create a map and save it, is it save on a .txt ? I have to know how its saved to know how to developp my map reader inside my game ...

6) The version i download here http://www.tilemap.co.uk/mappy.php  is the sfml/c++ version right ?

I hope you understand what i mean cause my english is not perfect .... sorry about that.

thanks
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 02, 2010, 04:50:36 am
Ok, I think you are confusing some things here.  I'm not the author of the actual Mappy map editor.  I simply ported the playback library, the part you would include in your game, from using a Direct X media library to instead work with SFML.

The source code I provide in the download link is a class you can include in your game to load and display any map created with the Mappy editor along with methods for doing things like the collision detection and updating the map animations.

I can answer some of your questions about the editor though:

1) You can load any tiles you want as long at they are all the same size based on what you define when you create a new map.  They all need to stored in a single file that you load using File->Import.  

2) For something like a tree you need to split it up into multiple tiles.  The roots being in with the collision flags set and the graphic set to the BG layer.  The top of the tree would be in another tile with no collision and set to the FG1 layer.  

3) Since I didn't make the editor there isn't anything I can do about it, but I think that would be nice as well.

4) Yes, the Brush menu lets you create brushes made out of multiple tiles.

5) The maps are normally saved in a binary format. I believe you can use File->Export as text to make something different.  The map reader you talk about is the part that I actually have already made and linked in the first post which you can reuse for your game.

6) That's the Mappy author's website where you can download the editor and the playback libraries for different game and media libraries (One didn't exist for SFML so made it)
Title: Mappy tilemap engine playback library port for SFML
Post by: Walker on April 13, 2010, 07:27:28 am
I found mappy a few days ago and dreaded the thought of working it into SFML. I've been playing around with your port a bit and it seems to do everything I need at the moment.

Have you made any more progress? Are you still planning to create a bit of an example on how to use it? I've been working through the Allegro example but I don't have the Allegro library so a working example I can compile and run would be great.

Cheers :)
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 13, 2010, 11:14:20 pm
Hi Walker.  Yes, I'm still working on improving the port.  I added a new download in my original post with an updated version of the class along with two examples and a small demo showing how the map collision detection would work for some simple AI sprites.  

I've been pressed for time lately so I didn't comment it very well, but I'll definitely answer any questions that you have.
Title: Mappy tilemap engine playback library port for SFML
Post by: Walker on April 14, 2010, 04:30:20 am
Excellent, I'm starting to understand the collisions and other tile info stuff now. I think.

Code: [Select]
GetMapBlockInPixels(x, y)

Returns the BLKSTR struct for the tile at PIXELS x, y? GetMapBlock(x, y) returns BLKSTR for TILE x, y?

Code: [Select]
if(TileMap.GetMapBlockInPixels(pos1x,pos1y)->tr) return true;

Basically checks if the 'tr' box in the editor was checked? I can't seem to get this to work in my own code.

How do you check the value one of the User variables?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 14, 2010, 06:39:28 am
Quote
Returns the BLKSTR struct for the tile at PIXELS x, y? GetMapBlock(x, y) returns BLKSTR for TILE x, y?

That's exactly right and it's based on the map coordinates.  So if you're looking for the collision on a block that currently showing up at say position 100,100 on the screen, but you've scrolled the map 400 pixels to the right then you need to be calling GetMapBlockInPixels(500,100)

I was only doing a simple collision check for the whole tile by only checking the top right value.  You make it as simple or complicated as you like using the 4 checkboxes.

Checking for the User vars should be as simple as:
Code: [Select]
unsigned long int User1;
User1 = Map.GetMapBlockInPixels(x,y)->user1;


User1 and 2 are unsigned long ints, 3 and 4 are unsigned short ints, and 5, 6, and 7 are unsigned chars.

Hmm, I haven't had any problems with using GetMapBlockInPixels unless you request something out of range and then it will crash.  The function works on whatever current layer you have selected, so if you change to one to draw some rooftops or something and forget to change back before running your collision detection, that would be a problem.

If you can't work it out, I could take a look at your code to see what I can figure out.
[/quote]
Title: Mappy tilemap engine playback library port for SFML
Post by: Walker on April 14, 2010, 07:37:44 am
Oh of course, I was experimenting just after my drawing routine so I was on a different layer than what I thought.  :oops:

Cheers
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on April 22, 2010, 11:27:04 am
How can you make the background transparent, like the allegro version has
MapDrawBGT, in the header it says DrawMapBG is the same, but it draws Black where the empty space is, is there a way around that?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 22, 2010, 03:55:17 pm
The background should already be transparent.  DrawMapBGT is redundant because in SFML all sprites are drawn using their alpha transparency by default.

Are you drawing anything to the screen before calling DrawMapBG?  A simple way to test that it's working is to change the Clear function so that it clears the screen to a different color other than black to test.

If you're using the code from one of the examples change the App.Clear line to this:

App.Clear(sf::Color(255, 0, 0));

That should make all of the transparent areas show up as red.

Let me know if you are still having problems.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on April 24, 2010, 11:08:41 am
Still having issues, i thought it might be the map, but all of the tiles have BG transparency checked. any idea what's going on?
Title: Mappy tilemap engine playback library port for SFML
Post by: Ashenwraith on April 26, 2010, 02:50:24 am
Hey, have you thought of porting to Tiled:

http://www.mapeditor.org/

It's open source and has free features you don't have to pay for like placing map objects. You also don't need to download separate files for png support.

Plus it supports windows/mac/linux.

The original version was done in java, but the new version is done in C++ with Qt.
Title: Mappy tilemap engine playback library port for SFML
Post by: Walker on April 26, 2010, 03:28:49 am
Tiled is good, but this is the SFML Mappy thread. Placing objects with Mappy really isn't very difficult to work out. AFAIK, Tiled doesn't already have map loading code for SFML.

I don't think switching to Tiled would be a good move at this stage, you're bound to run into just as many issues with that plus you would have to rewrite everything.
Title: Mappy tilemap engine playback library port for SFML
Post by: Ashenwraith on April 26, 2010, 03:51:19 am
Quote from: "Walker"
Tiled is good, but this is the SFML Mappy thread. Placing objects with Mappy really isn't very difficult to work out. AFAIK, Tiled doesn't already have map loading code for SFML.

I don't think switching to Tiled would be a good move at this stage, you're bound to run into just as many issues with that plus you would have to rewrite everything.


Of course SFML doesn't have map loading code for Tiled, that's what I'm suggesting, otherwise you don't have to do anything.

Mappy is closed source so you cannot quickly adapt it to your engine, it will always be a generic map editor and you have to write external converters/tools if you want more.
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on April 26, 2010, 04:39:45 am
WitchD0ctor, the BG Transparency flag doesn't do anything in SFMLMappy.  It was a trigger in DrawMapBGT to do a masked_blit instead of a regular blit.  

Only thing I can think of off-hand is that you are using the wrong color for the area you want transparent.  When the map is loaded into SFML all of the tiles are converted to 32-bit images with alpha channels.  For an 8-bit tile the palette color 0 will be converted to alpha 0.  15, 16, and 24-bit tiles use magenta 255,0,255 for alpha 0, and 32-bit images are left alone and use whatever alpha is already set in the image.

If you really need a hand you can upload the map and I can take a look at it to see what you're trying to do.


Ashenwraith, actually I have looked at Tiled and another one which I've forgotten when I first thought about porting a playblack library to SFML.  I went with Mappy since the Allegro playback lib was the easiest to port since I used to program in it.  Personally I like the Tiled editor interface better, Mappy is a bit clunky in a way and someone would need WINE to use it on a linux/mac box.   I do like that Mappy stores all of the tiles in map file where this program keeps them in a separate tilesheet.  You can't create animated tiles and It looks like tile properties are user defined.   It wWould be a lot of work to use an XML parser to build out a container to hold all of the map data.
Title: Mappy tilemap engine playback library port for SFML
Post by: Ashenwraith on April 26, 2010, 04:46:21 am
Quote from: "Breakman79"
Ashenwraith, actually I have looked at Tiled and another one which I've forgotten when I first thought about porting a playblack library to SFML.  I went with Mappy since the Allegro playback lib was the easiest to port since I used to program in it.  Personally I like the Tiled editor interface better, Mappy is a bit clunky in a way and someone would need WINE to use it on a linux/mac box.   I do like that Mappy stores all of the tiles in map file where this program keeps them in a separate tilesheet.  You can't create animated tiles and It looks like tile properties are user defined.   It wWould be a lot of work to use an XML parser to build out a container to hold all of the map data.


Yes I thought about this because I'm not a big fan of XML myself, but since Tiled is opensource you can build a plug-in for Tiled that handles whatever format you want/convert to (ie, support for mappy).
Title: Mappy tilemap engine playback library port for SFML
Post by: Walker on April 27, 2010, 05:36:09 am
Sorry, Ashenwraith, I though you were suggesting witchdoctor switching to Tiled.

I did like the look of Tiled, but with no example code for me to dig in to straight away, I went with Mappy. If someone wants to port Tiled to SFML, I'd certainly use it :)
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 18, 2010, 12:30:00 am
Sorry it took so long for me to get back to u, I'm stil having issues with background tranceparency. I'll upload a build of what I got very soon
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 18, 2010, 06:02:03 am
Ok, here is a build of what I have
www.blackshark.nukelol.com/NSSC/PlovR_001.zip

the controls are, W to thrust up, A and D to thrust Left and Right respectively

Left mouse to shoot, and mouse wheel to change weapons,

the black should be clear, and show the Grey background but it doesn't, its like its not being masked at all for some reason (this is block 0 that I'm talking about)


Thanks for any help you can offer!
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on May 18, 2010, 07:59:42 am
Alright, I believe I have a solution for your problem.  There is indeed a problem with the drawing of tile 0.  I didn't notice it for my 8-bit test maps because the color of tile 0 matches the transparency color, but that isn't true for the higher bit depth maps.  

I've changed the Draw functions to ignore drawing tile 0 which should fix your problem and it gives a nice speed boost if you're drawing multiple layers at once.  I need to back out some changes I wasn't finished with but I think I can get a new release up sometime within the next day.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 18, 2010, 09:32:37 am
Most awesome, thank you very much.

I'm using this game for a prototype in one of my college classes and one of my team members brought up background images and reminded me of this problem, we meet up again Wednesday and it would be awesome if i had parallax scrolling backgrounds done by then.

Thanks again!
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 19, 2010, 11:27:33 am
Cool, my issue has been resolved, thank you so much!
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on May 19, 2010, 06:01:42 pm
Awesome!  I'm glad it works for you now  :D
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 20, 2010, 12:18:38 am
hey, I have a little feature request, don't know how feasible it would be, but how about being able to control how fast the parallax backgrounds scroll? for a cool multiple parallax effect, like you call

   
Code: [Select]
Map.DrawMapParallax(*Get_RenderWindow(), Background, Background.GetImage()->GetWidth(), Background.GetImage()->GetHeight(), Map.Get_Camera().x * scrollSpeed, Map.Get_Camera().y * scrollSpeed);


because currently if i were to multiply by scrollSpeed, i get really weird effects.


This isn't important or anything, just thought it would be kinda neat :)
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on May 20, 2010, 02:04:42 am
Sure, I add to the function so that you can make it scroll slower.  Right now the parallax scrolls at half the speed of the map.  I can pretty easily change it so that you can pass in or set a parameter to change the scroll speed to 1/3, 1/4, 1/5... etc.  However if you need it to scroll faster than 1/2, it doesn't look so simple.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on May 20, 2010, 07:19:11 am
Cool! the only time i would need it to scroll faster was if it was in front of the map being drawn, which i might want, but that's something that would be a special case and i would add the myself any way.



EDIT:

also i noticed this in the header file,

Code: [Select]
If SFML has a method of returning image size for a sprite, let me know so I can change it so they don't need to be passed in.


I believe you can get it like this,
Code: [Select]

sprite.GetImage()->GetWidth();
sprite.GetImage()->GetHeight();




EDIT #2

Ok, I added the multi-speed scroll ability to the DrawMapParallax by adding a nother argument "float scrollSpeed", and if set to 1, it will scroll at the same speed of the map, the closer you get to 1 the slower it is, so 1.7 will scroll faster than 1.2.

works pretty well, if you would like to see the whole thing i could post it, but it really isn't much, the "scrollSpeed" just replaces the hard coded 2 in the function.
Title: Using Zoom
Post by: CytraL on July 02, 2010, 04:03:01 am
Hi! first, great work!! ;)

Pls.. How can use sf::View zooming with SFMLMappy ???

Thx!
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on July 02, 2010, 07:41:53 pm
I've have yet to actually work with Views in SFML, but it doesn't look to hard.  I added these two lines in my demo program before the main loop and it doubled the size of map and sprite images.

sf::View& DefaultView = App.GetDefaultView();
DefaultView.Zoom(2);
Title: Mappy tilemap engine playback library port for SFML
Post by: CytraL on July 03, 2010, 08:31:01 pm
Hi! Thank you for responding :)

The problem I have it when I want things away....

With x2 Zoom:
(http://img293.imageshack.us/img293/6632/zoom2.png)

With x0.5 Zoom:
(http://img12.imageshack.us/img12/5344/zoom05.png)


Thx!


P.D: Sry for my bad english :\
Title: Compile Errors
Post by: Victoria on July 04, 2010, 04:01:44 am
Hey, I'm using Code::Blocks 10.05 with the mingw-with-gcc-4.4 package on the sfml-dev site. When I try to compile Demo.cpp I get:

SFMLMappy.h|132|error: extra qualification 'SFMLMappy::' on member 'SFMLMappy'|
SFMLMappy.h|147|error: extra qualification 'SFMLMappy::' on member 'GenerateMapYLookup'|
||=== Build finished: 2 errors, 0 warnings ===|

Can you point me in the right direction? Thanks.

PS: I tried removing the 'extra qualification', and it just gives me different errors.
Title: Mappy tilemap engine playback library port for SFML
Post by: CytraL on July 04, 2010, 08:11:25 pm
Ok..i fixed my problem ;)
Title: Fixed
Post by: Victoria on July 04, 2010, 10:56:25 pm
I fixed my problem too  :wink: It turns out if I remove the 'SFMLMappy::' in the header, it does fix it. The other errors I got were just user error.

Thanks.
Title: Great
Post by: Hugo on July 08, 2010, 11:53:27 pm
Great! Now I don't have to write my own tiling/map engine, this engine's free though right? And it it has it's own map editor and it can load maps into sfml? And can it show any image size and any #of Images right?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on July 09, 2010, 10:30:49 pm
Yes, the playback library I made plus the standard version of the map editor are free.  The mappy editor will complain if you try to create a tile size greater than 128x128 but I believe size of the images it can display are really only limited by size of your graphic card's texture memory.  I believe it has a map limit of around 10,000 x 10,000 tiles.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on August 15, 2010, 12:02:06 pm
Is their a way to load the .FMP from memory?
that would be a real useful feature
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on August 16, 2010, 04:25:46 pm
Yes, there is a function for that.

Use DecodeMap which you pass a pointer to the FMP file you already have stored in memory.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on August 18, 2010, 04:58:05 am
Cool! It works, thanks

now does any one know of a version of mappy that supports alpha transparency? Other than magic pink? Like blending?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on August 20, 2010, 06:43:03 am
Are you sure it doesn't already?  

I was pretty sure I tested 24-bit graphics with alpha blending and I definitely wrote code to handle them in the playback library because the 8-bit and 16-bit graphics are converted to 24 to work with SFML.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on August 20, 2010, 11:06:40 am
i don't think so, its either fully transparent or fully opaque, doesn't seem to allow png's that are inbetween
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on August 20, 2010, 04:41:31 pm
I took a look around on the Mappy forums and it looks like 24-bit FMPs still use colorkeys for the transparency, but if you create a 32-bit FMP and use 32-bit pngs the alpha channels should work.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on August 21, 2010, 01:17:21 am
Nope, just tested it out to be double sure, created a 32 bit (+ alpha) FMP and importing a transparent png image causes the tiles that are partially transparent to become fully opaque and ungodly ugly :s



EDIT:
new question, how do you use
       'SetMapStartPosition'
and
   'SetMapDimensions'
?

im trying to convert my camera from using mappy's functions to using Views, but when i do, I see that Mappy automatically culls tiles that are not suppose to be visible, but they are cuz I'm using views now. and i thought that with these functions, i can set the map Dimensions to the size of the map, so it would stop culling but i was wrong.

Am i on the right track here?

EDIT 2:
nvm, got it working! was resetting the Map start pos, and Map dimensions every time i draw a layer because of an incorrect call. fixed now
Title: Some issues with Tilemap engine
Post by: Naufr4g0 on November 07, 2010, 04:08:05 pm
Hi, Breakman79!
I'm using your Mappy playback port for SFML intensively, and I had no problems so far.
I'm using layer #2 of the tilemap as a trigger map for some gameplay actions.
But when I use this code in a method of a class:
Code: [Select]

map.ChangeMapLayer(2);
long int tileID = map.GetMapBlockInPixels(pos.x + 6, pos.y + 6)->bgoff;
this->tileID = tileID;

to get the ID of a tile under the player sprite, the program gimme a runtime error that I can't solve.
The definition of the method containing this code is:
Code: [Select]
void Ninja::CollisionDetection(SFMLMappy& map)
When I comment the line:
Code: [Select]

this->tileID = tileID;

the problem disappears.
Why?
Thanks for your very useful SFMLMappy, and for your future answer.
Title: Mappy tilemap engine playback library port for SFML
Post by: WitchD0ctor on November 08, 2010, 08:49:08 am
Probably wont fix the problem but why not save a line with,
Code: [Select]

this->tileID = map.GetMapBlockInPixels(pos.x + 6, pos.y + 6)->bgoff;

Title: Mappy tilemap engine playback library port for SFML
Post by: Naufr4g0 on November 08, 2010, 05:09:26 pm
Quote from: "WitchD0ctor"
Probably wont fix the problem but why not save a line with,
Code: [Select]

this->tileID = map.GetMapBlockInPixels(pos.x + 6, pos.y + 6)->bgoff;



'Cause, as you guessed, it doesn't work!
The problem is I can't store the value in a private data member of the class, but if I simply read the value, I have no errors.
Title: Re: Some issues with Tilemap engine
Post by: Breakman79 on November 08, 2010, 08:10:46 pm
Quote from: "Naufr4g0"
Hi, Breakman79!
I'm using your Mappy playback port for SFML intensively, and I had no problems so far.
I'm using layer #2 of the tilemap as a trigger map for some gameplay actions.
But when I use this code in a method of a class:
Code: [Select]

map.ChangeMapLayer(2);
long int tileID = map.GetMapBlockInPixels(pos.x + 6, pos.y + 6)->bgoff;
this->tileID = tileID;


Sorry it took me a while to get back to you.  

Hmm, are you sure that you aren't requesting the bgoff for a position outside of the map dimensions?  The library has no bounds checking so it will definitely throw a runtime error if you try to request a position that doesn't exist.
Title: SOLVED!
Post by: Naufr4g0 on November 08, 2010, 08:51:19 pm
Quote from: "Breakman79"

Hmm, are you sure that you aren't requesting the bgoff for a position outside of the map dimensions?  The library has no bounds checking so it will definitely throw a runtime error if you try to request a position that doesn't exist.


Don't tell my why, but now the code works, without errors.
I made some other modification to the code and now it works with no apparent reason (maybe pos.x and pos.y returned an incorrect value)! :'D

Anyway here is a video of the game I'm working on:

>>> Ninja game preview <<< (http://www.youtube.com/watch?v=uHQWeL3sJI4)
Title: Mappy tilemap engine playback library port for SFML
Post by: darekg11 on November 12, 2010, 02:58:59 pm
Helo, I have a question:
I have to use normal Mappy editor and then use Your file to probably handle it in SFML?
Title: Mappy tilemap engine playback library port for SFML
Post by: toddcarnes on February 09, 2011, 08:23:16 am
Quote from: "Ashenwraith"
Mappy is closed source so you cannot quickly adapt it to your engine, it will always be a generic map editor and you have to write external converters/tools if you want more.


Actually...

The code was made freely available for anyone to use and/or modify a long, time ago. So, you can adapt it and make it as "non-generic" as you want. All the original author asks is that you give him credit and NOT name your resulting editor "Mappy".

FWIW, I just downloaded the source for Mappy 1.01 and found that it still compiles just fine on Ubuntu 10.10. (As long as you don't mind ignoring the 384 warnings issued by the Allegro libraries for using deprecated code <grin>). It runs natively on Linux, loads fmp files, etc.

There is actually a more up-to-date version of the source available, but it's for the Windows version. I haven't tried to compile it yet.

Todd
Title: Mappy tilemap engine playback library port for SFML
Post by: toddcarnes on February 09, 2011, 08:25:16 am
Quote from: "darekg11"
Helo, I have a question:
I have to use normal Mappy editor and then use Your file to probably handle it in SFML?


Yes, that is correct.
Title: Mappy tilemap engine playback library port for SFML
Post by: Anata on December 12, 2011, 02:12:26 am
hello

Is there an update of SfmlMappy for use with smfl2 or someone have a modified version ?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on December 13, 2011, 04:39:32 am
Sorry, but I haven't upgraded the playback library for version 2 yet.  I've been waiting for the graphics API to stabilize before I dive in and see what has changed.  

It's possible someone else has already modified it to version 2 for their own use, but I haven't been notified.
Title: Mappy tilemap engine playback library port for SFML
Post by: Anata on December 26, 2011, 06:35:15 pm
How to get the X and Y block position of a layer with sfmlmappy ?

I have make a layer with a tile for collision, and would like to get X and Y from this block for my collision.

I've try with tl/tr/bl/br for collision, but difficult to use when you have slop tile :(
Title: Mappy tilemap engine playback library port for SFML
Post by: Neomex on January 01, 2012, 10:32:37 pm
And how does it handle drawing many sprites? Is it actually able to run over 60fps with 1024x768 screen fullof 16bit tiles? Does it use OpenGL to render it or SFML graphics?
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on January 03, 2012, 11:32:08 pm
Quote from: "Neomex"
And how does it handle drawing many sprites? Is it actually able to run over 60fps with 1024x768 screen fullof 16bit tiles? Does it use OpenGL to render it or SFML graphics?


That really depends on a lot of things such as the power of your video card and how many layers you are trying to draw at once.  The 1.6 version is using SFML sprites for rendering so there is some overhead there.  Also, mappy supports multi-frame animations for tiles so it needs to redraw every tile every frame for that.
Title: Mappy tilemap engine playback library port for SFML
Post by: Wander on January 19, 2012, 09:04:00 pm
I downloaded the zip with the sample code and the header and cpp file and I added them to my project, etc. When I try to run the program my debugger breaks at all of the points in the SFMLMappy::LoadMap() where it tries to edit the boolean entitled map_error. Whether it's going to true or false... it throws an exception.

Quote
Unhandled exception at 0x013caeab in App.exe: 0xC0000005: Access violation writing location 0xcdcdce31.
Title: Mappy tilemap engine playback library port for SFML
Post by: Breakman79 on January 19, 2012, 10:52:07 pm
That's strange.  It's just a simple static variable that is private to the SFMLMappy class.  I can't think of a reason why you would get an error like that; I've only seen that message when trying to write to a pointer that is out of bounds.
Title: Mappy tilemap engine playback library port for SFML
Post by: Wander on January 19, 2012, 11:18:08 pm
Hahaha. I figured this one out. I feel stupid.

I had:

Code: [Select]
class Map
{
    SFMLMappy *map;
}


But then I forgot to say:
Code: [Select]
map = new SFMLMappy();

Hahaha. Stupid me.
Title: Mappy tilemap engine playback library port for SFML
Post by: Nexus on January 20, 2012, 07:43:48 pm
A problem (among many) you wouldn't have if you used
Code: [Select]
SFMLMappy map;
Title: Mappy tilemap engine playback library port for SFML
Post by: Wander on January 20, 2012, 08:22:46 pm
I thought if you declared something that had parameters from the class declaration you had to make it a pointer. :o
Title: Mappy tilemap engine playback library port for SFML
Post by: Nexus on January 20, 2012, 08:27:45 pm
Maybe you confuse something: You have to use pointers if types are (directly or indirectly) recursive, something like that doesn't work:
Code: [Select]
class A { A a; }
};
Code: [Select]
class A { B b; };
class B { A a; };

Often, pointers also help you to reduce dependencies, since the type needn't be complete at declaration. The climax results in the Pimpl Idiom.

In many cases, you can use smart pointers (e.g. std::unique_ptr) to benefit of the advantages of automatic memory management.
Title: Mappy tilemap engine playback library port for SFML
Post by: Wander on January 20, 2012, 08:32:52 pm
Quote
You have to use pointers if types are (directly or indirectly) recursive

Oh that makes a lot more sense!! :D Thanks!

Quote
you can use smart pointers


I've researched these, but I don't quite understand them... What is the purpose of these things besides memory management?
Title: Mappy tilemap engine playback library port for SFML
Post by: Nexus on January 20, 2012, 08:54:03 pm
Quote from: "Wander"
I've researched these, but I don't quite understand them... What is the purpose of these things besides memory management?
They allow to work with RAII (http://en.wikipedia.org/wiki/RAII), a powerful idiom that makes it extremely easy to manage resources (e.g. memory).

And there are different implementations with different ownership strategies (unique, shared, copied), some also support further features.
Title: Mappy tilemap engine playback library port for SFML
Post by: GamingGod on March 18, 2012, 01:55:00 pm
Will it work with SFML 2.0? If no, can someone post link to good tile map parser that will be compatible with SFML 2.0 and Mappy? I'm trying to find one but still no luck.
Title: Mappy tilemap engine playback library port for SFML
Post by: eXpl0it3r on March 18, 2012, 05:54:23 pm
Quote from: "GamingGod"
Will it work with SFML 2.0?

Since you're asking with the verb "will" which is afaik a futur tense, I can answer it by yes.
But to get there you'd have to modify it a bit. The heavy part in the class isn't dealing with SFML but loading the Mappy files.

One would now have to deal with chaning from sf::Image to sf::Texture the rest seems pretty much interchangable.
I didn't look at the examples but since you're using SFML 2 you won't have much problems rewriting them for SFML 2.  :wink:

Btw: Why is this not listed on the Mappy website under Mappy Playback Libraries?  :shock:
Title: Re: Mappy tilemap engine playback library port for SFML
Post by: Aoos on June 13, 2012, 08:21:33 pm
Sorry but the download link is dead! :'(  Can you reupload it?
Title: Re: Mappy tilemap engine playback library port for SFML
Post by: aBallofWin on June 13, 2012, 10:57:30 pm
Sorry but the download link is dead! :'(  Can you reupload it?

I second this :P