Avancées sur l'éditeur
This commit is contained in:
parent
b868a5e08a
commit
cc2551e035
|
@ -7,10 +7,32 @@ import curses
|
|||
def fix(x):
|
||||
return int(x*65536)
|
||||
|
||||
class windowDat:
|
||||
s = 0
|
||||
def __init__(self):
|
||||
self.s = curses.initscr()
|
||||
curses.noecho()
|
||||
curses.cbreak()
|
||||
self.s.keypad(True)
|
||||
#little trick that allows us to not worry about closing
|
||||
def __del__(self):
|
||||
curses.nocbreak()
|
||||
self.s.keypad(False)
|
||||
curses.echo()
|
||||
curses.endwin()
|
||||
|
||||
class raycastMap:
|
||||
w = 0
|
||||
h = 0
|
||||
d = 0
|
||||
#provide usable start values to avoid headscratching
|
||||
startpos_x = 196608
|
||||
startpos_y = 196608
|
||||
startpos_z = 0
|
||||
startdir_x = 0
|
||||
startdir_y = 65536
|
||||
startplane_x = 43253
|
||||
startplane_y = 0
|
||||
floor = []
|
||||
wall = []
|
||||
sprite_count = 0
|
||||
|
@ -21,6 +43,13 @@ class raycastMap:
|
|||
"w":self.w,\
|
||||
"h":self.h,\
|
||||
"d":self.d,\
|
||||
"startpos_x":self.startpos_x,\
|
||||
"startpos_y":self.startpos_y,\
|
||||
"startpos_z":self.startpos_z,\
|
||||
"startdir_x":self.startdir_x,\
|
||||
"startdir_y":self.startdir_y,\
|
||||
"startplane_x":self.startplane_x,\
|
||||
"startplane_y":self.startplane_y,\
|
||||
"floor":self.floor,\
|
||||
"wall":self.wall,\
|
||||
"sprite_count":self.sprite_count,\
|
||||
|
@ -55,6 +84,26 @@ if len(sys.argv) < 2:
|
|||
seehelppls()
|
||||
os._exit(1)
|
||||
|
||||
def parsin(string):
|
||||
data = json.load(string)
|
||||
nmap = raycastMap(0, 0, 0)
|
||||
nmap.w = data.w
|
||||
nmap.h = data.h
|
||||
nmap.d = data.d
|
||||
nmap.startpos_x = data.startpos_x
|
||||
nmap.startpos_y = data.startpos_y
|
||||
nmap.startpos_z = data.startpos_z
|
||||
nmap.startdir_x = data.startdir_x
|
||||
nmap.startdir_y = data.startdir_y
|
||||
nmap.startplane_x = data.startplane_x
|
||||
nmap.startplane_y = data.startplane_y
|
||||
|
||||
return nmap
|
||||
|
||||
def parsefile(filename):
|
||||
nmap = parsin(open(filename, "r"))
|
||||
return nmap
|
||||
|
||||
def gen_ne(filename, w, h, d):
|
||||
try:
|
||||
nfile = open(filename, mode="x+t", buffering=1, encoding="utf-8", newline="\n")
|
||||
|
@ -65,26 +114,39 @@ def gen_ne(filename, w, h, d):
|
|||
nfile.write(nmap.parseout())
|
||||
nfile.write("\n")
|
||||
|
||||
for i in range(1, len(sys.argv)):
|
||||
option_set = -1
|
||||
if sys.argv[i] == "-h":
|
||||
helppage()
|
||||
os._exit(0)
|
||||
if sys.argv[i] == "-n":
|
||||
i+=3
|
||||
try:
|
||||
filename = sys.argv[-1]
|
||||
w = int(sys.argv[i-2])
|
||||
h = int(sys.argv[i-1])
|
||||
d = int(sys.argv[i])
|
||||
except:
|
||||
print("Invalid use of option -n !")
|
||||
if len(sys.argv) > 2:
|
||||
for i in range(1, len(sys.argv)-1):
|
||||
option_set = -1
|
||||
if sys.argv[i] == "-h":
|
||||
helppage()
|
||||
os._exit(0)
|
||||
if sys.argv[i] == "-n":
|
||||
i+=3
|
||||
try:
|
||||
filename = sys.argv[-1]
|
||||
w = int(sys.argv[i-2])
|
||||
h = int(sys.argv[i-1])
|
||||
d = int(sys.argv[i])
|
||||
except:
|
||||
print("Invalid use of option -n !")
|
||||
seehelppls()
|
||||
os._exit(1)
|
||||
gen_ne(filename, w, h, d)
|
||||
os._exit(0)
|
||||
if option_set == -1:
|
||||
print('Invalid option "'+sys.argv[i]+'" !')
|
||||
seehelppls()
|
||||
os._exit(1)
|
||||
gen_ne(filename, w, h, d)
|
||||
os._exit(0)
|
||||
if option_set == -1:
|
||||
print('Invalid option "'+sys.argv[i]+'" !')
|
||||
seehelppls()
|
||||
|
||||
myscr = windowDat()
|
||||
|
||||
openmap = parsefile(sys.argv[-1])
|
||||
|
||||
while True:
|
||||
myscr.s.clear()
|
||||
|
||||
myscr.s.addstr(0, 0, openmap)
|
||||
print(openmap)
|
||||
|
||||
myscr.s.refresh()
|
||||
sleep(10)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue