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

Author Topic: Question about selbaward's tilemap  (Read 1394 times)

0 Members and 1 Guest are viewing this topic.

CowNation

  • Newbie
  • *
  • Posts: 20
    • View Profile
Question about selbaward's tilemap
« on: May 02, 2018, 09:48:43 am »
Link to source used:
https://github.com/Hapaxia/SelbaWard/wiki/Tile-Map
My tilemap code:
        //TileMap Stuff
        Tiles = ENG::TextureFromFile(&MainWindow, "Data//Images//tileMap.png", "main", false, false, true);
        for (auto& tile : levelData) { tile = rand() % 3; } // pick one of the four available tiles at "random"
        tileMap.setLevel(levelData); // connect level data
        tileMap.setLevelWidth(Engine::windowSize.x); // width of 125 means that the level data gets processed as if it is 125 x 80
        tileMap.setSize({ 1280, 720 }); // size of tile map's rendered image
        tileMap.setGridSize({ 40, 24 }); // size of tile map grid (number of tiles)
        tileMap.setTexture(Tiles);
        tileMap.setNumberOfTextureTilesPerRow(3);
        tileMap.setTextureTileSize({ 64, 64 }); // actual size of tiles within the texture
        tileMap.setPosition(MainWindow.mapPixelToCoords(Vector2i(0, 0)));
        tileMap.update();
        window->draw(tileMap);
        //TileMap Stuff
what it draws:
https://i.imgur.com/LZiFJgB.png
it only randomly selects the first 7 rows
my tilemap:
https://imgur.com/a/lKJk3SX
I'm not understanding what setSize & setGridSize & setLevelWidth do.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Question about selbaward's tilemap
« Reply #1 on: May 07, 2018, 03:14:50 pm »
Hi.

My first question would have to be: are you sure that your level has 10,000 cells (125x80) and not around 800 (this would show 125x7)?

My second question would then have to be: are you sure that Engine::windowSize.x is the width of the level in cells (125, is it?) and not the width of the level in co-ordinates or the width of the window?

With those out of the way, let me attempt to clarify what those three things do:
  • setLevelWidth
    Specifies the number of cells from left to right in the map.
  • setSize
    Specifies the final visual size.
  • setGridSize
    Specifies how many grid cells can fit inside that final visual size. That is, how many cells can be seen; the visual size is divided by this size to get the cell size.

According to your code, you seem to have setup these three things correctly :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*