SFML community forums

Help => Graphics => Topic started by: Guardian on February 10, 2017, 10:38:51 pm

Title: Hexagonal tile map
Post by: Guardian 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?
Title: Re: Hexagonal tile map
Post by: Hapax 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
Title: Re: Hexagonal tile map
Post by: Guardian on February 11, 2017, 09:04:43 pm
Ok. I found the way to do that with Triangles. Thanks for your answer.
Title: Re: Hexagonal tile map
Post by: Hapax on February 11, 2017, 11:29:11 pm
You're very welcome. Hope it becomes an awesome game! :)
Title: Re: Hexagonal tile map
Post by: Toreno96 on February 20, 2017, 03:31:55 pm
Why not use a sf::CircleShape instead as shown in the official shapes tutorial (http://www.sfml-dev.org/tutorials/2.4/graphics-shape.php)?

PS. It's my first post so hello everyone :) Yes, the above was bothering me so much, that I immidiately registered xD