From 9142ec7bfe3f03e89e155e69fc120a43471d0638 Mon Sep 17 00:00:00 2001 From: mbhatti4 Date: Sat, 13 Dec 2025 22:44:43 -0500 Subject: [PATCH] This is the begining stages of my game. I was able to follow along the live coding video to start off my project. I am a bit confused on how to add in agents and then make them disapear but i am sure i can figure it out I am more concerned on how to make them add onto me after i make them disspear, as in snake game --- __pycache__/Player.cpython-313.pyc | Bin 0 -> 1513 bytes nav_game.py | 7 +++++++ player.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 __pycache__/Player.cpython-313.pyc create mode 100644 nav_game.py create mode 100644 player.py diff --git a/__pycache__/Player.cpython-313.pyc b/__pycache__/Player.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbd575aa2999e707dad75983bc33138018cbf83a GIT binary patch literal 1513 zcmZ`(-)q}e6uy!rS$2MT&9APZC3aJYS`rhMY|xFuph?>;xWS5OHoRUGTeY>=l6NJO zc~G!nndwurhd}mL_SU!UKdJFU&1DaPJ@qZrjJ@t0Np7=jImSol-tRl--uvlX4aUZj z1Z-vHj{S#7$e%bEniK_t%Mcuq%Opc|a)s!^8ZglqDT`XH7!E=&M1#R11V^Mmn4l9T z>H>@DB9rtOlXd9|VTvw;kLwCk%W+NR%2w5ETI>zxbEO^(xS$uKm4d1<@c19x1b0LX zp#f<9x&hUfATnTuB{-IA59?H56vd5r63dz8vu5gzT*9 zLH(fm%mr*EU@H+Dsw3MF^C;mtdnB(#J&GNQW-h~S#5}BZ-i-fpaYtKcy9+WC=ko|z zi>BtG|L~{9bI@(-m+N2A&Gn6Kp1>&o;NJahu3%_vh2Y(Xk8*4Zl7nVt(-_U5n+2!I z3@dNx~9@_gI9CT-5?D^GaSKAA%bYC9tJZ?XJHM`N1 zH~Pv%$7wsq$)1wwPfZ^SKd&FJ9Nunko~R!@AAdG}e50e@p_uo(7?5PXyrdx#*CE2O9YloY!m2_80_v0g-r|qYQh1c;+HxBvfgKtjcL}#bH zbMWVU=T~jV za$HIoeh_)0STUJd^ex6xSTT*0)0BF?>DxtW`aZLF8@}aH`jUi;qQ(p_XW+08J$$=A zk-nO0P4&l8tqZF(oQ;?n0;PZ)D8oFTn!P`cKmY&$ literal 0 HcmV?d00001 diff --git a/nav_game.py b/nav_game.py new file mode 100644 index 0000000..a7c8929 --- /dev/null +++ b/nav_game.py @@ -0,0 +1,7 @@ +from retro.game import Game +from player import Player + +board_size = (100, 25) +player = Player(board_size) +game = Game([player], {"score": 0}, board_size=board_size, color = "pink", debug=TRUE) +game.play() \ No newline at end of file diff --git a/player.py b/player.py new file mode 100644 index 0000000..eb79bec --- /dev/null +++ b/player.py @@ -0,0 +1,28 @@ +class Player: + name = "player" + character = 'S' + + 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) + + elif keystroke.name == "KEY_DOWN": + 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