From ac195773463b94927c4435fd876d245edffca571 Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Sat, 22 Apr 2023 11:45:32 +0200 Subject: [PATCH 1/4] add dust car rotation imgs --- imgs/dust_car_down.png | Bin 0 -> 1034 bytes imgs/{dust_car.png => dust_car_left.png} | Bin imgs/dust_car_right.png | Bin 0 -> 751 bytes imgs/dust_car_up.png | Bin 0 -> 1086 bytes main.py | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 imgs/dust_car_down.png rename imgs/{dust_car.png => dust_car_left.png} (100%) create mode 100644 imgs/dust_car_right.png create mode 100644 imgs/dust_car_up.png diff --git a/imgs/dust_car_down.png b/imgs/dust_car_down.png new file mode 100644 index 0000000000000000000000000000000000000000..359ff9e5e615d3ce813f90e18962f560574bf1fa GIT binary patch literal 1034 zcmV+l1oiugP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGqB>(^xB>_oNB=7(L1D{DmK~zXfwU$dr zR8bhm&wV)8XQNg$*(l+o7HwQ;o0bv`?FwoWx)6MokhDk_5kwIthO3Yvg3tsPk&A*d zL9nF;wUUIAvU03Z^Eoqj9{2XY_d9cEbdG}*{WzTYf9Ib2pL4(aoiihurpf*fGXMNr z5{U#?83^*Xe`) z(a}av**ookS$PUASYEU2txj*4>~_0tCkyDYu`#+=oRHbTVsA?u^y!zc+si6+&9!Ae zhbl?-loSWQe?qTm8il&9qbEN)>N(^37bWk=7ir z*Nr65PHAU5LlQfm2X=X~RA4s<$6ZkrISDi$&2IfPuwmHl=w*o&D$>X8=!Z=m4I&>y zS;=M{G0Xx*f;sv~!W<23POM<7GmN}h3B3qz(=^Hh0ZoG-n{|wtGaI@pG4ziY*Yg#* z)$6V;(oVZ`uT>P!hOH6?lm`OZIZsj*g6|}O6JW*OW4vGv5)zA?P3SY&h2t=HoCY%?no}uL`iY+vQ-+KLP?JBJh7W=%T(7CqW(|?qy?*X-S?cAF9Tr&Z%**jiiV0V<@pbTwHprLy82AUj~}57Wkg6vPqmb^rhX07*qoM6N<$ Eg0GO$^#A|> literal 0 HcmV?d00001 diff --git a/imgs/dust_car.png b/imgs/dust_car_left.png similarity index 100% rename from imgs/dust_car.png rename to imgs/dust_car_left.png diff --git a/imgs/dust_car_right.png b/imgs/dust_car_right.png new file mode 100644 index 0000000000000000000000000000000000000000..a330922feb08f67ffb6a5bf29d460cb5d7df8c53 GIT binary patch literal 751 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGqB>(^xB>_oNB=7(L0)$CKK~zXf<&@8F z5>XJxmjy~&TNlEQk_C1t?6N8s&in~P{{Uk&^w4-EAt{`Usf}XP5R*2BOB-$&qa11? zNz()mdVpT-Mb1TvzjaFl$~tt~Cm@7vgoFCcWU_Dez0b@WW}%d^>Hk4Dn@#Y!TrL`o z#^Z4k>Cs<}uGj0}W3d=TQF^@|yn5+$I`H{?9tfQ|y3kNXu~@{&Zh3EU)}(O0cTVBM zV5>O1ipPITGx2158&0W0U%Pne?HTh|_qiTcj}1q6s@Z6O??iue3RQ=Yq-}R7>oR58 zwatIy#P_E~H;%ZeOlFnRD_;M;(@P2j`T-}tG;$9#wl6LbgQu%{PnNIR*(U3)oIr^| zrJr5G(`k0!(Y^{q)S|KD*B2Ic3}@x}^LS-q1FPnwRg(>dM6c11fk~&+ztETvl0ykl z2%I5Mv`;Rf%z9TS%Nwh^tJl1AlQD13x$aHQEI!-Xl$9%Y*VY~;)uO9Tp~j0F6ZXeb zY>oH94KS_>4U!e*vM9+mu6lA`G~j;c#2qsa69P-@GTLzT@mw!0ZE2@}crNsI+1c*$ zYZC_s53nS!MuvW6;u>xr^!mlD^MDtjEp0R>-8Wj784E+xeSXHFXl%%B$|`f>Bi-Ed z83(lf7|ly7M$5X{4mrxO^!QWsWO8F&6&mRP%}lX3C^Mj8S};BW^dK98#<2?o0?;F^ zRtx@5)aR2Ss?}-?!{EL`p#Tx``5qn~f-jXy_?D*WN~HpkR;zXNzDr$bY)d#ChGPbU z0lXwh5J4gca|DAyvLO@-K?MKQdh`#VQDf;f2=iyNSvVPqMBo{(LWIjiA^{sxsT7I) hu0BP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGqB>(^xB>_oNB=7(L1Jg-FK~zXfrIk-; z6ImR`=glNDnW&rC+Qzu9E4AR-i}g@%S`f4fdRXzWAe1e#Na?9q+9E502yHw_1-06O z#fl&b78E3)9`>*o+k<;r7R@3x)mm+v(l&o4lNrC6-F8AAkB3i5gW=-`bzSF%jU-82*;EQ` z+F6H_ul|&Sq`}$TvSt|E@TOAeTh*IMCv|;KKqU>1eR%ue`Ezbq)JRfub2B$=+|Uq( z0^bsNJ5dxbhBuKJ5ZIFGrnyO!=2IzdSe!F8r$kO=cxbc*eIpl9EXdEiAOe;!E{nkQ z`M9<~pI0~5&3a~Lrmd}w^vK9aBog^xxABWarV_oqy`=m4`bdcMF*Gz3jYgl?K*Q-{ z3_}!(gS6McVq{HN@rv-Q@%oq*MX{VhE|&Kag6GJLDSutGb9b#QB)NFWdxUmQIQvv>GrLv)L08^^}RLZJ{M63}pB zZRs!=t5pIR|Gt}QGcx{rcWys^gt2RL@h)49yZN%&YA}H4RaJ9!4P+Af($eLR z#R?>UKY9M@)o3tS&~?eWxMf+^G|gJ&!b9T*@U6VvVa5esAL3TsPseXuhd6QI0A_k* zVqyZisj11c)`WB0V#A>NXS%z|Bre2a^w(Q@;dFI%Va9Lt_xF>>1)5|An2 z#+O);bs4398KCTHBuZbDgo9^job}Q(`3+Rc`nwQ>&-HLSri{uQGynhq07*qoM6N<$ Eg2Si_z5oCK literal 0 HcmV?d00001 diff --git a/main.py b/main.py index 6fd945a..467a645 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ pygame.init() canvas = pygame.display.set_mode((800, 800)) pygame.display.set_caption("Inteligentna śmieciarka") -dust_car_pil = Image.open('imgs/dust_car.png') +dust_car_pil = Image.open('imgs/dust_car_right.png') game_context = GameContext() game_context.dust_car_pil = dust_car_pil From aba828546977af983eae0d6410848bb161d75340 Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Sat, 22 Apr 2023 12:04:08 +0200 Subject: [PATCH 2/4] street grid cell type --- gameContext.py | 12 +++++++++++- gridCellType.py | 7 +++++++ street.py | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gridCellType.py diff --git a/gameContext.py b/gameContext.py index d749c04..37939b0 100644 --- a/gameContext.py +++ b/gameContext.py @@ -1,6 +1,7 @@ -from typing import Tuple, List +from typing import Tuple, List, Dict import pygame from PIL import Image +from gridCellType import GridCellType class GameContext: dust_car_speed = 20 @@ -11,6 +12,15 @@ class GameContext: canvas = None _cell_size: int = 30 city = None + grid: Dict[Tuple[int, int], GridCellType] = {} + + def __init__(self) -> None: + self._init_grid() + + def _init_grid(self) -> None: + for i in range(1, 28): + for j in range(1, 28): + self.grid[(i, j)] = GridCellType.NOTHING def render_in_cell(self, cell: Tuple[int, int], img_path: str): img = Image.open(img_path) diff --git a/gridCellType.py b/gridCellType.py new file mode 100644 index 0000000..d8e5e42 --- /dev/null +++ b/gridCellType.py @@ -0,0 +1,7 @@ +from enum import Enum + +class GridCellType(Enum): + NOTHING = 0 + STREET_VERTICAL = 1 + STREET_HORIZONTAL = 2 + GARBAGE_CAN = 3 \ No newline at end of file diff --git a/street.py b/street.py index 9287394..3ec4bd6 100644 --- a/street.py +++ b/street.py @@ -1,6 +1,7 @@ from enum import Enum from typing import Tuple from gameContext import GameContext +from gridCellType import GridCellType class StreetType (Enum): VERTICAL = 0 @@ -23,3 +24,4 @@ class Street: img_str: str = 'imgs/street_vertical.png' if self.street_type == StreetType.VERTICAL else 'imgs/street_horizontal.png' cell: Tuple[int, int] = (self.row_or_column, i) if self.street_type == StreetType.VERTICAL else (i, self.row_or_column) game_context.render_in_cell(cell, img_str) + game_context.grid[cell] = GridCellType.STREET_HORIZONTAL if self.street_type == StreetType.HORIZONTAL else GridCellType.STREET_VERTICAL From 9323b5a507d96d5c4df738cf357414ba8b62bacf Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Sat, 22 Apr 2023 12:06:01 +0200 Subject: [PATCH 3/4] add agent action type --- agentActionType.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 agentActionType.py diff --git a/agentActionType.py b/agentActionType.py new file mode 100644 index 0000000..b251b0c --- /dev/null +++ b/agentActionType.py @@ -0,0 +1,6 @@ +from enum import Enum + +class AgentActionType (Enum): + MOVE_FORWARD = 0 + TURN_LEFT = 1 + TURN_RIGHT = 2 \ No newline at end of file From 2b10bb8650a11941f74685b05116e28ddb360eaa Mon Sep 17 00:00:00 2001 From: Pawel Felcyn Date: Sat, 22 Apr 2023 12:11:06 +0200 Subject: [PATCH 4/4] garbage can cell type --- garbageCan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/garbageCan.py b/garbageCan.py index 8585123..782e6f3 100644 --- a/garbageCan.py +++ b/garbageCan.py @@ -1,6 +1,7 @@ from garbage import Garbage from typing import List, Tuple from gameContext import GameContext +from gridCellType import GridCellType class GarbageCan: position: Tuple[int, int] @@ -17,4 +18,5 @@ class GarbageCan: self.garbage.remove(garbage) def render(self, game_context: GameContext) -> None: - game_context.render_in_cell(self.position, "imgs/container.png") \ No newline at end of file + game_context.render_in_cell(self.position, "imgs/container.png") + game_context.grid[self.position] = GridCellType.GARBAGE_CAN \ No newline at end of file