-
Notifications
You must be signed in to change notification settings - Fork 18
/
cave_demo.py
executable file
·62 lines (53 loc) · 1.38 KB
/
cave_demo.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
59
60
61
62
#!/usr/bin/env python
from random import randrange
import cave_factory
print '16x16 tile with exits on the East and West ends:'
cave = cave_factory.new(16, 16)
# North
width = randrange(1, 5)
offset = randrange(1, 16 - width)
cave.add_exit((0, offset), (0, offset + width))
# South
width = randrange(1, 5)
offset = randrange(1, 16 - width)
cave.add_exit((15, offset), (15, offset + width))
# Cave!
cave.gen_map()
cave.print_map()
del(cave)
print '16x16 tile with (room type)'
cave = cave_factory.new(16, 16)
# North
cave.add_exit((1, 0), (14, 0))
# Cave!
cave.gen_map(mode='room')
cave.print_map()
del(cave)
print '32x32 tile with two exits to the East, and one to the South:'
cave = cave_factory.new(32, 32)
# East
width = randrange(1, 5)
offset = randrange(1, 16 - width)
cave.add_exit((31, offset), (31, offset + width))
width = randrange(1, 5)
offset = randrange(16, 32 - width)
cave.add_exit((31, offset), (31, offset + width))
# South
width = randrange(1, 5)
offset = randrange(1, 32 - width)
cave.add_exit((offset, 31), (offset + width, 31))
# Cave!
cave.gen_map(mode='room')
cave.print_map()
# Resize
cave.resize_map(48, 48)
cave.print_map()
# del(cave)
#cave = cave_factory.new(32, 32)
#cave.add_exit((offset, 0), (offset+width, 0))
# cave.gen_map()
# cave.print_map()
# for p in cave.iterate_map(cave_factory.FLOOR):
# print p
# for p in cave.iterate_map(cave_factory.WALL):
# print p