1
Programming / Re: Python + Libtcod Filling Rooms
« on: January 22, 2013, 08:59:53 PM »
Thanks a lot for the suggestions. Gives me stuff to play around with while I'm coming up with weird room shapes.
As for the circular room, Jotaf kindly posted an easier way of doing this over at the Roguecentral board:
Hopefully that will help anyone else out trying to do the same thing!
As for the circular room, Jotaf kindly posted an easier way of doing this over at the Roguecentral board:
Code: [Select]
def create_circular_room(room):
global map
#center of circle
cx = (room.x1 + room.x2) / 2
cy = (room.y1 + room.y2) / 2
#radius of circle: make it fit nicely inside the room, by making the
#radius be half the width or height (whichever is smaller)
width = room.x2 - room.x1
height = room.y2 - room.y1
r = min(width, height) / 2
#go through the tiles in the circle and make them passable
for x in range(room.x1, room.x2 + 1):
for y in range(room.y1, room.y2 + 1):
if math.sqrt((x - cx) ** 2 + (y - cy) ** 2) <= r:
map[x][y].blocked = False
map[x][y].block_sight = False
Hopefully that will help anyone else out trying to do the same thing!