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

Author Topic: Hexagonal tile map  (Read 2652 times)

0 Members and 1 Guest are viewing this topic.

Guardian

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hexagonal tile map
« on: February 10, 2017, 10:38:51 pm »
Hi all,

I'm new with SFML and I'm trying to learn how to make an hexagonal tile map.
I can't understand what primitive type I should use to draw a hexagon?

I've already thought to use a series of Triangle but if I do that I won't be able to set the correct texture to the tile.

Someone can help me?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Hexagonal tile map
« Reply #1 on: February 11, 2017, 02:03:39 am »
You can draw anything* with triangles.

You can draw a hexagon simply (in a fan) with six triangles although you can actually draw one with just four.

Why can you not set the texture correctly? Just set the texture co-ordinates to match the points of the texture that they should.

*to a reasonable degree
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Guardian

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Hexagonal tile map
« Reply #2 on: February 11, 2017, 09:04:43 pm »
Ok. I found the way to do that with Triangles. Thanks for your answer.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Hexagonal tile map
« Reply #3 on: February 11, 2017, 11:29:11 pm »
You're very welcome. Hope it becomes an awesome game! :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Toreno96

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Hexagonal tile map
« Reply #4 on: February 20, 2017, 03:31:55 pm »
Why not use a sf::CircleShape instead as shown in the official shapes tutorial?

PS. It's my first post so hello everyone :) Yes, the above was bothering me so much, that I immidiately registered xD
« Last Edit: February 20, 2017, 03:58:27 pm by Toreno96 »

 

anything