From 98f6f2716cde44f93d512de04cc2e4044ccde87f Mon Sep 17 00:00:00 2001 From: kdang Date: Fri, 16 Jan 2026 09:36:38 -0500 Subject: [PATCH] I will finish the rest of the project at home --- __pycache__/catcher.cpython-311.pyc | Bin 3651 -> 4153 bytes __pycache__/fruit.cpython-311.pyc | Bin 3601 -> 3107 bytes __pycache__/manager.cpython-311.pyc | Bin 1384 -> 1473 bytes catcher.py | 10 +++++++++- fruit.py | 26 ++++++++------------------ game.py | 3 ++- manager.py | 5 +++-- pyproject.toml | 12 ++++++++++-- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/__pycache__/catcher.cpython-311.pyc b/__pycache__/catcher.cpython-311.pyc index 978f128b709d1488c7d7105aa6fbb3f8e8f1737e..5fbf1644b88e39881e42c6f3d4941c48942d39e4 100644 GIT binary patch delta 1139 zcmZ{j&rcIU6vt`oBT{sfL&U#8f4=Yd5Nr5*AgC(L_JfX+Of)n~oeC*=F z*i3L*=Qo8>dWwG*D!dt&ccpiA@ZrdYt10bj;)3Y29mGXI9H5ol5U6BjNA1# z3eO=L2iaKQKia__BMev~nbOL;=dwg}`YkLEX1pc0ledzq@pW(GrnfOm1jV0G zOSaVd4YmI1zID~Nsru5Y4}5ovR=d)wmR9#@o2r(&49_f6TUWL1tRo+DtxuMzVihQ{ z;LHT1#ZNo6ery+OM;ro}G{U-JHb7IX21f1!Iso=!X`vvd2jlu!uJX3Ecg`BxhM_@1 z{2X@Tv0gN-h!U)R3)sS)E{%5c7S|WMmBVpf@9v19>;UNxcy5dfHuaKxC6 z1{bV0v1atwBD@G}G&_ty?HT6FS`Y(>y@+Cj^*hw#3W1h!53p3YGH!*-N@uN0YRZxV zs%#SUrT`BgR*oLQ2qS)*X$L{Wv1ulP&9F`@_8*7-kb9*o|9D{K{}UbK1k?Zk delta 696 zcmZvZ&ui0Q7{~J_O`=JYSedNrIvTQ#CBnKY)=`D2?1!g$DePKe_fpepTiyh;H7I)V zEYHP*D2O0VlWuTg@2c z7T}?BS=|-t0zYt| zxI~62^?b=wnZYZP;~hE(Bi8FshQktaCm{p20uR(}@&fkN$5W#d%lsLuLY8msezF!v z)*=j#&B7(^o3VsFGV{AF%A0EX{3fcfGl;XPUXaNBfHrBU@X$_e@+&Tnho{#4sCk33 za+6U%qK!$ZyZ2l#k_w7@a=PbVMONckc7Y?5IsOqW!$EeQRKPO6E9n+%AemKCg_^nA zHrXup6%liY6^=yR4Z{9Sf531QTSk-+7NUSShrm@?8F2++BXWrJP8{?Q7=@4Ei@9ZK sa(OHqA`k1kfw^Btd`Kt%0eu#m1poj5 diff --git a/__pycache__/fruit.cpython-311.pyc b/__pycache__/fruit.cpython-311.pyc index f71363c79a476737a55132e25b2159ecd27b54fb..ae2f4e7075b02ee7be749f586f0fc0aecad23602 100644 GIT binary patch delta 836 zcmZvZ%WD%+6vpSyD>IYHqu9n;O&_*RGf8|Dsfb8S6>1kENCg`ZLd;BJt0v(lU{fZ7 z3qeF7?Gajc5uqwwxpv{}A5bY+W@C5KT|~Ev_e^L+>mBZIhB@DP-0v{vm!a#2SIi3XxirH3H#-)D{PQDUl(k_6t25N(YQ^TJls|z@Ws;$DK#kL zd^UlU7CLE)YbFh$9lH;!6u`*Br@p8PZCeMB%P780uS{Z1Rt%nv>7@ zCsQBx$3F%W8^Hv;Qch?cGe_X35+gQ5)pKM5%4&*lN{~=TU{f6<;LSqx*IU+yGTyK WEuS@E5T@9TZ}{)We*!efdjAG3xWRV- delta 1282 zcmb7DOHWfl6rQ=SJ|RtdK@eMzS6f;h1rdBijE_i2Aki*0DW&&TDa69G^2)6&+-SlA zG9=cOO^m1^F5I|qCyD!(G(v7PapMA4HTnZQbBiUR1mn4PzB}j4$$V$dH}^%|+NtVS zRaI65HtUE?J~F+lKF#9^+QYZ=uCzeA&2?iMmy%dQ$u>BIHer+uqZPM;LWtPF_X)%f zA6=T5PDH1Yx;;wNNJ4+GF zwx*!pbXjb$H?bwWpyNg2r5oZEtkXU5>gjcBW+3Nifw$mj$!*+_o*ZWtF__FUbC!?1$L;NM=4Kd*Cg|p4Y*=94L8tBL?$t ztv##P)<;+2Db~|*X={kJS(jqu!DK3_TOx`Qj@(u6r+j7thew3fOd1(Ad-}CoaM+h8-(A{bKg^AJ&@Ju*Q|O7BoTQ59Hj}+F)5ehNV(v0aQM?jQc8+Rw&YE zDmBChbKL@ePB@yFP7vc4BOMSVeg*-SDwY~(w9Ur)M!XEVY0@$*oq=ic2mNRXHUCro z@AQJycu4=RN9Yf+|I)vK4qJm}U7DFxqiT{qwAR{sScPr|gY>yI+FvCGi>M54QFIqk i8LF$~3tKr6i930G`$>LW8a@|WQ5CM|ZWG!L?Qj_DDrIlHV_<+nJejss+v7(3@NEfpJ z2?Zc15&%i@PM*Q6tnUhBHZa`f5uV^Up{UcZ$FGC&u7K!-!WoJa(q^PAb-SuaYc5+98zTb~gF8bCOAA8^ z>oO(=hSfj}0a5G|i!?YHZ?Pq34E@Tu=VyIzS#t1YJh#>%EZ7_o-lbdBKTQs>10Ze%JCm&_F)t-Q7wqs`JVmJ`MfrNEMMe2V#YJpjlR<2 zKczG$)vibuC;{?*aWRmX?93`3DS3eb1>IoKxqym3u<$Sf-HAzj1c`mYA_2A<02~Nx Ang9R* diff --git a/catcher.py b/catcher.py index a93dedd..141985f 100644 --- a/catcher.py +++ b/catcher.py @@ -8,7 +8,7 @@ class CatcherPiece: def play_turn(self, game): fruit = game.get_agent_by_name("fruit") - if new_position == fruit.position: + if self.position == fruit.position: game.state['Score'] += 1 class Catcher: @@ -36,6 +36,14 @@ class Catcher: if x + self.width < width: self.position = (x+1, y) self.update_piece_positions() + self.checkforfruitcollision(game) + + def checkforfruitcollision(self, game): + for piece in self.pieces: + if piece.collision(game): + game.remove_agent(fruit) + game.state['Score'] += 1 + def create_pieces(self, game): x, y = self.position diff --git a/fruit.py b/fruit.py index 2c76f43..a7e84f0 100644 --- a/fruit.py +++ b/fruit.py @@ -23,8 +23,8 @@ class Fruit: def __init__(self, position, game, shape_offsets): self.position = position - self.blocks = {} - for shape in shape_offsets: + self.pieces = {} + for offset in shape_offsets: self.create_shape(game, offset) def play_turn(self, game): @@ -32,22 +32,17 @@ class Fruit: x, y = self.position if y == 29: game.remove_agent(self) - game.state['Score'] -= 3 + game.end() else: catcher = game.get_agent_by_name("catcher") new_position = (x, y + 1) - if new_position == catcher.position: - game.remove_agent(self) - game.state['Score'] += 1 - else: - self.position = new_position def create_shape(self, game, offset): x, y = self.position ox, oy = offset - fruit = Fruit((x + ox, y + oy)) - self.fruits[offset] = fruit - game.add_agent(fruit) + piece = FruitPiece((x + ox, y + oy)) + self.pieces[offset] = piece + game.add_agent(piece) def update_piece_positions(self): if game.turn_number % 3 == 0: @@ -55,12 +50,7 @@ class Fruit: x, y = self.position if y == 29: game.remove_agent(self) - game.state['Score'] -= 3 + game.end() else: catcher = game.get_agent_by_name("catcher") - new_position = (x, y + 1) - if new_position == catcher.position: - game.remove_agent(self) - game.state['Score'] += 1 - else: - self.position = new_position \ No newline at end of file + new_position = (x, y + 1) \ No newline at end of file diff --git a/game.py b/game.py index 1de0f9c..4e7af94 100644 --- a/game.py +++ b/game.py @@ -2,6 +2,7 @@ from random import randint from retro.game import Game from catcher import Catcher from manager import FruitManager +import json WIDTH = 27 HEIGHT = 30 @@ -13,4 +14,4 @@ agents = [ state = {'Score': 0} game = Game(agents, state, board_size=(WIDTH, HEIGHT), framerate=24, color="white_on_indigo") -game.play() \ No newline at end of file +game.play() \ No newline at end of file diff --git a/manager.py b/manager.py index a69fe37..9fdefbf 100644 --- a/manager.py +++ b/manager.py @@ -1,5 +1,5 @@ from fruit import Fruit, SHAPE_DEFINITIONS -from random import choice +from random import choice, randint from retro.errors import AgentNotFoundByName class FruitManager: @@ -13,5 +13,6 @@ class FruitManager: self.create_piece(game) def create_piece(self, game): - fruit = Fruit((14, 1), game, choice(SHAPE_DEFINITIONS)) + x = randint(0, 26) + fruit = Fruit((x, 1), game, choice(SHAPE_DEFINITIONS)) game.add_agent(fruit) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f7df288..0cc4733 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [project] -name = "project-game" +name = "fruit-catcher" version = "0.1.0" description = "" authors = [ - {name = "Chris Proctor",email = "chris@chrisproctor.net"} + {name = "Kayden Dang, Connor ",email = "chris@chrisproctor.net"} ] license = {text = "MIT"} readme = "README.md" @@ -12,6 +12,14 @@ dependencies = [ "retro-games (>=1.1.1,<2.0.0)" ] +[project.scripts] +play = "game:play" + +[tool.retro] +authors = "Kayden, Connor" +description = "Use your buttons to help the catcher catch the falling fruits. Don't drop too many fruits!" +instructions = "SCore as many points as possible before losing by using the two designated buttons to move left and right." +result_file = "result.json" [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"]