-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (48 loc) · 1.64 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import svgwrite
from dungeon import Dungeon
# Setup Parameters
paper_dimensions = {"A4p":( 595, 842),
"A4l":( 842, 595),
"A3p":( 842, 1191),
"A3l":(1191, 842)}
width, height = paper_dimensions["A3l"]
square = 14.2
background_color = svgwrite.rgb(9, 46, 61, '%')
corridor_color = svgwrite.rgb(100, 100, 100, '%')
# Make Dungeons
dungeon = Dungeon(width=int(width/square), height=int(height/square))
dungeon.build_dungeon(max_iterations=400)
# Setup Drawing
print("Setting up drawing")
dwg = svgwrite.Drawing('output/dungeon_test.svg',
size=(width, height),
viewBox=(0,0,width, height),
profile='tiny')
# Draw Background
background = dwg.rect((0, 0), (width, height))
background.fill(color=background_color)
dwg.add(background)
# Draw Origin
origin = dwg.circle(center=dungeon.origin*square, r=square)
origin.fill(color="red")
dwg.add(origin)
# Draw Corridors
print("Drawing corridors")
for corridor in dungeon.corridors:
corridor_line = dwg.line(start=corridor.start*square, end=corridor.end*square)
corridor_line.stroke(color=corridor_color,
width=square,
linecap="round")
dwg.add(corridor_line)
# Draw tricks and traps
print("Placing Tricks and traps")
for point in dungeon.tricks+dungeon.traps:
text = dwg.text("T", insert=point*square+[-square/2, square/2])
dwg.add(text)
# Draw tricks and traps
print("Placing Monsters")
for point in dungeon.monsters:
text = dwg.text("M", insert=point*square+[-square/2, square/2])
dwg.add(text)
# Save Drawing
dwg.save()