Overlapping At Offset - I think I'm using this command wrong..?

0 favourites
  • 6 posts
From the Asset Store
In this game you will command the character by voice command.
  • I'm trying to set up a basic city-builder tile-based game with hexagons, where you can build something on a free hexagon tile and then the game will spawn additional hexagons to build on around that hexagon. So the map will keep expanding as you build.

    To test the framework I've created a hexagon tile, have set it up to turn red when it's considered "built on" (happens on touch/click at the moment), and then want it to spawn additional tiles in all directions that don't already have tiles. And that's the part I'm struggling with. I've tried using the "overlapping at offset" check, inverted, to check for already present tiles before spawning in each possible location, but I must be doing something wrong because it spawns in all directions anyway. Here's a GIF so you can see how the red tiles get covered in new white tiles:

    live.staticflickr.com/65535/51653083952_21c7bc0aec_o.gif

    And below is the event sheet for this process at the moment, so you can see what I'm trying to do with the overlap check. Hopefully someone can point out where I'm being an idiot here, or suggest a better method for choosing whether a tile should be spawned :)

    live.staticflickr.com/65535/51654762645_04c0b3abb0_o.jpg

    EDIT: Sorry, struggling to figure out how to embed images, so they're just links for now...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I might be wrong,

    but basically its checking to see if its not overlapping itself(as its the one being picked on the touch event). Which is true every event.

    There are some tricks around this, but the most easiest verion for my brain that i can think of is to use a function and a invisible collision tile(the same size of the gridbase).

    so,

    on gridbased.touch, call function($name) no need to pass any values.

    on.function($name) set invisible tile position to createx and createy

    invisible_tile is not overlapping gridbase at offsetx and y

    then create object(gridbase) at createx +- offsetx and createy +- offsety

    (repeat event inside function for however many times you need it)

    This should work, someone else might come up with a better solution.

  • I might be wrong,

    but basically its checking to see if its not overlapping itself(as its the one being picked on the touch event). Which is true every event.

    There are some tricks around this, but the most easiest verion for my brain that i can think of is to use a function and a invisible collision tile(the same size of the gridbase).

    so,

    on gridbased.touch, call function($name) no need to pass any values.

    on.function($name) set invisible tile position to createx and createy

    invisible_tile is not overlapping gridbase at offsetx and y

    then create object(gridbase) at createx +- offsetx and createy +- offsety

    (repeat event inside function for however many times you need it)

    This should work, someone else might come up with a better solution.

    Ahhh man, nice idea but it still isn't working =/

    It also gave me the idea to try using families. I created a family for tiles, placed the GridBase object in there, and asked the overlap to check if the targeted object is overlapping anything from the family. And that still didn't work either. Did I get the X/Y values in the overlap checks wrong or something? My head is hurting trying to figure out why this isn't working lol

  • I ended up using a different solution entirely, and simply not using the "overlapping at offset" function.

    I'm spawning the GridBase tiles on one layer (they will be a visual guide for where buildings can be placed), and will be placing building tiles on top of them on a higher layer. I'm then running a check to make sure the function that spawns more GridBase tiles doesn't run if the Touch object is also overlapping a building object. That way, yes, some GridBase tiles will still be created needlessly underneath built tiles, but they won't be visible to the player and (hopefully) won't cause much performance overhead since there are only so many that can be spawned in one place in total.

  • I second the idea of putting the hex sprites in a family. You can call it “other” or something.

    Also the offset you’re using is off. It literally just needs an offset not a full position. Which would look like this:

    On tap hex
    Hex: active = 0
    — set color
    — set active to 1
    — — X hex overlaps other by offset (0, -384)
    — — — create hex at (hex.x+0, hex.y-384)
    ...

    As long as the hexagons have the collision polygon set up well and you’re creating them far enough apart from each other so the collision polygons aren’t touching you should be good.

    Another approach without families would be using the “pick overlapping point” condition.

    Global number createX=0
    Global number createY=0
    
    On tap hex
    Hex: active = 0
    — set color
    — set active to 1
    — set createX to hex.x
    — set createY to hex.y
    — — pick all hex
    — — X pick hex overlapping point(createX+0, createY-384)
    — — — create hex at (createX+0, createY-384)
    ...
  • Here is a slightly different approach.

    Hex

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