Hexagon, Square or Circle

DocJDocJ Member Posts: 66

This might make a lot of sense to some of you, but I'm trying to understand it and can't find anything on it.

I've been looking at other apps to see how things are laid out, and I've noticed a trend in some of the board games out there. It seems like Hexagonal tiles were the go-to way of designing a board game. I have seen some with circles, and some with squares, but the majority had hexagons (Ancient Chronicles, New World Colony, etc...)

Now, my inexperienced GameSalad mind has me thinking a board game relies on coordinate positioning for "tiles". If that is the case, how does a hexagon board game lay out? Wouldn't that be too difficult to get all the points of a hexagon?

I guess I must first ask; is a board game tile based on x,y coordinates?

Thanks. Just curious.
Doc

«1

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Well, everything in GameSalad is based on x,y coordinates so I suppose the general answer is yes. Hexagons are certainly more challenging to work with than squares or even circles. I think the reason they are popular is because they are more interesting and flexible than squares/circles (a square has four possible intersections with other tiles while a hexagon has six).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @DocJ said:
    Now, my inexperienced GameSalad mind has me thinking a board game relies on coordinate positioning for "tiles". If that is the case, how does a hexagon board game lay out? Wouldn't that be too difficult to get all the points of a hexagon?

    What does 'get all the points of a hexagon' mean ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks I think he means "determine the coordinates of each vertex."

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @tatiang said:
    Socks I think he means "determine the coordinates of each vertex."

    Ah, I see (I think !?)

    That's not difficult, depending on the orientation of the hexagonal grid - and assuming each hexagon is a separate actor then each point will be 60° apart, but I can't imagine why you might need this kind of information ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks said:
    but I can't imagine why you might need this kind of information ?

    I can't either. If you're making a board game with hexagonal tiles that move along 60° paths to other hexagonal tiles, I'm not sure why you would need to know where the edges of those tiles are. But I suppose it depends on the type of game.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • DocJDocJ Member Posts: 66

    You know, the more you guys explain things, the more I begin to think....."that was a dumb question". LOL.

    @Socks @tatiang You guys make a lot of sense regarding the layout of any board game. I never thought of the board as separate actors. I figured it as some sort of "table" or "grid". Now I see the light. And that seems to make more sense when a "token" going along the "board" "overlaps" another actor.

    I knew you guys could answer it easily. There just wasn't much info on the forums for board games.

    Thank you so much, again.
    Doc

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @DocJ said:
    Now I see the light. And that seems to make more sense when a "token" going along the "board" "overlaps" another actor.

    If the goal is to determine the position of a token, then the shape of the permitter is pretty much irrelevant, a grid of hexagons is just a standard grid with every other row/column offset by half the distance between rows/column. The grid could be circles or squares or McDonald's logos or diamonds or tiny spots and the positioning of elements would be the same as if the individual grid elements where hexagons . . . .for example image a grid of hexagons, now mentally superimpose small diamonds in the centre of each hexagon, now mentally image the hexagons fading away so you are just left with a grid of diamonds, there is nothing innately hexagonal about this grid of diamonds yet the pattern is identical to a hexagonal grid, hope that makes sense.

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    But I suppose it depends on the type of game.

    Absolutely, you can't really say much without knowing the nature of the game.

  • DocJDocJ Member Posts: 66

    @socks @tatiang so, I think my thinking is straightened out now.....somewhat.

    A board game is just a "grid" of actors. If, say like in a game of monopoly for example, the "token" actor lands on the "game board" actor, it's really just a rule looking to see if the actors overlap.

    But I guess in a way, you would still need to know x,y coordinates, but not for the "board game" actors, but rather for the "token" actors. How else would a "token" actor know which way or how far to move, other than by a rule dictating direction and distance (x,y coordinates)? I mean you don't set a rule saying "move 5 actors left", do you? I wouldn't think GameSalad understands that kind of language.

    And so, going back to the original question, if you have to design a rule to determine which way and how far a "token" actor has to move, I see now where the shape of the "board game" actor is irrelevant. because once the "token" actor is moved, it's just a matter of rules to see if they collide or overlap.....correct?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    To know where to move, you need to know the grid spacing and angle of movement but not necessarily the coordinates of each board game square/hexagon.

    To check for collisions, you would use a Collides or Overlaps With condition. The actors do not need to know the coordinates of other actors to check this.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    To know where to move, you need to know the grid spacing and angle of movement but not necessarily the coordinates of each board game square/hexagon.

    Yep, a hexagonal grid simply requires to you move at a fixed distance at an angle divisible by 60°.

    @tatiang said:
    To check for collisions, you would use a Collides or Overlaps With condition. The actors do not need to know the coordinates of other actors to check this.

    Agreed, and they don't even need to be hexagons, they could be square or circular.

    @DocJ said:
    A board game is just a "grid" of actors.

    That would entirely depend on what you are trying to acheive and how you go about achieving it - there are no really fixed or correct ways of working in GameSalad, give two people the same task and they will probably come up with two entirely different ways of doing it.

  • DocJDocJ Member Posts: 66

    @tatiang said:
    To know where to move, you need to know the grid spacing and angle of movement but not necessarily the coordinates of each board game square/hexagon.

    To check for collisions, you would use a Collides or Overlaps With condition. The actors do not need to know the coordinates of other actors to check this.

    That makes perfect sense now that I see the board as a series of actors

    @Socks said:
    That would entirely depend on what you are trying to acheive and how you go about achieving it - there are no really fixed or correct ways of working in GameSalad, give two people the same task and they will probably come up with two entirely different ways of doing it.

    Is there another way of making a "board" other than a series of actors?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @DocJ said:
    Is there another way of making a "board" other than a series of actors?

    Yep. The board could be a single image and all of the rules check to see if an actor is at a precise point along some set path(s). So if you calculated all of the centers of the hexagons and put them in a table, you could check to see which hexagon your player actor is in. That wouldn't require collisions at all. It's not necessarily a better method, just an alternative.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @DocJ said:
    Is there another way of making a "board" other than a series of actors?

    Numerous ways, it would all depend on what you are trying to achieve.

  • DocJDocJ Member Posts: 66

    @tatiang @Socks Thank you. I truly enjoy learning all you guys have to teach!

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    On a side note: I was thinking about how to do 'hexagonal moves', you could just click in the direction you wanted to move and use this to move one position . . . .

    radius *cos ((round(( vectorToAngle( mouse X - self X, mouse Y - self Y )) /60) *60)%360)
    radius *sin ((round(( vectorToAngle ( mouse X - self X, mouse Y - self Y )) /60) *60)%360)

    . . . those two lines could be a change attribute behaviour or even two interpolate behaviours, but basically you click on a hexagon adjacent to your current position and you will jump (or slide) to your new position.

    I'll stick it into GameSalad later and see if it works, but it should, it just finds the angle between your current position and the mouse click, then quantises that angle to the nearest 60° - and then moves a certain distance (the 'radius') in that direction.

  • SocksSocks London, UK.Member Posts: 12,822

    @DocJ said:

    Example file, click in the direction you want to move (file attached)

  • LovejoyLovejoy Member Posts: 2,078

    @Socks said:
    Example file, click in the direction you want to move (file attached)

    Great project. Having that mouse button up rule in the token actor breaks the movement when tapping too fast. Just remove it, its unnecessary.

    Fortuna Infortuna Forti Una

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @Lovejoy said:
    Great project. Having that mouse button up rule in the token actor breaks the movement when tapping too fast.

    In theory you cannot tap too fast as I've used a gate that waits for the movement to finish before it allows another move.

    @Lovejoy said:
    Just remove it, its unnecessary.

    It's there for a reason, remove it and keep your mouse held down and see what happens ! ;)

  • LovejoyLovejoy Member Posts: 2,078

    @Socks said:
    It's there for a reason, remove it and keep your mouse held down and see what happens ! ;)

    Yeah i just noticed that, it can work on certain projects as well. Great alternative.

    What's with self.gate 0 and 1. Isn't it a boolean? or am i missing a socks magic trick?

    Fortuna Infortuna Forti Una

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @Lovejoy said:
    Yeah i just noticed that, it can work on certain projects as well. Great alternative.

    Don't know what that means :/ :)

    @Lovejoy said:
    What's with self.gate 0 and 1. Isn't it a boolean? or am i missing a socks magic trick?

    No, nothing special, just a boolean like you say, you can use 0 and 1 on booleans, or even some maths as long as the maths produces 0 or 1.

  • LovejoyLovejoy Member Posts: 2,078

    @Socks Thanks for the clarification, i did not know that.

    Fortuna Infortuna Forti Una

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @Lovejoy said:
    Socks Thanks for the clarification, i did not know that.

    Yeah, it might be useful in a situation like this . . .

    Change game.boolean to game.score/10

    (if your score is ten you have just changed the boolean to true).

    Beyond that I just use 0 and 1 because I am too lazy to type out 'true' and 'false' over and over again.

  • DocJDocJ Member Posts: 66

    @Socks I finally had a chance to delve into your example and wrap my head around the rules (don't you just hate when work gets in the way of GameSalad). Great example and explanation of hexagonal movement.

    Again, I thank you and @tatiang for all the explanations. I'm glad I started this in the Community Tutorials because I'm sure there are many people who could benefit from the knowledge you guys have offered.

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    edited May 2015

    Here is an example of a hexagon tile in case you want something to check if you clicked within the tile.

    I use the same thing with the Hex Words template.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @CodeMonkey said:
    Here is an example of a hexagon tile in case you want something to check if you clicked within the tile.

    I use the same thing with the Hex Words template.

    "floor( self.Size.Width /4) *sqrt(3)/cos(( self.Angle %60)-30)"

    Cool witchcraft !

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    edited May 2015

    @Socks said:
    "floor( self.Size.Width /4) *sqrt(3)/cos(( self.Angle %60)-30)"
    Cool witchcraft !

    Mathcraft. Trig-o-gnome-atry?

  • SocksSocks London, UK.Member Posts: 12,822

    @CodeMonkey said:
    Mathcraft. Trig-o-gnome-atry?

    Reported to the International Criminal Court (math-pun department), expect a knock on the door.

  • SocksSocks London, UK.Member Posts: 12,822

    @CodeMonkey said:
    floor( self.Size.Width /4) *sqrt(3)/cos(( self.Angle %60)-30)

    I was trying to get my head around this idea, and after a lot of thought (and some red wine) it's slowly starting take hold ! The sqrt(3) part confused me, but working my way from the sqrt(2) (for a square) it's now starting to make sense, I can slowly see a hexagon emerging, I'm not quite there yet, but really clever stuff anyhow, you should become a programmer with those kinds of skills ! :wink:

  • SummationSummation Member, PRO Posts: 476
    edited May 2015

    @Socks said:
    I was trying to get my head around this idea, and after a lot of thought (and some red wine) it's slowly starting take hold ! The sqrt(3) part confused me, but working my way from the sqrt(2) (for a square) it's now starting to make sense, I can slowly see a hexagon emerging, I'm not quite there yet, but really clever stuff anyhow, you should become a programmer with those kinds of skills ! :wink:

    @CodeMonkey

    So if it were an octagon, it would be sqrt(4)...?
    Decagon at sqrt(5)...?

    Or does the pattern not follow?

Sign In or Register to comment.