generated from mwc/project_game
	Installed retro and got a cursor that moves...
Need to do: -Populate 10 mines randomly -Have the game end when a mine is selected (figure out how to select something) -Figure out an algorithm to reveal squares -Figure out how to show numbers in revealed squares -Add flag functionality?
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								__pycache__/cursor.cpython-312.pyc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								__pycache__/cursor.cpython-312.pyc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										28
									
								
								cursor.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								cursor.py
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
				
			||||||
							
								
								
									
										12
									
								
								minesweeper_game.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								minesweeper_game.py
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
				
			||||||
							
								
								
									
										7
									
								
								poetry.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								poetry.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -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"
 | 
				
			||||||
@@ -8,6 +8,8 @@ packages = [{include = "project_game"}]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[tool.poetry.dependencies]
 | 
					[tool.poetry.dependencies]
 | 
				
			||||||
python = "^3.11"
 | 
					python = "^3.11"
 | 
				
			||||||
 | 
					retro-games = "^0.1.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[build-system]
 | 
					[build-system]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user