How do I spawn an entity in a blank space

Get help using Construct 2

Post » Mon Jul 06, 2015 6:55 pm

I´m trying to do some procedural cave-like generation, but after being able of generating/resetting the terrain, I need different entities to spawn in empty spaces within the layout. It uses arrays with "miners" that clear up "wall" sprites while generating.

I would like to know how to detect specific locations like hallways, corners or open spaces if possible.

Image

Thanks a lot! Hope someone answers this time, heheh...
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Mon Jul 06, 2015 7:33 pm

Off the top of my head I'd say that you should create a function a receive a point (x,y), and it returns the state of that particular tile in the array. If tile is empty, and have obstacles to the left, top and right, then return 1... do so for all your combination, and then use that function whenever you need to test a particular tile.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Jul 06, 2015 7:42 pm

Oh I see... I don´t really have much an idea of how would I do that, but I´ll give it a try, thanks!
Though further explanation would be greatly appreciated :)
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Mon Jul 06, 2015 8:47 pm

How is your terrain data represented, is it an array, or a tilemap ?
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Tue Jul 07, 2015 9:38 am

Sorry for the wait, @Magistross. I used to try tilemaps, but switched to sprites and found Yann´s post about procedural generation with miners. I can´t post plain URL´s (for the .capx) yet but it looks like there´s no problem with images so I´ll post the process:

Image

They are pretty much three arrays of 10 w each

Edit: c2 missed an event when making the screenshot that generated a wall for each XY element, it basically created the grid of sprites.
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Wed Jul 08, 2015 2:50 pm

I´m still stuck with this, if anyone could help, that would be awesome :)
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Wed Jul 08, 2015 7:39 pm

It's still tough to determine what you want exactly. Care to elaborate a bit more ?
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Thu Jul 09, 2015 9:25 am

Yes, sorry @Magistross :
-The array gets cleaned, then generates a grid of sprites which gets carved by "miners" (miner method).
-An empty cell is represented as 1 in the array
-Everything is generated from a center point in which the player is positioned so it´s never stuck

So what I want is to make the engine look for an empty space xy pixels far from the player pe enemies items... And if possible detecting special cases like an empty space surrounded by three sides (for a fake wall), a corner, a wall (turret)... like represented in the first post. I know I could do this with invisible high speed solid bullets, but the second part would require proper logic.

I apologise if I still did not explain it enough.
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Thu Jul 09, 2015 2:35 pm

I still can't grasp exactly your need. A function that check neighboring cells and return its "type" is dead easy to do, but obviously you want more. Maybe you could draw another diagram? :P
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Thu Jul 09, 2015 3:51 pm

Here it is, I hope it´s better explained. (ignore that green arrow too, it got in the way)

Image

As I said, I use a method really similar to Yann´s "miners" procedural generation, an array that is translated to a sprite grid, carving rooms and hallways from a center point.

What I want is to pick coordinates of an empty space so enemies can spawn. My main concern was that it would be pretty lame having all enemies spawning in random locations (in fact, it would be malfunctional because some depend on the terrain like turrets or worms), and I´m really bad with arrays so I was asking for a way to detect special areas like the ones shown in the image.

I don´t know if I could explain this in a better way, i´m an absolute noob with procedural generation
B
9
S
3
Posts: 150
Reputation: 1,264

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests