generated from mwc/project_game
Compare commits
3 Commits
7907a4cad3
...
f0840a02fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0840a02fc | ||
|
|
cdafa795fc | ||
|
|
bce3c8508c |
BIN
__pycache__/maze_layout.cpython-312.pyc
Normal file
BIN
__pycache__/maze_layout.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/player.cpython-312.pyc
Normal file
BIN
__pycache__/player.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/wall.cpython-312.pyc
Normal file
BIN
__pycache__/wall.cpython-312.pyc
Normal file
Binary file not shown.
25
escape_the_maze.py
Normal file
25
escape_the_maze.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from retro.game import Game
|
||||||
|
from player import Player
|
||||||
|
|
||||||
|
def main():
|
||||||
|
board_size = (100, 40)
|
||||||
|
|
||||||
|
player = Player(board_size)
|
||||||
|
|
||||||
|
state = {
|
||||||
|
"win": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
game = Game(
|
||||||
|
agents=[player],
|
||||||
|
state=state,
|
||||||
|
board_size=board_size,
|
||||||
|
debug=False,
|
||||||
|
framerate=24,
|
||||||
|
color="white_on_black",
|
||||||
|
)
|
||||||
|
|
||||||
|
game.play()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
8
game_signature.py
Normal file
8
game_signature.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from retro.game import Game
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
print("Game.__init__ signature:")
|
||||||
|
print(inspect.signature(Game.__init__))
|
||||||
|
|
||||||
|
print("\nFull source of Game.__init__:\n")
|
||||||
|
print(inspect.getsource(Game.__init__))
|
||||||
38
player.py
Normal file
38
player.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
class Player:
|
||||||
|
"""
|
||||||
|
Player agent for Escape the Maze.
|
||||||
|
Moves one step at a time using the arrow keys.
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "player"
|
||||||
|
character = "🐧" # Penguin icon
|
||||||
|
|
||||||
|
def __init__(self, board_size):
|
||||||
|
# Start near the top-left corner
|
||||||
|
width, height = board_size
|
||||||
|
self.position = (1, 1)
|
||||||
|
|
||||||
|
def handle_keystroke(self, keystroke, game):
|
||||||
|
"""
|
||||||
|
Called once for each key pressed since the last turn.
|
||||||
|
Moves the player using the arrow keys.
|
||||||
|
"""
|
||||||
|
x, y = self.position
|
||||||
|
new_position = None
|
||||||
|
|
||||||
|
if keystroke.name == "KEY_UP":
|
||||||
|
new_position = (x, y - 1)
|
||||||
|
elif keystroke.name == "KEY_DOWN":
|
||||||
|
new_position = (x, y + 1)
|
||||||
|
elif keystroke.name == "KEY_LEFT":
|
||||||
|
new_position = (x - 1, y)
|
||||||
|
elif keystroke.name == "KEY_RIGHT":
|
||||||
|
new_position = (x + 1, y)
|
||||||
|
|
||||||
|
|
||||||
|
if new_position is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if game.on_board(new_position) and game.is_empty(new_position):
|
||||||
|
self.position = new_position
|
||||||
31
proposal.md
Normal file
31
proposal.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Game Proposal
|
||||||
|
|
||||||
|
## Game Overview
|
||||||
|
Title: Escape the Maze
|
||||||
|
|
||||||
|
Vision: A puzzle style game where the player must complete a maze. I think it's compelling because it combines problem solving and interactive play.
|
||||||
|
|
||||||
|
Layout: A grid based maze with a player and exit.
|
||||||
|
|
||||||
|
Objective: Player uses arrow keys to navigate and end the game by reaching the exit.
|
||||||
|
|
||||||
|
## Core Mechanics
|
||||||
|
- Player movement: Move one step at a time using arrow keys.
|
||||||
|
- Collision detection: Prevents player from walking through walls.
|
||||||
|
- Win condition: End the game when the player reaches the exit.
|
||||||
|
|
||||||
|
## Milestone
|
||||||
|
1. Player agent moves correctly.
|
||||||
|
2. Walls block movement.
|
||||||
|
3. Exit agent ends the game when reached.
|
||||||
|
6. (Optional) Add scoring, timer, or multiple levels.
|
||||||
|
|
||||||
|
## Challenges
|
||||||
|
- Designing the maze
|
||||||
|
- Implementing collision detection
|
||||||
|
- Adding optional features
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user