Custom Grid Shape

This forum is currently in read-only mode.
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • 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: <img src="http://www.math.grin.edu/mcm-2000-problem-b.jpg" border="0" />

    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.

  • 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

  • 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.

  • 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 <img src="smileys/smiley36.gif" border="0" align="middle" />)

    Now I'm curious to see if I can get to to move the right way. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thanks, it worked just like you said. Sorry for the late reply. I have been busy working on this and some other construct stuff.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)