Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - xerca

Pages: [1]
1
SFML projects / Re: 'Tiled' Tile-map Loader
« on: March 21, 2015, 04:28:48 pm »
Hello. I have encountered another problem while using the map loader and solved it, so I am posting this here in case anyone else gets the same problem or fallahn decides to update it.

The loader works with no problem when the tilesets have 1 px spacing and 1 px margin. But I had a map made with a tileset that had no margins and despite Tiled showing it without a problem, in the game, the tiles were all messed up. I looked through the code and noticed these lines in MapLoaderPrivate.cpp:
//slice into tiles
int columns = (sourceImage.getSize().x - margin) / (tileWidth + spacing);
int rows = (sourceImage.getSize().y - margin) / (tileHeight + spacing);
 
Here, sourceImage.getSize().x and .y  are the dimensions of the tileset image. The problem with this is, there are 2 margins in both dimensions (one left + one right and one up + one down) and "tiles in a row/column" - 1 spacings (since there is no spacing before the first and after the last tile).

In my case, this resulted in 56 instead of 57 tiles in a row: (968 - 0)/(16 + 1) = 56.94 which rounds down to 56.

I think the correct calculation should be like this:
//slice into tiles
int columns = (sourceImage.getSize().x - 2*margin + spacing) / (tileWidth + spacing);
int rows = (sourceImage.getSize().y - 2*margin + spacing) / (tileHeight + spacing);
 
So I changed it and now it works.

2
This is so amazingly beautiful

3
SFML projects / Re: 'Tiled' Tile-map Loader
« on: October 19, 2014, 06:22:19 pm »
To be honest I was already using four points for my characters to handle obstacles while walking but I wanted the player to be able to interact with characters in the same way. Since I couldn't check two sets of points against each other, I decided to use MapObjects instead. Now that you said there is probably a bug, I got more confident in my code and looked thoroughly at the MapObject class to find out what happens exactly.

I found the problem to be in the "SetPosition" or more precisely the "move" method of MapObject:
(click to show/hide)
It moves the points of the map object as well as the position vector whereas the points are supposed to be relative to the position vector of the object. This results in the actual shape being moved twice as much from where it was before. Simply commenting those two lines solved my problem. Thank you!

4
SFML projects / Re: 'Tiled' Tile-map Loader
« on: October 18, 2014, 12:07:33 am »
First of all, thank you for this great map loader! I'm using it in my game project and it works really well. Except, I have a problem now that I couldn't solve.

If I understand correctly, the Intersects method in MapObject class is supposed to return true when the two MapObjects have overlapping area, false otherwise. At least that is how I expected to use it. However, it gives random results for me.
The code I wrote looks like this:
(click to show/hide)
This method is called everytime I press "E".

I recorded an example of how it behaves: http://gfycat.com/PerkyIncredibleHeron Here the red box is the DebugShape of interactBox, the gray boxes are the objects in the "interactions" layer of the map. The first sign  I am trying to interact is named "sign1" and the gray box at the top that I can interact without even touching is named "rect1".

It seems I have done something wrong and I just can't figure out why! I have poor programming skills despite coding for many years so it would be very nice if whoever understands my problem explains it to me in a simple way. Thank you in advance!

5
SFML projects / Re: The 8-Bit Encounter - My Open-World 2D Game Demo
« on: October 06, 2014, 03:41:55 pm »
I am interested in this, keep up the good work. One thing about the demo: If you stand at left of the skeleton guard that is supposed move in that direction while talking to it, he can't and the game becomes stuck.

Pages: [1]