-1

Edit: simple mistake I looked over, and wasn't thinking. Ignore :)

My code brings up the error:

no match for 'operator*' in 'mapRows * width'

on the code

// get the current tile number
  int tileNumber = levelMap[mapRows*width + currentTile];

Declared at:

for (auto& mapRows : levelMap)
        for (auto& currentTile : mapRows)  //It loops through the rows, then goes through all the tiles in that column.
        {

and width at:

bool Map::load(const std::string& tileset, sf::Vector2u tileSize, unsigned int width, unsigned int height)

and levelMap at:

std::vector<std::vector<Tile>> levelMap;

Sorry, just a beginner!

5Mixer
  • 541
  • 4
  • 10
  • 4
    Can we see the declaration of `mapRows` and `width`? – Shoe Oct 11 '14 at 10:54
  • 2
    We want the type of mapRows, so we need to see the declaration of `levelMap` too. But it seems to be a collection so you might want to try `mapRows.size()*width` – PeterT Oct 11 '14 at 10:58
  • 1
    Obviously, whatever `mapRows` refers to, does not have the binary multiplication operator overloaded. See [this FAQ answer](http://stackoverflow.com/a/3350710/140719) of mine to understand when `*` means dereferencing and when it means multiplication. (See [this entry](http://stackoverflow.com/a/4421719/140719) (see "Binary arithmetic operators") on how to overload operators.) – sbi Oct 11 '14 at 10:58
  • @Mixerman123 I have a suspicion that your problem is not just the error. Maybe try to describe what you tried to do since the access doesn't seem to make much sense. – PeterT Oct 11 '14 at 11:03

1 Answers1

2

mapRows appears to be an std::vector<Tile> for which multiplication with an int doesn't make sense. That's what the error is telling you.

Shoe
  • 74,840
  • 36
  • 166
  • 272
  • To be honest I'm not even sure how to correct this because I have no clue as to what you are trying to do with `operator*` there. Nothing related to `mapRows` or `levelMap` makes sense with `operator*`. – Shoe Oct 11 '14 at 11:03
  • @sbi: In 2d game programming, it's pretty common to call the 2d grid of bitmap tiles on which the characters move a map. – Benjamin Lindley Oct 11 '14 at 11:06