diff --git a/__pycache__/cursor.cpython-312.pyc b/__pycache__/cursor.cpython-312.pyc new file mode 100644 index 0000000..7e3f3c7 Binary files /dev/null and b/__pycache__/cursor.cpython-312.pyc differ diff --git a/cursor.py b/cursor.py new file mode 100644 index 0000000..f8c48da --- /dev/null +++ b/cursor.py @@ -0,0 +1,28 @@ +# cursor.py +# ------------ +# By MWC Contributors +# This module defines a spaceship agent class. +class Cursor: + name = "cursos" + character = 'O' + + def __init__(self, board_size): + board_width, board_height = board_size + self.position = (board_width // 2, board_height - 1) + + def handle_keystroke(self, keystroke, game): + x, y = self.position + if keystroke.name in ("KEY_LEFT", "KEY_RIGHT", "KEY_UP", "KEY_DOWN"): + if keystroke.name == "KEY_LEFT": + new_position = (x - 1, y) + elif keystroke.name == "KEY_RIGHT": + new_position = (x + 1, y) + elif keystroke.name == "KEY_UP": + new_position = (x, y - 1) + else: + new_position = (x, y + 1) + if game.on_board(new_position): + if game.is_empty(new_position): + self.position = new_position + else: + game.end() \ No newline at end of file diff --git a/minesweeper_game.py b/minesweeper_game.py new file mode 100644 index 0000000..1841ef8 --- /dev/null +++ b/minesweeper_game.py @@ -0,0 +1,12 @@ +# minesweeper_game.py +# ------------ +# By Cory +# This class implements a simple minesweeper game on a 9x9 gird. +from retro.game import Game +from cursor import Cursor + +board_size = (9, 9) +cursor = Cursor(board_size) +# spawner = AsteroidSpawner(board_size) +game = Game([cursor], {"score": 0}, board_size=board_size) +game.play() \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..86a4a80 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.0" +python-versions = "^3.11" +content-hash = "81b2fa642d7f2d1219cf80112ace12d689d053d81be7f7addb98144d56fc0fb2" diff --git a/pyproject.toml b/pyproject.toml index 1e94b25..351c89a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,8 @@ packages = [{include = "project_game"}] [tool.poetry.dependencies] python = "^3.11" +retro-games = "^0.1.2" + [build-system]