From c8264cf347872e462b4f068bbf277ac1d4a42ff7 Mon Sep 17 00:00:00 2001 From: adithyagenie Date: Sat, 5 Nov 2022 12:07:23 +0530 Subject: [PATCH] More tidying up + minor bug fix on saving maze --- maze/modules/about.py | 24 +++++++++++++++--------- maze/modules/maze.py | 6 ++++-- maze/modules/maze_saveandload.py | 8 +++++++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/maze/modules/about.py b/maze/modules/about.py index 668cb83..f64c6a9 100644 --- a/maze/modules/about.py +++ b/maze/modules/about.py @@ -12,9 +12,9 @@ def about(screen): 5, "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(6, 5, "V. Kirthivaasan - XII - C - Roll no: 17") - screen.addstr(7, 5, "Manwanthakrishnan - XII - C - Roll no: 21") + screen.addstr(5, 5, "B. Adithya\t\t\t - XII - C - Roll no: 3") + screen.addstr(6, 5, "V. Kirthivaasan\t\t - XII - C - Roll no: 17") + screen.addstr(7, 5, "R. Manwanthakrishnan\t - XII - C - Roll no: 21") screen.addstr( 9, 5, @@ -26,22 +26,28 @@ def about(screen): screen.addstr( 11, 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( - 12, 5, "in the native terminal without use of any other external modules." + 12, 5, + "use of any other external modules." ) screen.addstr( 13, 5, "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( - 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(20, 5, "The Labyrinth") + screen.addstr(16, 5, "This project has been an absolute blast to make.") + 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.refresh() while True: diff --git a/maze/modules/maze.py b/maze/modules/maze.py index 878178a..f20676e 100644 --- a/maze/modules/maze.py +++ b/maze/modules/maze.py @@ -532,13 +532,15 @@ def main(screen): curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) screen.clear() screen.refresh() - height, width = screen.getmaxyx() - height, width = int((height - 2) / 2), int((width - 2) / 2) + y, x = screen.getmaxyx() + height, width = int((y - 2) / 2), int((x - 2) / 2) database.databaseinit() database.tableinit() maze = Maze(height, width) screen.addstr(0, 0, str(maze)) screen.refresh() + screen.addstr(2, x - 22, "Press space to skip") + screen.addstr(3, x - 22, "the loading screen...") construction_demo(maze, screen) screen.clear() screen.refresh() # 70x 15y diff --git a/maze/modules/maze_saveandload.py b/maze/modules/maze_saveandload.py index 5a1dd84..b599767 100644 --- a/maze/modules/maze_saveandload.py +++ b/maze/modules/maze_saveandload.py @@ -15,7 +15,13 @@ def save(screen, maze, coords): screen.addstr(17, x - 17, "Enter filename: ") name = input(18, x - 17, screen) 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: name = "default" filename = f"maze_{str(num)}_{name}.maze"