How do I check check if a tilemap is overlapping another tilemap

0 favourites
  • 9 posts
From the Asset Store
Enchanted Forest & Cave 16x16 Tilemap with Environment Sprites
  • i want to check overlapping tile maps, and mix the array stored in them.

    there isnt a tilemap is overlapping event.. any ideas?

    i could just use sprites. im thinking of storing array data in a tile map.. may not use it.. but it will leave me with options if i cant save array data to a json and call it for a tilemap

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If both tilemap are the same size and at the same position with the same tile size then you could loop over all the tiles on one and see if there is a tile on the other. If both tilemaps have a tile at the same position then stop the loop since they are colliding.

    If position, size or tile size differs between the two then it would just become more involved. Worst case you’d take each tile of one and compare the bounding boxes of each tile of the other. But there are likely lots of ways you can reduce the amount of checks needed. Even so, it will be slow with a lot of checks.

  • they wont be overlapping each other exactly ( tiles will)

    the main floor tile map will store individual tiles into an array. so. in the array it will say exactly where the rooms are... but.. to extrapolate that data...

    like dungeon keeper. a 3x3 room is more efficient than a 2x2 room. so ill need to know how big the rooms are... and merge them when enlarging them.

    just looking for an efficient way to do this.

    ive gone through many ideas. and this seems to be working the best.

    youtube.com/watch

    is where im at. im spawning in tile maps. its just an example. and i was about to do buttons for difforent rooms.

    maybe ill try using sprites. they will be invisible. its for pathfinding, pick nearest "room" where it isnt at full capacity. then pick unused tile

  • so.. really. if i just clicked on the floor, build 1 tile. then click next to it, build second tile, i could just use the array.. to .. go through all tiles. on tileroomtype=1 then check right and down. if its value is also 1, keep checking to get room width and height.

    hmm.. i tried that first. but i was trying to directly manipulate the room tilemap to accomodate new blocks. i could just erase all instances of that room type. and make a new one.

    dificulty is checking down... ill givbe it a shot

  • Do you want the small tilemaps merged into a third tilemap just big enough to combine the two? Or do you want to just draw them onto the main tilemap that covers the layout?

    What is the array you mention for? Tilemaps can already be thought of an array of tiles so using an array too seems redundant and overcomplicate things.

  • yes, 2 small tile maps should create a larger tilemap on top of them. ideally then destroying the smaller ones.

    then repeat when a new tilemap is created; they should merge once more.

    This should always have a big room, but can have many rooms also.

    what is the array for.. well sir, thats a very good point. mostly as i can do a search in an array easily. for eachxy element. i havent seen an obvious way to do that in the tilemap to go through each tile.

    on my newest test project. im attempting single tile build where the room (instead of checking mutiple tilemaps overlapping) will have a loop in the array to find a grouping!.

    click button to set room type. click tile to place the square. save all squares into the array.

    THEN/NOW im currently trying to get it to go through the array to the first result thats "1" (specific room) and run a loop to check the next tile. then the next tile until a tile isnt "1".

    i can make a tilemap/sprite and set its width based on this. (tilemaps idealy. as i planned to set their tiles to match the actual tiles. so A.finding the room will be exact. B. like dungeon keeper, i can have a fire around the edge using flood. i can set its colour to who owns it.)

    so, each time a room of a type is built: i will just delete all tilemap/sprites, that have this room type, and create a new one when a new tile is placed.

    does this sound..efficient/..possible? i did look up grouping within array examples, nothing stood out.

    really. i will just brute force out something that can work out room location and size.

    any help, conversation, thoughts, or obvious solutions are massively apprieciated.

    I work on c3 for 5 hours. go work. come home and keep going. so, where i am advances.

    cheers ROJO sorry its so much. exactly what i want changes. its just the overall concept i need help with lol

  • {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"for-each-element","objectClass":"Array","parameters":{"axes":"xy"}}],"actions":[],"children":[{"eventType":"variable","name":"saved","type":"number","initialValue":"0","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[{"id":"compare-current-value","objectClass":"Array","parameters":{"comparison":0,"value":"4"}}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"while","objectClass":"System"},{"id":"compare-at-xy","objectClass":"Array","parameters":{"x":"Array.CurX+saved","y":"Array.CurY","comparison":0,"value":"4"}}],"actions":[{"id":"add-to-eventvar","objectClass":"System","parameters":{"variable":"saved","value":"1"}}],"children":[{"eventType":"block","conditions":[{"id":"compare-at-xy","objectClass":"Array","parameters":{"x":"Array.CurX+saved","y":"Array.CurY","comparison":1,"value":"4"}}],"actions":[{"id":"stop-loop","objectClass":"System"},{"id":"create-object","objectClass":"System","parameters":{"object-to-create":"Tilemap","layer":"0","x":"0","y":"0","create-hierarchy":false,"template-name":"\"\""}},{"id":"set-width","objectClass":"Tilemap","parameters":{"width":"saved-Array.CurX"}}]}]}]}]}]}

    oof. i hate this. but thats the code to check so far. 2 events for all that... only items are tilemap and array. if you want to see what im thinking. need to loop here

  • its not in the right place, and its a sprite not a tilemap.... and it doesnt remove the existing sprite but it is working for width

  • ive got it so is makes a sprite that covers the tiles... but.. its always 1 tile behind..

    youtu.be/NBknuBtj8A0

    no matter what i do fiddeling with the numbers. but. im burn out. time for a break

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