Custom Grid Shape

For questions about using Classic.

Post » Sun Jul 08, 2012 12:33 am

I'm here with another random question.

Is there a way to create a gird with a special shape around a center point in the event sheet editor?

I want to make an isolated hex grid in a hexagon shape like this:

Also I'm trying to make it as flexible as possible (changing size, number of grid spaces and so forth that's why I trying to make it in the event sheet editor)

I think making it out of individual hexagons objects will take care of isolation issue.

My second question is is there a way to have that grid rotate around a center point? Kind of like how some computer board games allow you to rotate the board.
B
3
Posts: 59
Reputation: 418

Post » Tue Jul 10, 2012 6:58 pm

Here's an example:
http://dl.dropbox.com/u/5426011/examples12/hexgrid2.cap

The global 'w' defines how many hexagons per side.
The individual hexagon size is defined by the sprite size.

I got the 2d rotation from here:
http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Wed Jul 11, 2012 4:14 am

Wow thanks.

This was driving me crazy. Although when I look at it, it looks so simple I feel kind of stupid that I couldn't figure this out.

Thanks again. I should be able to modify it to work on a click a drag.
B
3
Posts: 59
Reputation: 418

Post » Wed Jul 11, 2012 5:22 am

I pretty much understand how this works now. While I was playing around with it, I got some interesting results to say the least.

It appears this doesn't work well with dynamically changing positions.
meaning I set the code so the center point was an object with an 8-way behavior and the gird wouldn't stay on it. Instead it would group together and orbit the object. (great fun trying to get it be center again )

Now I'm curious to see if I can get to to move the right way.
B
3
Posts: 59
Reputation: 418

Post » Mon Jul 16, 2012 4:45 am

Ok.So I have grid down.

Now I've run into the issue of figuring out a way of snapping moving/movable objects to each space and preventing that space from being used by more than one object.
B
3
Posts: 59
Reputation: 418

Post » Mon Jul 16, 2012 6:52 am

For the snapping you could do something like this:

for each object
pick grid closest to (object.x, object.y)
-- set object position to grid


For making a grid hold only one object you could add a variable to the grid objects to store the UID of the object that's on it. UIDs start at 0 so you could use a value like -1 to indicate the grid is empty.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon Jul 23, 2012 2:17 am

Thanks, it worked just like you said. Sorry for the late reply. I have been busy working on this and some other construct stuff.RandomDood2012-07-23 02:17:56
B
3
Posts: 59
Reputation: 418


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests