More tidying up + minor bug fix on saving maze

This commit is contained in:
adithyagenie 2022-11-05 12:07:23 +05:30
parent e05ea8cdaa
commit c8264cf347
3 changed files with 26 additions and 12 deletions

View file

@ -12,9 +12,9 @@ def about(screen):
5, 5,
"This game which you have played was developed as a Computer Science Project by", "This game which you have played was developed as a Computer Science Project by",
) )
screen.addstr(5, 5, "B. Adithya - XII - C - Roll no: 3") screen.addstr(5, 5, "B. Adithya\t\t\t - XII - C - Roll no: 3")
screen.addstr(6, 5, "V. Kirthivaasan - XII - C - Roll no: 17") screen.addstr(6, 5, "V. Kirthivaasan\t\t - XII - C - Roll no: 17")
screen.addstr(7, 5, "Manwanthakrishnan - XII - C - Roll no: 21") screen.addstr(7, 5, "R. Manwanthakrishnan\t - XII - C - Roll no: 21")
screen.addstr( screen.addstr(
9, 9,
5, 5,
@ -26,22 +26,28 @@ def about(screen):
screen.addstr( screen.addstr(
11, 11,
5, 5,
"This game makes use of the 'curses' module which runs on any operating system", "This game makes use of the 'curses' module which runs on any operating system in the native terminal without"
) )
screen.addstr( screen.addstr(
12, 5, "in the native terminal without use of any other external modules." 12, 5,
"use of any other external modules."
) )
screen.addstr( screen.addstr(
13, 13,
5, 5,
"It makes use of SQL tables to store login details and maintain a leaderboard.", "It makes use of SQL tables to store login details and maintain a leaderboard.",
) )
screen.addstr(15, 5, "This project has been an absolute blast to make.")
screen.addstr( screen.addstr(
16, 5, "We thank you for playing this! Hope you liked it as much as we did!" 14,
5,
"It also makes use of binary files to save and load mazes.",
) )
screen.addstr(19, 5, "Signing off,") screen.addstr(16, 5, "This project has been an absolute blast to make.")
screen.addstr(20, 5, "The Labyrinth") screen.addstr(
17, 5, "We thank you for playing this! Hope you liked it as much as we did!"
)
screen.addstr(20, 5, "Signing off,")
screen.addstr(21, 5, "The Labyrinth")
screen.addstr(y - 2, x - 33, "Press Enter to exit this screen.") screen.addstr(y - 2, x - 33, "Press Enter to exit this screen.")
screen.refresh() screen.refresh()
while True: while True:

View file

@ -532,13 +532,15 @@ def main(screen):
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
screen.clear() screen.clear()
screen.refresh() screen.refresh()
height, width = screen.getmaxyx() y, x = screen.getmaxyx()
height, width = int((height - 2) / 2), int((width - 2) / 2) height, width = int((y - 2) / 2), int((x - 2) / 2)
database.databaseinit() database.databaseinit()
database.tableinit() database.tableinit()
maze = Maze(height, width) maze = Maze(height, width)
screen.addstr(0, 0, str(maze)) screen.addstr(0, 0, str(maze))
screen.refresh() screen.refresh()
screen.addstr(2, x - 22, "Press space to skip")
screen.addstr(3, x - 22, "the loading screen...")
construction_demo(maze, screen) construction_demo(maze, screen)
screen.clear() screen.clear()
screen.refresh() # 70x 15y screen.refresh() # 70x 15y

View file

@ -15,7 +15,13 @@ def save(screen, maze, coords):
screen.addstr(17, x - 17, "Enter filename: ") screen.addstr(17, x - 17, "Enter filename: ")
name = input(18, x - 17, screen) name = input(18, x - 17, screen)
if names: if names:
num = int(((names[-1].replace(".maze", "")).split("_"))[1]) + 1 for i in range(len(names)):
names[i] = names[i].replace(".maze", "")
for i in range(len(names)):
for j in range(len(names) - i - 1):
if int(names[j].split('_')[1]) > int(names[j + 1].split('_')[1]):
names[j], names[j + 1] = names[j + 1], names[j]
num = int(names[-1].split('_')[1]) + 1
if not name: if not name:
name = "default" name = "default"
filename = f"maze_{str(num)}_{name}.maze" filename = f"maze_{str(num)}_{name}.maze"