generated from mwc/project_game
game
This commit is contained in:
32
game.py
Normal file
32
game.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from random import randint
|
||||
from retro.game import Game
|
||||
|
||||
class Agent:
|
||||
RIGHT = (1, 0)
|
||||
UP = (0, -1)
|
||||
LEFT = (-1, 0)
|
||||
DOWN = (0, 1)
|
||||
character = ">"
|
||||
direction = RIGHT
|
||||
position = (15, 0)
|
||||
name = "agent"
|
||||
color = "white_on_black"
|
||||
display = True
|
||||
|
||||
def handle_keystroke(self, keystroke, game):
|
||||
x, y = self.position
|
||||
if keystroke.name == "M":
|
||||
self.direction = self.RIGHT
|
||||
self.character = '>'
|
||||
elif keystroke.name == "I":
|
||||
self.direction = self.LEFT
|
||||
self.character = '<'
|
||||
|
||||
def can_move(self, position, game):
|
||||
on_board = game.on_board(position)
|
||||
empty = game.is_empty(position)
|
||||
|
||||
if __name__ == '__main__':
|
||||
player = Agent()
|
||||
game = Game([Agent], {'score': 0}, board_size:=(24, 20), framerate:=12)
|
||||
game.play()
|
||||
Reference in New Issue
Block a user