diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb81eeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +__pycache__ +.*.sw* +.DS_Store +*.sqlite3 +*.sqlite3-wal +*.sqlite3-shm +.ipynb_checkpoints diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/first_hack.py b/first_hack.py new file mode 100644 index 0000000..889b097 --- /dev/null +++ b/first_hack.py @@ -0,0 +1,67 @@ +import curses + +MAP = [ +"####################", +"###....#############", +"###....#############", +"###...........######", +"#############....###", +"#############....###", +"####################"] + + +def update(win, status, player_y, player_x): + win.erase() + win.box() + status.hline(0,0, curses.ACS_HLINE, 78) + map_line = 1 + + for line in MAP: + win.addstr(map_line, 1, line) + map_line += 1 + + win.addstr(player_y, player_x, '@', curses.A_BOLD) + status.addstr(1, 1, "PLAYER STATS") + win.refresh() + + +def main(stdscr): + curses.curs_set(0) + stdscr.clear() + begin_x = 0 + begin_y = 0 + height = 26 + width = 80 + win = curses.newwin(height, width, begin_y, begin_x) + status = win.subwin(5, 78, height-6, begin_x+1) + + win.keypad(True) + + + player_x = 4 + player_y = 4 + + while True: + new_x = player_x + new_y = player_y + + update(win, status, player_y, player_x) + + ch = win.getch() + + if ch == ord('q'): + break + elif ch == curses.KEY_UP: + new_y = (player_y - 1) % 26 + elif ch == curses.KEY_DOWN: + new_y = (player_y + 1) % 26 + elif ch == curses.KEY_RIGHT: + new_x = (player_x + 1) % 80 + elif ch == curses.KEY_LEFT: + new_x = (player_x - 1) % 80 + + if MAP[new_y - 1][new_x - 1] != '#': + player_x, player_y = new_x, new_y + + +curses.wrapper(main) diff --git a/main.py b/main.py new file mode 100644 index 0000000..03fa6a6 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from curseyou!") + + +if __name__ == "__main__": + main() diff --git a/phase_one.py b/phase_one.py new file mode 100644 index 0000000..fd71630 --- /dev/null +++ b/phase_one.py @@ -0,0 +1,83 @@ +import curses +import sys + +MAP = [ +"####################", +"###....#############", +"###....#############", +"###...........######", +"#############.######", +"#############....###", +"#############....###", +"####################"] + +def draw_map(win): + map_line = 1 + for line in MAP: + win.addstr(map_line, 1, line) + map_line += 1 + +def draw_status(status): + status.addstr(1, 1, "PLAYER STATS") + +def draw_player(win, player_y, player_x): + win.addstr(player_y, player_x, '@', curses.A_BOLD) + +def update(win, status, player_y, player_x): + win.clear() + win.box() + status.hline(0,0, curses.ACS_HLINE, 78) + draw_map(win) + draw_status(status) + draw_player(win, player_y, player_x) + win.refresh() + +def create_ui(stdscr, width, height, status_height): + curses.curs_set(0) + stdscr.clear() + begin_x = 0 + begin_y = 0 + win = curses.newwin(height, width, begin_y, begin_x) + status = win.subwin(status_height, height-2, height-6, begin_x+1) + win.keypad(True) + return win, status + +def move_player(player_y, player_x, target_y, target_x): + if MAP[target_y - 1][target_x - 1] != '#': + return target_y, target_x + else: + return player_y, player_x + +def handle_input(win, y, x, width, height): + ch = win.getch() + + if ch == ord('q'): + sys.exit(0) + elif ch == curses.KEY_UP: + y = (y - 1) % height + elif ch == curses.KEY_DOWN: + y = (y + 1) % height + elif ch == curses.KEY_RIGHT: + x = (x + 1) % width + elif ch == curses.KEY_LEFT: + x = (x - 1) % width + + return y, x + +def main(stdscr): + width=80 + height=26 + win, status = create_ui(stdscr, 80, 26, 5) + + player_x = 4 + player_y = 4 + + while True: + update(win, status, player_y, player_x) + new_y, new_x = handle_input( + win, player_y, player_x, width, height) + + player_y, player_x = move_player( + player_y, player_x, new_y, new_x) + +curses.wrapper(main) diff --git a/phase_two.py b/phase_two.py new file mode 100644 index 0000000..889b097 --- /dev/null +++ b/phase_two.py @@ -0,0 +1,67 @@ +import curses + +MAP = [ +"####################", +"###....#############", +"###....#############", +"###...........######", +"#############....###", +"#############....###", +"####################"] + + +def update(win, status, player_y, player_x): + win.erase() + win.box() + status.hline(0,0, curses.ACS_HLINE, 78) + map_line = 1 + + for line in MAP: + win.addstr(map_line, 1, line) + map_line += 1 + + win.addstr(player_y, player_x, '@', curses.A_BOLD) + status.addstr(1, 1, "PLAYER STATS") + win.refresh() + + +def main(stdscr): + curses.curs_set(0) + stdscr.clear() + begin_x = 0 + begin_y = 0 + height = 26 + width = 80 + win = curses.newwin(height, width, begin_y, begin_x) + status = win.subwin(5, 78, height-6, begin_x+1) + + win.keypad(True) + + + player_x = 4 + player_y = 4 + + while True: + new_x = player_x + new_y = player_y + + update(win, status, player_y, player_x) + + ch = win.getch() + + if ch == ord('q'): + break + elif ch == curses.KEY_UP: + new_y = (player_y - 1) % 26 + elif ch == curses.KEY_DOWN: + new_y = (player_y + 1) % 26 + elif ch == curses.KEY_RIGHT: + new_x = (player_x + 1) % 80 + elif ch == curses.KEY_LEFT: + new_x = (player_x - 1) % 80 + + if MAP[new_y - 1][new_x - 1] != '#': + player_x, player_y = new_x, new_y + + +curses.wrapper(main) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c5bf70a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "curseyou" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [ + "windows-curses>=2.4.1", +] diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..b15b9c8 --- /dev/null +++ b/uv.lock @@ -0,0 +1,25 @@ +version = 1 +revision = 2 +requires-python = ">=3.12" + +[[package]] +name = "curseyou" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "windows-curses" }, +] + +[package.metadata] +requires-dist = [{ name = "windows-curses", specifier = ">=2.4.1" }] + +[[package]] +name = "windows-curses" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/99/60f34e51514c82631aa5c6d21eab88ce1701562de9844608411e39462a46/windows_curses-2.4.1-cp312-cp312-win32.whl", hash = "sha256:bdbe7d58747408aef8a9128b2654acf6fbd11c821b91224b9a046faba8c6b6ca", size = 71489, upload-time = "2025-01-11T00:26:22.726Z" }, + { url = "https://files.pythonhosted.org/packages/62/8f/d908bcab1954375b156a9300fa86ceccb110f39457cd6fd59c72777626ab/windows_curses-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:5c9c2635faf171a229caca80e1dd760ab00db078e2a285ba2f667bbfcc31777c", size = 81777, upload-time = "2025-01-11T00:26:25.273Z" }, + { url = "https://files.pythonhosted.org/packages/25/a0/e8d074f013117633f6b502ca123ecfc377fe0bd36818fe65e8935c91ca9c/windows_curses-2.4.1-cp313-cp313-win32.whl", hash = "sha256:05d1ca01e5199a435ccb6c8c2978df4a169cdff1ec99ab15f11ded9de8e5be26", size = 71390, upload-time = "2025-01-11T00:26:27.66Z" }, + { url = "https://files.pythonhosted.org/packages/2b/4b/2838a829b074a68c570d54ae0ae8539979657d3e619a4dc5a4b03eb69745/windows_curses-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:8cf653f8928af19c103ae11cfed38124f418dcdd92643c4cd17239c0cec2f9da", size = 81636, upload-time = "2025-01-11T00:26:29.595Z" }, +]