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

Author Topic: Tile Map Example Help  (Read 3408 times)

0 Members and 1 Guest are viewing this topic.

masterassassin1398

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Tile Map Example Help
« on: November 06, 2014, 11:23:25 pm »
Hi guys.  I need some help.  Im trying to make a tile map game, using sfml.  Currently i am using sfml 2.1, the designing entities with vertex arrays tutorial for tile maps is really confusing for me.  I was wondering if anyone could break it down for me.  I know its a lot of work but it would be extremely helpful.  Thanks in advance.
« Last Edit: November 06, 2014, 11:47:52 pm by eXpl0it3r »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Tile Map Example Help
« Reply #1 on: November 06, 2014, 11:26:37 pm »
If you could ask some specific questions about that example then we could help.

Have you tried building and running the example yourself?  Have you stepped through it in a debugger to see what's actually in the vertex array and how it got there?
« Last Edit: November 06, 2014, 11:28:32 pm by Ixrec »

masterassassin1398

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Tile Map Example Help
« Reply #2 on: November 07, 2014, 11:18:10 pm »
No i havent tried running it myself.  I figured that i would need the texture for the tiles.  I will go ahead and try though.  Overall i dont have anything specific i am curious about.  I just need a more detailed walkthrough than what is offered.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Tile Map Example Help
« Reply #3 on: November 14, 2014, 01:40:04 am »
If you need tiles to use for the example and you are talking about the one in the Vertex Array tutorial, feel free to use these simple tiles:


The tilemap is stored as a one dimensional array of tile indices - each one represents which tile should be displayed. These tile are lay out from left to right but split every few tiles and moves down to the next row and starts the columns from the left again. It's a lot like typing/text wrapping.
The vertex array is just a list of all the vertices that hold the co-ordinates for all four corners of each tile.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

wh1t3crayon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
Re: Tile Map Example Help
« Reply #4 on: November 14, 2014, 04:54:32 am »
Why are you using vertex arrays for tiles? You're guranteed to only have squares, so sf::RectangleShape might simplify things.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Tile Map Example Help
« Reply #5 on: November 14, 2014, 06:40:59 am »
Except RectangleShapes are horribly inefficient compared to VertexArrays.

1 draw call vs width * height * z-indices or so of your map draw calls.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Tile Map Example Help
« Reply #6 on: November 14, 2014, 08:19:16 am »
Why are you using vertex arrays for tiles? You're guranteed to only have squares, so sf::RectangleShape might simplify things.

This thread is about the tile map example in the tutorials, which is all about using a vertex array with a spritesheet so that you can draw the entire tile map in one draw() call, since that's more efficient than using a separate draw() for every tile.

Using sprites or rectangle shapes for every tile probably is simpler, but vertex arrays exist because this is a common and worthwhile optimization (assuming you have a lot of tiles).

 

anything