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

Author Topic: An Hexagon Rect  (Read 2970 times)

0 Members and 1 Guest are viewing this topic.

lockandstrike

  • Newbie
  • *
  • Posts: 32
    • View Profile
An Hexagon Rect
« on: November 17, 2013, 02:17:38 pm »
Okay so I've seen the Rect.inl file and understood what was going on for the rect/squares but because I'm in 8th grade I don't know how to do the same for an hexagon, I just don't know the mathematical form for it. So if someone could guide me through it.

Lots of thanks, lockandstrike

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: An Hexagon Rect
« Reply #1 on: November 17, 2013, 02:26:32 pm »
What do you exactly want to achieve? The term "hexagon rect" doesn't make any sense, these are two distinct shapes.

Have a look at trigonometry and basic vector algebra, after that computing the coordinates of hexagons is not difficult. But it will require you some time to read through those topics, you can't just ask here and expect an answer "that's how it works". If you don't know where to look, Wikipedia is a good start.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

lockandstrike

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: An Hexagon Rect
« Reply #2 on: November 17, 2013, 02:43:45 pm »
As to the title I had anticipated that sort of response what I'm looking for is something of the like of
Hex<T>
.

The problem is in the 8th grade (at least in my country) the only thing were taught in terms of geometry is how to draw triangles using the compass. I'll study those subjects, but I would be very happy if could just give me a hint.

Lots of thanks, lockandstrike

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: An Hexagon Rect
« Reply #3 on: November 17, 2013, 02:49:53 pm »
Hex<T>
That doesn't mean anything. What do you expect from such a class?

Most of us weren't taught programming or some parts of math in school, that doesn't mean one can't go lend a book or search online on these topics and teach them yourself. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lockandstrike

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: An Hexagon Rect
« Reply #4 on: November 17, 2013, 04:50:18 pm »
Ok you have the
Rect<T>
class and what I want is the same but for an Hexagon. That is, a class that allows me to check if a vector is contained inside an hexagon instead of it checking if it is contained inside of a rectangle like with the Rect class

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: An Hexagon Rect
« Reply #5 on: November 17, 2013, 04:58:33 pm »
So what you really want is just a collision check function for point-inside-hexagon, why don't you just say that? ::)

The main purpose of sf::Rect<T> is to represent a rectangle through it's position and size. The "collision" functions are just some optional goodies.

Have you tried googling? For instance you could use the keywords: "point in hexagon" :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: An Hexagon Rect
« Reply #6 on: November 17, 2013, 05:09:08 pm »
There are many things to consider when using hex based maps. One of the best resources I have ever found on hex based maps can be found here.

http://www.redblobgames.com/grids/hexagons/
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

 

anything