0 Favourites

How do I Generate Hexagon

  • Hello, Ive been trying to do this on my own, but I had no real results. I am trying to make a generator that makes hexagon made out triangles. I want to make it like this: if i would make value of some global variable like 2, it would generate 2 layers of triangles, making hexagon, as in this picture

    Its kinda hard to explain, but I have made this "generator", but the process is controlled manually, if you're interested you could look at it

    datafilehost..com/d/5e063ea6 (remove 1 dot, since i cant post urls, sorry)

    If someone could help me with this it would be great

  • Several weeks ago I made rectangles consist of 8 triangles arrange them by using loop 'for'. What you are trying to build isn't too far from my case. Basically it's kind of arithmetic & geometry things we need to figure out. I'll give a try to solve your quest (hopefully).

    Let's give a shot:

    A hexagon consist of 6 triangles. 2nd layer of perimeter is an increment from the core.

    Think about this;

    - each triangles of 'core' creates 3 more triangles outside to make 2nd layer

    - same rule for 3rd layer but with more increment with 5 more triangles

    - see? The increments was simple arithmetic, 1,3,5, ..and you can guess next increments

  • Thanks, Ill try it out, just one quick question, how can I add an action that is executed as soon the loop is over?

  • 'trigger once' should do the trick.

    While I'm spend time working the generator, here is visual guide to start with:

  • Thanks, I can generate half of the hexagon, but I don't want to generate to other side, just copy it and rotate it.

    My question is how can I rotate all objects as one

    Edit: Never mind, played around with rotate and pin, the trick was to use rotate clockwise not set angle

  • Now I have new problem, I use UID to spawn sprites for hexagon. Everything works perfect, but if i place something in like text box, everything goes wild. And if i delete text box afterwards it still gets bugged out. But if I load previous save(where I have not placed text box) it works again...

  • In my experience, I'm less using UID. I prefer IID since they are update dynamically on runtime.

    Allright I made the hexa_tris generator. Try to compare it with yours.

  • Well, I am using construct 2 for about a week now, so I do everything by flat logic. Here's what I made.

    I think the main thing that is different from your generator is that I use flipped triangles instead of rotated, because my goal is to make the game pixelated and if i rotate triangle it becomes screwed up...

  • Is it possible to save generated hexagon, and load it afterwards, without any generating?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Funny, my first attempt was make the triangles flip. I believe it is not too difficult lo load what has been generated before by retrieve data from stored information in text format.

    Will dig into this, or you can search the topic in forum first.

  • Well I have looked a bit around. What I want is to save a generated hexagon to a file and then load it, but I cant seem to find topic on that. What would be the keywords on such topic?

  • Simple way to do that:

    select all the object one by one except the triangle object and set the behaviour to 'NoSave' then create save trigger event (clicked button for example)

    system | save game from slot "you_name_it" after you generate the objects

    That's will store all the triangles object that appear on stage

    To load them:

    create a trigger then add:

    system | load game from slot "you_name_it"

    tested guarantee

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