I need someone whos good at Math

Get help using Construct 2

Post » Wed Nov 11, 2015 4:47 pm

So my issue is im trying to make a hexagon grid snap in game.. so ive searched and found one which works on a flat orientated hexagon... the problem is mine is pointy orientated hexagon(the point of the hexagon is at the top). so i tried googling it and tried finding formulas but i dont understand them so please can someone tell me what my formula should be..

so the size of my hexagons are 60,70

and the code i have found for the FLAT orientation is;

On drag drop
- set x to round(4*(Touch.X - 320)/(3*self.Width))
- set y to round((Touch.Y - 280) / self.Height - self.X / 2))
- set position to (self.Width*self.X *3/4 +320 , self.Height*(self.Y+self.X/2) + 280)

I dont understand this at all so can someone whos good a math please tell me what my formula would be for a pointy orientated 60,70 hexagon?

Thank you.
B
7
S
1
Posts: 54
Reputation: 527

Post » Wed Nov 11, 2015 9:19 pm

Hi,

Perhaps I can help, but I did not understand exactly what you are aiming for. A snapshot or an example image may help.

Correct me if I am wrong, the formula you have is of a hexagon with flat sides on top/bottom, whereas, you need a similar formula for a hexagon which is rotated 30° (which will make the hexagon's flat sides on right/left)

Also, by 60/70 do you mean, its radius of 60 and 70 ?
B
10
S
2
Posts: 109
Reputation: 982

Post » Wed Nov 11, 2015 9:37 pm

Yes that is correct.
This is an image which is similar to my hexagons except the 60,70 which i was referring too is the width and height of the object in pixels.

Image
B
7
S
1
Posts: 54
Reputation: 527

Post » Wed Nov 11, 2015 9:48 pm

Couldn't you just flip everything?
switch width and height in the equations. As well as the x and y's?
So maybe this?

On drag drop
- set x to round((Touch.x - 280) / self.width- self.y / 2))
- set y to round(4*(Touch.x - 320)/(3*self.height))
- set position to (self.width*(self.x+self.y/2) + 280, self.height*self.y *3/4 +320)
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Thu Nov 12, 2015 1:51 am

Ye I thought it would as simple as that but it completely messed it up so I don't think it works like that unfortunately
B
7
S
1
Posts: 54
Reputation: 527

Post » Thu Nov 12, 2015 3:18 am

Look here for everything about hexagon grids (all kinds). You should be able to do what you want refering to that.
http://www.redblobgames.com/grids/hexagons/
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests