Search a tilemap for a tile

Get help using Construct 2

Post » Mon Apr 18, 2016 3:29 pm

Hi guys,

the solution I got is a bit (too) rudimentary (plus very random in duration and questionable in effectiveness, no doubt):

Image

Does someone know a more accurate way? Im generating a map (dungeon) randomly and the player should be placed somewhere on a walkable spot (the worldgeneration starts in the middle of the generated field). I would like to use that routine also for spawning enemies, interactive objects, stairs, etc.. With my "solution" it *might* be possible to place the player (somewhat between instant and X minutes, depending on whats generated).

Does someone can offer a player- and time-friendlier solution?

Have a great day,
Proxy

Edit: also thought about extracting the JSON of the tilemap and search in that for the ID I want, but this likely will take the first match every time - so the player will always start in the top left corner, what I dont really want - and placing the enemies with that way would end in a massacre (without an exit :D)
B
24
S
14
G
9
Posts: 118
Reputation: 6,794

Post » Mon Apr 18, 2016 6:05 pm

Your dungeon generation routine should keep tracks of positions that are candidate to receive additional objects. Once generation is done, pick a random position in the list of candidates and create your sprite on it.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675


Return to How do I....?

Who is online

Users browsing this forum: Manubis, TheSupreme and 10 guests