Hexagon, Square or Circle
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
Comments
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
What does 'get all the points of a hexagon' mean ?
@Socks I think he means "determine the coordinates of each vertex."
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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 ?
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
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
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.
Absolutely, you can't really say much without knowing the nature of the game.
@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?
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
Yep, a hexagonal grid simply requires to you move at a fixed distance at an angle divisible by 60°.
Agreed, and they don't even need to be hexagons, they could be square or circular.
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.
That makes perfect sense now that I see the board as a series of actors
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
Numerous ways, it would all depend on what you are trying to achieve.
@tatiang @Socks Thank you. I truly enjoy learning all you guys have to teach!
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.
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
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.
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
Don't know what that means
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.
@Socks Thanks for the clarification, i did not know that.
Fortuna Infortuna Forti Una
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.
@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.
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 !
Mathcraft. Trig-o-gnome-atry?
Reported to the International Criminal Court (math-pun department), expect a knock on the door.
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 !
@CodeMonkey
So if it were an octagon, it would be sqrt(4)...?
Decagon at sqrt(5)...?
Or does the pattern not follow?
Mathtap.com (Android) | Fridgemanager.com (Android) | Breakoutofspace.com (Android)