Attention |
Topic was automatically imported from the old Question2Answer platform. | |

Asked By |
Lothrinn |

Hello everyone !

I followed KidsCanCode’s tutorial on procedural dungeon generation. In the tutorial, he makes corridors connecting each room with this part of the code :

```
func carve_path(pos1, pos2):
#Carve a path between 2 points
var x_diff = sign(pos2.x - pos1.x)
var y_diff = sign(pos2.y - pos1.y)
if x_diff == 0: x_diff = pow(-1.0, randi() % 2)
if y_diff == 0: y_diff = pow(-1.0, randi() % 2)
#choose either x/y or y/x
var x_y = pos1
var y_x = pos2
if (randi() % 2) > 0:
x_y = pos2
y_x = pos1
for x in range(pos1.x, pos2.x, x_diff):
Map.set_cell(x, x_y.y, 0)
Map.set_cell(x, x_y.y + y_diff, 0) #widen corridor
for y in range(pos1.y, pos2.y, y_diff):
Map.set_cell(y_x.x, y, 0)
Map.set_cell(y_x.x + x_diff, y, 0) #widen corridor
```

This code makes his corridors being 2 tiles wide, however I would like them to be 4 wide since my map uses an autotile and his’ uses single tiles. I tried to mess up with this for a bit but can’t figure out how to do it. Could anyone please help me ?

could you link the tutorial?

Millard | 2020-06-07 19:15

Sure, it’s a 3 parts tutorial :

Part 1 : https://www.youtube.com/watch?v=G2_SGhmdYFo&t=600s

Part 2 : https://www.youtube.com/watch?v=U9B39sDIupc

Part 3 : https://www.youtube.com/watch?v=o3fwlk1NI-w&t=1239s

Lothrinn | 2020-06-07 21:47

thanks, I’ll have to look at them.

Millard | 2020-06-08 14:57