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

Author Topic: So, I want to save a tile map.  (Read 17954 times)

0 Members and 1 Guest are viewing this topic.

ineed.help

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: So, I want to save a tile map.
« Reply #30 on: April 27, 2014, 10:20:00 pm »
Quote
...
For the record, the main reason debug mode exists in the first place is to make all of these features possible.
Thank you. (EDIT: I just realized you have to use the proper debugger, not CTRL+F5.) :P
Quote
As I said before, the second parameter to resize() is what you want.
And as I just told you, it doesn't work - "tileMap.resize(columnAmount, Vector2i(-1, -1));" is an invalid constructor for "resize".
« Last Edit: April 27, 2014, 10:24:57 pm by ineed.help »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: So, I want to save a tile map.
« Reply #31 on: April 27, 2014, 10:25:10 pm »
Ah, sorry, I misunderstood that.  That's happening because tileMap is a vector of vector<Vector2i>, so if you call tileMap.resize() you need to give it a vector<Vector2i>, not a Vector2i.  If you called tileMap[0].resize() then you would pass it a Vector2i.

ineed.help

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: So, I want to save a tile map.
« Reply #32 on: April 27, 2014, 10:27:27 pm »
Ah, sorry, I misunderstood that.  That's happening because tileMap is a vector of vector<Vector2i>, so if you call tileMap.resize() you need to give it a vector<Vector2i>, not a Vector2i.  If you called tileMap[0].resize() then you would pass it a Vector2i.
Hm. So, how would I resize that part? Using "std::vector<Vector2i(-1, -1)>" isn't valid, obviously. (And doesn't even make any sense.) I need to resize both the rows and columns, though...

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: So, I want to save a tile map.
« Reply #33 on: April 27, 2014, 10:28:50 pm »
Ixrec just mentioned how you should do it... You should really also research such things on your own, there are reference sites like www.cppreference.com that show how std::vector works.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

ineed.help

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: So, I want to save a tile map.
« Reply #34 on: April 27, 2014, 10:31:47 pm »
???

Obviously I understand how to set the default for the columns, but not the rows. Apparently, just using:
void Map::ResizeMap(int _rowAmount, int _columnAmount)
{
        rowAmount = _rowAmount;
        columnAmount = _columnAmount;

        tileMap.resize(columnAmount);

        for (int i = 0; i < columnAmount; i++)
        {
                tileMap[i].resize(rowAmount, Vector2i(-1, -1));
        }

        std::cout << tileMap.size() << "," << tileMap[0].size();
}
... was enough to make it set the default for all unspecified tiles to "Vector2i(-1, -1)", but I don't understand how.

(And of course I have checked around for what std::vector does; the reason I'm here is because I don't understand what it means. :-\ English is not my first language, and I have only taken a VERY basic class in C++ for my eleventh year of school.)
« Last Edit: April 27, 2014, 10:36:33 pm by ineed.help »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: So, I want to save a tile map.
« Reply #35 on: April 27, 2014, 10:38:00 pm »
If there's a specific thing about vectors you don't understand, then ask about that on a general C++ forum.  It is extremely important to understand the basic containers.  If you know very little C++ to begin with, you need to go read a proper C++ book from start to finish before trying to use a library like SFML.

The columns of a matrix contain all the values of the matrix.  The rows also contains all the values.  You seem to be implying that iterating over columns would somehow operate on a completely different set of values than iterating over rows of the same matrix, which makes no sense.  I'm not sure how else to explain that.

ineed.help

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: So, I want to save a tile map.
« Reply #36 on: April 27, 2014, 10:45:25 pm »
If there's a specific thing about vectors you don't understand, then ask about that on a general C++ forum.  It is extremely important to understand the basic containers.  If you know very little C++ to begin with, you need to go read a proper C++ book from start to finish before trying to use a library like SFML.

The columns of a matrix contain all the values of the matrix.  The rows also contains all the values.  You seem to be implying that iterating over columns would somehow operate on a completely different set of values than iterating over rows of the same matrix, which makes no sense.  I'm not sure how else to explain that.
I don't really know what I was thinking, I realized after a while that it made no sense. I thought it would be best to continue asking here, since it involved Vector2i:s.
I guess I'll ask somewhere else if I need help with anything else - thank you very much for your help.