View Full Version : [Juego estupido] Modifica el codigo
theotherhiveking
09-19-2008, 08:02 PM
import curses
FOV_RADIUS = 10
dungeon = ["################################################## #########",
"#...........#..................................... ........#",
"#...........#........#............................ ........#",
"#.....................#........................... ........#",
"#....####..............#.......................... ........#",
"#.......#.......................################## ###.....#",
"#.......#......................................... ..#.....#",
"#.......#...........##............................ ..#.....#",
"#####........#......##..........################## ..#.....#",
"#...#...........................#................# ..#.....#",
"#...#............#..............#................# ..#.....#",
"#...............................#..############### ..#.....#",
"#...............................#................. ..#.....#",
"#...............................#................. ..#.....#",
"#...............................################## ###.....#",
"#................................................. ........#",
"#................................................. ........#",
"################################################## #########"]
class Map(object):
# Multipliers for transforming coordinates to other octants:
mult = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0, 0, 1, -1, 0, 0, -1]
]
def __init__(self, map):
self.data = map
self.width, self.height = len(map[0]), len(map)
self.light = []
for i in range(self.height):
self.light.append([0] * self.width)
self.flag = 0
def square(self, x, y):
return self.data[y][x]
def blocked(self, x, y):
return (x < 0 or y < 0
or x >= self.width or y >= self.height
or self.data[y][x] == "#")
def lit(self, x, y):
return self.light[y][x] == self.flag
def set_lit(self, x, y):
if 0 <= x < self.width and 0 <= y < self.height:
self.light[y][x] = self.flag
def _cast_light(self, cx, cy, row, start, end, radius, xx, xy, yx, yy, id):
"Recursive lightcasting function"
if start < end:
return
radius_squared = radius*radius
for j in range(row, radius+1):
dx, dy = -j-1, -j
blocked = False
while dx <= 0:
dx += 1
# Translate the dx, dy coordinates into map coordinates:
X, Y = cx + dx * xx + dy * xy, cy + dx * yx + dy * yy
# l_slope and r_slope store the slopes of the left and right
# extremities of the square we're considering:
l_slope, r_slope = (dx-0.5)/(dy+0.5), (dx+0.5)/(dy-0.5)
if start < r_slope:
continue
elif end > l_slope:
break
else:
# Our light beam is touching this square; light it:
if dx*dx + dy*dy < radius_squared:
self.set_lit(X, Y)
if blocked:
# we're scanning a row of blocked squares:
if self.blocked(X, Y):
new_start = r_slope
continue
else:
blocked = False
start = new_start
else:
if self.blocked(X, Y) and j < radius:
# This is a blocking square, start a child scan:
blocked = True
self._cast_light(cx, cy, j+1, start, l_slope,
radius, xx, xy, yx, yy, id+1)
new_start = r_slope
# Row is scanned; do next row unless last square was blocked:
if blocked:
break
def do_fov(self, x, y, radius):
"Calculate lit squares from the given location and radius"
self.flag += 1
for oct in range(8):
self._cast_light(x, y, 1, 1.0, 0.0, radius,
self.mult[0][oct], self.mult[1][oct],
self.mult[2][oct], self.mult[3][oct], 0)
def display(self, s, X, Y):
"Display the map on the given curses screen (utterly unoptimized)"
dark, lit = curses.color_pair(8), curses.color_pair(7) | curses.A_BOLD
for x in range(self.width):
for y in range(self.height):
if self.lit(x, y):
attr = lit
else:
attr = dark
if x == X and y == Y:
ch = '@'
attr = lit
else:
ch = self.square(x, y)
s.addstr(y, x, ch, attr)
s.refresh()
def color_pairs():
c = []
for i in range(1, 16):
curses.init_pair(i, i % 8, 0)
if i < 8:
c.append(curses.color_pair(i))
else:
c.append(curses.color_pair(i) | curses.A_BOLD)
return c
if __name__ == '__main__':
try:
s = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
color_pairs()
s.keypad(1)
x, y = 36, 13
map = Map(dungeon)
while True:
map.do_fov(x, y, FOV_RADIUS)
map.display(s, x, y)
k = s.getch()
if k == 27:
break
elif k == 259:
y -= 1
elif k == 258:
y += 1
elif k == 260:
x -= 1
elif k == 261:
x += 1
finally:
s.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
print "Normal termination."
El juego consiste en hacer que el '@' no pueda pasar por encima de '#'
Topoq
09-19-2008, 08:03 PM
eeing??????? p-p-perdon-n??????
Nidhug
09-19-2008, 08:05 PM
Yo lo haria pero no quiero (?) :cuac:
Si no es lenguaje C le pego en el palo.
P.D: Lo hago a la noche y despues les cuento si me salio
leytonn
09-19-2008, 08:10 PM
El juego consiste en hacer que el '@' no pueda pasar por encima de '#'
No somos tan inteligentes como vos Hive :p
arlick
09-19-2008, 08:11 PM
jajaj que chulo está! eso es uno de los roguelike esos? ahora lo miró con detenimiento xD
theotherhiveking
09-19-2008, 08:13 PM
jajaj que chulo está! eso es uno de los roguelike esos? ahora lo miró con detenimiento xD
anda a jugar al dungeon crawl!
ssh crawl.akrasiac.org -l joshua
La contraseña es joshua, ahí podes jugar online.
leytonn
09-19-2008, 08:13 PM
anda a jugar al dungeon crawl!
ssh crawl.akrasiac.org -l joshua
La contraseña es joshua, ahí podes jugar online.
ALGUIEN QUE ME EXPLIQUE EN QUE IDIOMA HABLAN!!!!!!!!!
Topoq
09-19-2008, 08:19 PM
ALGUIEN QUE ME EXPLIQUE EN QUE IDIOMA HABLAN!!!!!!!!!
El HOYGAN(?)
Roldier
09-19-2008, 08:24 PM
Es un HOYGAN + L4MM3R, Voy a intentar comunicarme.
0|4 HYB3CyNJ, Z0i r0|Dy3r, 4|gvn0z n0 3nt3nD3m0z 3zt3 p0Zt, 3Xplyk4n0zl0 kv4nD0 Pv3D4z X f4b0r :)
Nidhug
09-19-2008, 08:25 PM
Es un HOYGAN + L4MM3R, Voy a intentar comunicarme.
0|4 HYB3CyNJ, Z0i r0|Dy3r, 4|gvn0z n0 3nt3nD3m0z 3zt3 p0Zt, 3Xplyk4n0zl0 kv4nD0 Pv3D4z X f4b0r :)
Esta bien pero por favor corrige el
0ol98jd8uiwo8 que lo unico que quieres decir es h76h6%89¿
:)
Roldier
09-19-2008, 08:29 PM
Esta bien pero por favor corrige el
0ol98jd8uiwo8 que lo unico que quieres decir es h76h6%89¿
:)
Me lo dices a mi? O.o
Nidhug
09-19-2008, 08:31 PM
Me lo dices a mi? O.o
Claro por que de lo contrario C0M3NZ4RI4S A QU3D4R M4L :harhar:
Roldier
09-19-2008, 08:32 PM
Claro por que de lo contrario C0M3NZ4RI4S A QU3D4R M4L :harhar:
3Z k "0ol98jd8uiwo8 que lo unico que quieres decir es h76h6%89¿" n0 Ty3n3 Z3nTyD0 3n YDy0M4 H0YG4N + L4MM3R :harhar:
Nidhug
09-19-2008, 08:35 PM
3Z k "0ol98jd8uiwo8 que lo unico que quieres decir es h76h6%89¿" n0 Ty3n3 Z3nTyD0 3n YDy0M4 H0YG4N + L4MM3R :harhar:
3nt0nc3s c0m0 qu13r3z q3u 3nt1end4 l4 g3nt3:harhar:
Roldier
09-19-2008, 08:36 PM
3nt0nc3s c0m0 qu13r3z q3u 3nt1end4 l4 g3nt3:harhar:
MV3R3T3 D3 H4ZKO!!!!!!
Nidhug
09-19-2008, 08:38 PM
MV3R3T3 D3 H4ZKO!!!!!!
P0N UN4 F0T0 TUY4 Y LO H4G0:harhar:
Nidhug
09-19-2008, 08:39 PM
P0N UN4 F0T0 TUY4 Y LO H4G0:harhar:
4QU1 3ST4 R0LD13R
http://img155.imageshack.us/img155/7355/screenshot2008091015334vw0.jpg
:cuac: :confused2:
Roldier
09-19-2008, 08:41 PM
4QU1 3ST4 R0LD13R
:cuac: :confused2:
Por que esa Duda??? Por que????
Nidhug
09-19-2008, 08:44 PM
Por que esa Duda??? Por que????
P0r qu3 n0 3st0y 100 % s3gur0 conf1rmam3 si 3r3s tu O.O"???
Roldier
09-19-2008, 08:45 PM
P0r qu3 n0 3st0y 100 % s3gur0 conf1rmam3 si 3r3s tu O.O"???
Es posible.... Dejame 60 minutos para pensarlo....
arlick
09-19-2008, 08:45 PM
que poco se de python T.T
the other!!
en la función if __name__ == '__main__':, puedo acceder al caracter que halla debajo de la posición actual del cursor? no se como hacerlo...
Nidhug
09-19-2008, 08:46 PM
Es posible.... Dejame 60 minutos para pensarlo....
Te doy 60 segundos y contando 59, 58 , 57 ,56,55,..... :naughty:
Roldier
09-19-2008, 08:48 PM
Te doy 60 segundos y contando 59, 58 , 57 ,56,55,..... :naughty:
Mira por donde me paso tus 60 segs: Forro (http://www.regnumonline.com.ar/forum/www.agujeronegro.com)
Nidhug
09-19-2008, 08:51 PM
Mira por donde me paso tus 60 segs: Forro (http://www.regnumonline.com.ar/forum/www.agujeronegro.com)
El link esta mal:harhar:
arlick
09-19-2008, 08:55 PM
conseguido :punk:
import curses
FOV_RADIUS = 10
dungeon = ["################################################## #########",
"#...........#..................................... ........#",
"#...........#........#............................ ........#",
"#.....................#........................... ........#",
"#....####..............#.......................... ........#",
"#.......#.......................################## ###.....#",
"#.......#......................................... ..#.....#",
"#.......#...........##............................ ..#.....#",
"#####........#......##..........################## ..#.....#",
"#...#...........................#................# ..#.....#",
"#...#............#..............#................# ..#.....#",
"#...............................#..############### ..#.....#",
"#...............................#................. ..#.....#",
"#...............................#................. ..#.....#",
"#...............................################## ###.....#",
"#................................................. ........#",
"#................................................. ........#",
"################################################## #########"]
class Map(object):
# Multipliers for transforming coordinates to other octants:
mult = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0, 0, 1, -1, 0, 0, -1]
]
def __init__(self, map):
self.data = map
self.width, self.height = len(map[0]), len(map)
self.light = []
for i in range(self.height):
self.light.append([0] * self.width)
self.flag = 0
def square(self, x, y):
return self.data[y][x]
def blocked(self, x, y):
return (x < 0 or y < 0
or x >= self.width or y >= self.height
or self.data[y][x] == "#")
def lit(self, x, y):
return self.light[y][x] == self.flag
def set_lit(self, x, y):
if 0 <= x < self.width and 0 <= y < self.height:
self.light[y][x] = self.flag
def _cast_light(self, cx, cy, row, start, end, radius, xx, xy, yx, yy, id):
"Recursive lightcasting function"
if start < end:
return
radius_squared = radius*radius
for j in range(row, radius+1):
dx, dy = -j-1, -j
blocked = False
while dx <= 0:
dx += 1
# Translate the dx, dy coordinates into map coordinates:
X, Y = cx + dx * xx + dy * xy, cy + dx * yx + dy * yy
# l_slope and r_slope store the slopes of the left and right
# extremities of the square we're considering:
l_slope, r_slope = (dx-0.5)/(dy+0.5), (dx+0.5)/(dy-0.5)
if start < r_slope:
continue
elif end > l_slope:
break
else:
# Our light beam is touching this square; light it:
if dx*dx + dy*dy < radius_squared:
self.set_lit(X, Y)
if blocked:
# we're scanning a row of blocked squares:
if self.blocked(X, Y):
new_start = r_slope
continue
else:
blocked = False
start = new_start
else:
if self.blocked(X, Y) and j < radius:
# This is a blocking square, start a child scan:
blocked = True
self._cast_light(cx, cy, j+1, start, l_slope,
radius, xx, xy, yx, yy, id+1)
new_start = r_slope
# Row is scanned; do next row unless last square was blocked:
if blocked:
break
def do_fov(self, x, y, radius):
"Calculate lit squares from the given location and radius"
self.flag += 1
for oct in range(8):
self._cast_light(x, y, 1, 1.0, 0.0, radius,
self.mult[0][oct], self.mult[1][oct],
self.mult[2][oct], self.mult[3][oct], 0)
def display(self, s, X, Y):
"Display the map on the given curses screen (utterly unoptimized)"
dark, lit = curses.color_pair(8), curses.color_pair(7) | curses.A_BOLD
for x in range(self.width):
for y in range(self.height):
if self.lit(x, y):
attr = lit
else:
attr = dark
if x == X and y == Y:
ch = '@'
attr = lit
else:
ch = self.square(x, y)
s.addstr(y, x, ch, attr)
s.refresh()
def color_pairs():
c = []
for i in range(1, 16):
curses.init_pair(i, i % 8, 0)
if i < 8:
c.append(curses.color_pair(i))
else:
c.append(curses.color_pair(i) | curses.A_BOLD)
return c
if __name__ == '__main__':
try:
s = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
color_pairs()
s.keypad(1)
x, y = 36, 13
map = Map(dungeon)
while True:
map.do_fov(x, y, FOV_RADIUS)
map.display(s, x, y)
k = s.getch()
if k == 27:
break
elif k == 259:
y -= 1
if map.blocked(x, y):
y += 1
elif k == 258:
y += 1
if map.blocked(x, y):
y -= 1
elif k == 260:
x -= 1
if map.blocked(x, y):
x += 1
elif k == 261:
x += 1
if map.blocked(x, y):
x -= 1
finally:
s.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
print "Normal termination."
theotherhiveking
09-19-2008, 08:58 PM
que poco se de python T.T
the other!!
en la función if __name__ == '__main__':, puedo acceder al caracter que halla debajo de la posición actual del cursor? no se como hacerlo...
Yo tampoco O_o
Seguro se puede hacer con curses.
No se.. podes importar curses y luego haces 'dir(curses)', miras los nombres y podes hacer 'print curses.lo_que_sea.__doc__' por si tiene algo de documentacion verla.
Edit: a bue.. a ver :p
Roldier
09-19-2008, 08:59 PM
conseguido :punk:
import curses
FOV_RADIUS = 10
dungeon = ["################################################## #########",
"#...........#..................................... ........#",
"#...........#........#............................ ........#",
"#.....................#........................... ........#",
"#....####..............#.......................... ........#",
"#.......#.......................################## ###.....#",
"#.......#......................................... ..#.....#",
"#.......#...........##............................ ..#.....#",
"#####........#......##..........################## ..#.....#",
"#...#...........................#................# ..#.....#",
"#...#............#..............#................# ..#.....#",
"#...............................#..############### ..#.....#",
"#...............................#................. ..#.....#",
"#...............................#................. ..#.....#",
"#...............................################## ###.....#",
"#................................................. ........#",
"#................................................. ........#",
"################################################## #########"]
class Map(object):
# Multipliers for transforming coordinates to other octants:
mult = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0, 0, 1, -1, 0, 0, -1]
]
def __init__(self, map):
self.data = map
self.width, self.height = len(map[0]), len(map)
self.light = []
for i in range(self.height):
self.light.append([0] * self.width)
self.flag = 0
def square(self, x, y):
return self.data[y][x]
def blocked(self, x, y):
return (x < 0 or y < 0
or x >= self.width or y >= self.height
or self.data[y][x] == "#")
def lit(self, x, y):
return self.light[y][x] == self.flag
def set_lit(self, x, y):
if 0 <= x < self.width and 0 <= y < self.height:
self.light[y][x] = self.flag
def _cast_light(self, cx, cy, row, start, end, radius, xx, xy, yx, yy, id):
"Recursive lightcasting function"
if start < end:
return
radius_squared = radius*radius
for j in range(row, radius+1):
dx, dy = -j-1, -j
blocked = False
while dx <= 0:
dx += 1
# Translate the dx, dy coordinates into map coordinates:
X, Y = cx + dx * xx + dy * xy, cy + dx * yx + dy * yy
# l_slope and r_slope store the slopes of the left and right
# extremities of the square we're considering:
l_slope, r_slope = (dx-0.5)/(dy+0.5), (dx+0.5)/(dy-0.5)
if start < r_slope:
continue
elif end > l_slope:
break
else:
# Our light beam is touching this square; light it:
if dx*dx + dy*dy < radius_squared:
self.set_lit(X, Y)
if blocked:
# we're scanning a row of blocked squares:
if self.blocked(X, Y):
new_start = r_slope
continue
else:
blocked = False
start = new_start
else:
if self.blocked(X, Y) and j < radius:
# This is a blocking square, start a child scan:
blocked = True
self._cast_light(cx, cy, j+1, start, l_slope,
radius, xx, xy, yx, yy, id+1)
new_start = r_slope
# Row is scanned; do next row unless last square was blocked:
if blocked:
break
def do_fov(self, x, y, radius):
"Calculate lit squares from the given location and radius"
self.flag += 1
for oct in range(8):
self._cast_light(x, y, 1, 1.0, 0.0, radius,
self.mult[0][oct], self.mult[1][oct],
self.mult[2][oct], self.mult[3][oct], 0)
def display(self, s, X, Y):
"Display the map on the given curses screen (utterly unoptimized)"
dark, lit = curses.color_pair(8), curses.color_pair(7) | curses.A_BOLD
for x in range(self.width):
for y in range(self.height):
if self.lit(x, y):
attr = lit
else:
attr = dark
if x == X and y == Y:
ch = '@'
attr = lit
else:
ch = self.square(x, y)
s.addstr(y, x, ch, attr)
s.refresh()
def color_pairs():
c = []
for i in range(1, 16):
curses.init_pair(i, i % 8, 0)
if i < 8:
c.append(curses.color_pair(i))
else:
c.append(curses.color_pair(i) | curses.A_BOLD)
return c
if __name__ == '__main__':
try:
s = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
color_pairs()
s.keypad(1)
x, y = 36, 13
map = Map(dungeon)
while True:
map.do_fov(x, y, FOV_RADIUS)
map.display(s, x, y)
k = s.getch()
if k == 27:
break
elif k == 259:
y -= 1
if map.blocked(x, y):
y += 1
elif k == 258:
y += 1
if map.blocked(x, y):
y -= 1
elif k == 260:
x -= 1
if map.blocked(x, y):
x += 1
elif k == 261:
x += 1
if map.blocked(x, y):
x -= 1
finally:
s.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
print "Normal termination."
Pero si solo cambio coordenadas.... Que hay que saber para cambiar y para que sirve ese codigo? =o
arlick
09-19-2008, 08:59 PM
Yo tampoco O_o
Seguro se puede hacer con curses.
No se.. podes importar curses y luego haces 'dir(curses)', miras los nombres y podes hacer 'print curses.lo_que_sea.__doc__' por si tiene algo de documentacion verla.
revisa mi último (anterior) post ^^
theotherhiveking
09-19-2008, 09:01 PM
Ya lo vi, arlick gana. El premio es 2 puntos de karma, cuando te pueda dar por hace ya siglos que no le puedo dar a nadie.
Pongo otro?
arlick
09-19-2008, 09:02 PM
Ya lo vi, arlick gana.
donde sacaste esto? o te lo has inventado?
arlick
09-19-2008, 09:03 PM
Ya lo vi, arlick gana. El premio es 2 puntos de karma, cuando te pueda dar por hace ya siglos que no le puedo dar a nadie.
Pongo otro?
si! soy más rápido quoteando que tu editando :naughty:
theotherhiveking
09-19-2008, 09:04 PM
si! soy más rápido quoteando que tu editando :naughty:
:cuac::cuac:
Roldier
09-19-2008, 09:10 PM
import curses
FOV_RADIUS = 10
dungeon = ["################################################## #########",
"#...........#..................................... ........#",
"#...........#........#............................ ........#",
"#.....................#........................... ........#",
"#....####..............#.......................... ........#",
"#.......#.......................################## ###.....#",
"#.......#......................................... ..#.....#",
"#.......#...........##............................ ..#.....#",
"#####........#......##..........################## ..#.....#",
"#...#...........................#................# ..#.....#",
"#...#............#..............#................# ..#.....#",
"#...............................#..############### ..#.....#",
"#...............................#................. ..#.....#",
"#...............................#................. ..#.....#",
"#...............................################## ###.....#",
"#................................................. ........#",
"#................................................. ........#",
"################################################## #########"]
class Map(object):
# Multipliers for transforming coordinates to other octants:
mult = [
[1, 0, 0, -1, -1, 0, 0, 1],
[0, 1, -1, 0, 0, -1, 1, 0],
[0, 1, 1, 0, 0, -1, -1, 0],
[1, 0, 0, 1, -1, 0, 0, -1]
]
def __init__(self, map):
self.data = map
self.width, self.height = len(map[0]), len(map)
self.light = []
for i in range(self.height):
self.light.append([0] * self.width)
self.flag = 0
def square(self, x, y):
return self.data[y][x]
def blocked(self, x, y):
return (x < 0 or y < 0
or x >= self.width or y >= self.height
or self.data[y][x] == "#")
def lit(self, x, y):
return self.light[y][x] == self.flag
def set_lit(self, x, y):
if 0 <= x < self.width and 0 <= y < self.height:
self.light[y][x] = self.flag
def _cast_light(self, cx, cy, row, start, end, radius, xx, xy, yx, yy, id):
"Recursive lightcasting function"
if start < end:
return
radius_squared = radius*radius
for j in range(row, radius+1):
dx, dy = -j-1, -j
blocked = False
while dx <= 0:
dx += 1
# Translate the dx, dy coordinates into map coordinates:
X, Y = cx + dx * xx + dy * xy, cy + dx * yx + dy * yy
# l_slope and r_slope store the slopes of the left and right
# extremities of the square we're considering:
l_slope, r_slope = (dx-0.5)/(dy+0.5), (dx+0.5)/(dy-0.5)
if start < r_slope:
continue
elif end > l_slope:
break
else:
# Our light beam is touching this square; light it:
if dx*dx + dy*dy < radius_squared:
self.set_lit(X, Y)
if blocked:
# we're scanning a row of blocked squares:
if self.blocked(X, Y):
new_start = r_slope
continue
else:
blocked = False
start = new_start
else:
if self.blocked(X, Y) and j < radius:
# This is a blocking square, start a child scan:
blocked = True
self._cast_light(cx, cy, j+1, start, l_slope,
radius, xx, xy, yx, yy, id+1)
new_start = r_slope
# Row is scanned; do next row unless last square was blocked:
if blocked:
break
def do_fov(self, x, y, radius):
"Calculate lit squares from the given location and radius"
self.flag += 1
for oct in range(8):
self._cast_light(x, y, 1, 1.0, 0.0, radius,
self.mult[0][oct], self.mult[1][oct],
self.mult[2][oct], self.mult[3][oct], 0)
def display(self, s, X, Y):
"Display the map on the given curses screen (utterly unoptimized)"
dark, lit = curses.color_pair(8), curses.color_pair(7) | curses.A_BOLD
for x in range(self.width):
for y in range(self.height):
if self.lit(x, y):
attr = lit
else:
attr = dark
if x == X and y == Y:
ch = '@'
attr = lit
else:
ch = self.square(x, y)
s.addstr(y, x, ch, attr)
s.refresh()
def color_pairs():
c = []
for i in range(1, 16):
curses.init_pair(i, i % 8, 0)
if i < 8:
c.append(curses.color_pair(i))
else:
c.append(curses.color_pair(i) | curses.A_BOLD)
return c
if __name__ == '__main__':
try:
s = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
color_pairs()
s.keypad(1)
x, y = 36, 13
map = Map(dungeon)
while True:
map.do_fov(x, y, FOV_RADIUS)
map.display(s, x, y)
k = s.getch()
if k == 27:
break
elif k == 259:
y -= 1
if map.blocked(x, y):
y += 1
elif k == 258:
y += 7
if map.blocked(x, y):
y -= 1
elif k == 260:
x -= 3
if map.blocked(x, y):
x += 1
elif k == 261:
x += 4
if map.blocked(x, y):
x -= 6
finally:
s.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
print "Normal termination."
Si hago esto pasa algo? =o
theotherhiveking
09-19-2008, 09:18 PM
donde sacaste esto? o te lo has inventado?
No, no es mio, tengo poquísima practica no creo que pudiese hacer algo asi.
Quieren que ponga algo mas dificil?^^
arlick
09-19-2008, 09:19 PM
No, no es mio, tengo poquísima practica no creo que pudiese hacer algo asi.
Quieren que ponga algo mas dificil?^^
dame caña!! :piz:
theotherhiveking
09-19-2008, 09:25 PM
No cabe en el post :p
Viene adjunto.
Tenes que usar ese codigo para generar una mazmorra aleatoria para usar con el otro codigo.
arlick
09-19-2008, 09:27 PM
solo me falta a mí ese módulo?
Traceback (most recent call last):
File "juego.py", line 2, in <module>
from Numeric import *
ImportError: No module named Numeric
theotherhiveking
09-19-2008, 09:33 PM
solo me falta a mí ese módulo?
Traceback (most recent call last):
File "juego.py", line 2, in <module>
from Numeric import *
ImportError: No module named Numeric
*sigh*
Yo si lo tengo.
Es que no viene empaquetado con python.
Mira en tus repos si esta.
Igual tambien esta aca.
http://numpy.scipy.org/
Cambio de nombre.. pero creo que es compatible, si no lo dejamos.
vBulletin® v3.8.7, Copyright ©2000-2025, vBulletin Solutions, Inc.