Trouble with random map generator

Get help using Construct 2

Post » Sun Mar 10, 2013 4:51 am

Hello, I'm having difficulty understanding why Construct 2 is occasionally creating a discontinuity in my randomly generated map. It doesn't always happen but if you hit reload enough you should see it.

For example: http://imgur.com/54A0iZH

I would think the engine would start at 4,3 in the array and move one direction in the x or y and then drop a room if there is no room there. I don't understand how it is moving both x AND y, creating an island of rooms.

Here is the capx: http://db.tt/KucuC8UK
B
9
S
2
Posts: 58
Reputation: 1,416

Post » Sun Mar 10, 2013 5:23 pm

You have rounding problems - cos(dir*90) or sin(dir*90) won't equal 0/1/-1 exactly but a number very close.

You should set dx to round(cos(dir*90)) and dy to round(sin(dir*90)).
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sun Mar 10, 2013 7:22 pm

Wow thanks a lot. Can't believe I overlooked that. :p
B
9
S
2
Posts: 58
Reputation: 1,416


Return to How do I....?

Who is online

Users browsing this forum: spacedoubt and 4 guests