How do I add wall around island?

0 favourites
  • 5 posts
From the Asset Store
Kids Game
$24.50 USD
50% off
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Hi all, please help.

    How add wall around island? How to prevent the wall from being 2x 3x ... in one place?

    dropbox.com/s/rezshkfxm744qke/island_wall.c3p

    Tagged:

  • You either set it up to only create the sprites if the space is free or remove the duplicates after.

    One way is to use an array to keep track of occupied spaces.

    start of layout
    — set array size to 1000,1000,1
    — for each island
    — — array set at island.x/16, island.y/16 to 1
    — for each island
    — — array at island.x/16+1, island.y/16 = 0
    — — — create wall at island.x+16, island.y
    — — — set array at wall.x/16, wall.y/16 to 1
    … same for other directions

    You could also use a tile map instead of the sprites for similar results. Probably could end up simpler.

    Another idea is to clean up the duplicates after.

    start of layout
    For each island
    — create wall at island.x+16, island.y
    — …other directions
    
    Start of layout
    Wall overlaps island
    — destroy wall
    
    Start of layout
    Repeat wall.count times
    Wall: x=wall(loopindex).x
    Wall: y=wall(loopindex).y
    Repeat wall.pickedCount-1 times
    Pick random wall instance
    — destroy wall
    

    At least those are two methods. Another could be to store xy pairs of created walls in a dictionary and check if a location is listed before creating.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice idea thank you :) I try delete duplicates but, still have bug in code :(

    my result

  • Events are a bit quirky. Here's a slight variation.

    dropbox.com/s/vivuxtpf99f5o5r/red_around_green.capx

    Also from my knowledge of how picking works your events shouldn't be working, and didn't test as working in C2. If picking logic is changing in C3 then my examples will start not working as intended.

  • wow thank you so much now it works properly.

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