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

Author Topic: Setting a tilemap into a vertex array  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

wojo1086

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Setting a tilemap into a vertex array
« on: December 20, 2013, 12:26:41 am »
I am familiar with C++, but a completely new to SFML. I've read through the tutorials for SFML here on this site, but I still can't seem to grasp hold of the tilemap to vertex array section. The example this site uses only uses a 2x2 tilemap and then they use quad to store the 4 coordinates into the vertex array. I can manipulate the tutorial to make it display a 2x2 tilemap that I have. However, how would I load a bigger tilemap into a vertex array? Would I still use quad? Or, is there a way to divide a sprite tilemap into specific pixel sizes and then store them into a multidimensional array?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Setting a tilemap into a vertex array
« Reply #1 on: December 20, 2013, 07:45:19 am »
2x2 is not special. The same code would work with 5x5 or 40x40.
Laurent Gomila - SFML developer

wojo1086

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Setting a tilemap into a vertex array
« Reply #2 on: December 20, 2013, 06:26:48 pm »
Hmm...but what, in the tutorial code,  would need to be changed in order to accommodate a bigger tilemap? I tried adding quads[4]-[7], but it didn't quite work out how I imagined it would. Also, if I use quad, when it comes to stating the four corners, would it be the four corners of the tilemap or of the individual tile?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Setting a tilemap into a vertex array
« Reply #3 on: December 20, 2013, 07:17:14 pm »
Nothing needs to be changed (except the "2"). The quads represent the final tiles, the number of tiles in the tilemap only change the texture coordinates of the vertices.
Laurent Gomila - SFML developer

 

anything