# SOLVEDExpanding Vine Around Wall Tiles

#### Klardonics

##### Member
Hopefully I can articulate what I'm trying to accomplish. I have a projectile that when it hits a wall (in this case I'm using tiles), it creates a vine object at that position (snapping it to the 8x8 grid that the game uses). I then want that vine object to expand for a couple more grid spaces, but hugging the tile wall (i.e. create several more vine objects that hug the wall).

In essence, it's simple to check whether an open grid space is adjacent to a wall:

However, things get more complex if there are more walls in the region that you don't necessarily want to create a vine on:

I really have no idea where to start with this, maybe arrays or ds grid. I looked into pathfinding for a bit, but knowing me I'll probably create something very convoluted and not performance friendly. I also had no idea how to search for similar problems to this -- not sure what I would look up. If someone could point me in the right direction, that'd be much appreciated!

#### Klardonics

##### Member
Well I think I worked it out, if anyone knows a way to optimize it though, I'd be happy to listen. At the moment the vines spread forever, but I can fix that.

Maybe if someone wants to create a similar effect, they can adapt this.

GML:
``````//create event

solids =  layer_tilemap_get_id("Solids");

spaceX[1] = x-8;
spaceY[1] = y-8;

spaceX[2] = x;
spaceY[2] = y-8;

spaceX[3] = x+8;
spaceY[3] = y-8;

//etc. all the way through spaceX[8]

//step event
//if space is free, start checking
for (i = 1; i < 9; i++){
if (!tilemap_get_at_pixel(solids, spaceX[i], spaceY[i]) && !instance_position(spaceX[i], spaceY[i], oVine)){
if (!tilemap_get_at_pixel(solids, spaceX[i]-8, spaceY[i]-8)
&& !tilemap_get_at_pixel(solids, spaceX[i], spaceY[i]-8)
&& !tilemap_get_at_pixel(solids, spaceX[i]+8, spaceY[i]-8)
&& !tilemap_get_at_pixel(solids, spaceX[i]-8, spaceY[i])
&& !tilemap_get_at_pixel(solids, spaceX[i]+8, spaceY[i])
&& !tilemap_get_at_pixel(solids, spaceX[i]-8, spaceY[i]+8)
&& !tilemap_get_at_pixel(solids, spaceX[i], spaceY[i]+8)
&& !tilemap_get_at_pixel(solids, spaceX[i]+8, spaceY[i]+8)){
}else{
instance_create_layer(spaceX[i], spaceY[i], "Instances", oVine);
}
}
}``````

Last edited: