projects
/
koperkapel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make screen size a tile shorter
[koperkapel.git]
/
koperkapel
/
generators
/
maps.py
diff --git
a/koperkapel/generators/maps.py
b/koperkapel/generators/maps.py
index dc36956ef08ef95e8a5d8335ef2f63e3f6ab1af0..ae174d5cd7bb4ed54902850ca2f7e33dbf1f8b30 100644
(file)
--- a/
koperkapel/generators/maps.py
+++ b/
koperkapel/generators/maps.py
@@
-28,6
+28,11
@@
ATTRIBUTE_MAP = {
}
}
+def random_cardinal():
+ """Return a random cardinal direction for random walks."""
+ return random.choice([(0, 1), (0, -1), (1, 0), (-1, 0)])
+
+
class LevelGenerator:
width = 0
height = 0
class LevelGenerator:
width = 0
height = 0
@@
-112,16
+117,14
@@
class LevelGenerator:
for walk in range(random.randint(3, 6)):
x = width // 2 + random.randint(-8, 8)
y = height // 2 + random.randint(-8, 8)
for walk in range(random.randint(3, 6)):
x = width // 2 + random.randint(-8, 8)
y = height // 2 + random.randint(-8, 8)
- dir_x = random.randint(-1, 1)
- dir_y = random.randint(-1, 1)
+ dir_x, dir_y = random_cardinal()
max_steps = random.randint(40, width * height // 4)
for step in range(20, max_steps):
if 0 < x < width - 1:
if 0 < y < height - 1:
self.underlayer[y][x] = '-'
if random.random() > 0.7:
max_steps = random.randint(40, width * height // 4)
for step in range(20, max_steps):
if 0 < x < width - 1:
if 0 < y < height - 1:
self.underlayer[y][x] = '-'
if random.random() > 0.7:
- dir_x = random.randint(-1, 1)
- dir_y = random.randint(-1, 1)
+ dir_x, dir_y = random_cardinal()
x += dir_x
y += dir_y
x += dir_x
y += dir_y