From d1fcc7142b1622105faabc951b7df355234f9f64 Mon Sep 17 00:00:00 2001 From: moritz Date: Tue, 9 Jul 2024 10:16:57 +0200 Subject: [PATCH] Finalisierung Scene 2 --- code/__pycache__/setup.cpython-312.pyc | Bin 5903 -> 8613 bytes code/__pycache__/sprites.cpython-312.pyc | Bin 6618 -> 6801 bytes code/setup.py | 76 ++++++++++++++++++++++- code/simulation.py | 12 +++- code/sprites.py | 4 ++ 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/code/__pycache__/setup.cpython-312.pyc b/code/__pycache__/setup.cpython-312.pyc index 13ada76ce79d1d281b23c264a2f9b35d2cb37f23..91c876c452cbf240894aae270d1727fad231e081 100644 GIT binary patch delta 2465 zcmb7EUuauZ7(eIc{>%N7Cb>zPv`zm+XO?ws_eZAHt()s6h+P#6K8#K&J6)F6IXQ{q z$_?#c4+RTbIidq!gy}TC7;A4?d_6_h7g6Nqq48?u}{Ixv-wVFXw#s z`}6z0@0{;y@27*I?`+#3u=t(1b6p+tp(NcqpUoOfxk64WmuOD?;+4;3N(5EX3dxf) z72RrwDKWVmU`knb1LBmDO9fnzFxi!vwxlnr=#Y@I;u3LHiBm;_h!vK3yI50Z}R^GfWr>8Sqx|~ zJHR4k$qOT~=(aFU!!R*MfwTi*`npX&S3+EAk@|ZI`)YDhU2>8b)O#9KF5WPvS2-5P z)E-{Dlo-`x4eOV9gdmAVK}L*|R1;%Hm$+#p#C4-nY#2$gY-Ge9Ga+=-5<}*0YI+(U zfTUz*#P{&OWOfSKN{Zj$JYXe6n}wPQ@s1T$!Y-Mx#T_-)?&@yPHC)TJ-H_Xq*Xv43 zL1kWX9McWw>q|{sDt@;*k5qn?;1R8Narm@up5+&d#loBU*9)u?MCDtkcLf2S1H|Bc;(hxRjff4q zhxUs0&^K}f^u!;bemeAJXVXoU4vU}TD_v(nT3hG}e2{y8DujH94~pdHS27XGBo=@l zyagsNsf*hDKiP;@6Y9QD?4>9TR#lCvbd+XW;eJ%5rZ4qFmX#6}V`^KHSwJB zIq2#vFgZ#{kS5A8yG+0BPZjdQU@!F&?;09ng$2PW{c+AtSXpvye+bm3%`W9!+ zEei;joN5MIaE+Mk4V4-NPUp_gU6x5{D zs8P4;sF!Tf6^u`7)daM<1gblo%asB2*XO3gcA$GZ^l(eNIG{RlXX3P*8%HQ_OgZ~$eSXm${fPvY?ys!Vsl zc1rgrT<3nC!OvNQ#}Lv8yAW{h@jVFL2pYl@2)h9aH^5g;O^O$t=<(#}s(fZmj{YR4R^-%j%br!ads8LR=4-|4 zgC9FTM0VXJh7y}qe$nmOiB&zd7ItQpH9Isbt%aOx{Jlx>TGM%h&rNOwL2t7~oC|ja zeDNXib+~^Qe$u>84ZMn_NLj5p_~_M*Hew~Ow=bL7WjV`RA(@=IuD*3CKXzfADycdz@} zacqe{Yn?lnKBd}j22HgK1+|F+?a7(PDnejr;~J_-Eg4GsZmdwXrBbb>F%@o^0ah7z zsLC{Iz^1VezF8Av!b8*&-Xn8e7v&|XWia`Q0Ua$lX{@6y4@pd=_6>*MiV9jk5|vL_ zS(wpNoQ64#^l9hxL7F>+=I)TT$0#}~jklCONudciuNSQC&fvRI+U_ew5&zQUFj9J; zuLj=gP?DGeCCkHqx>I1mEdFDT-jL3`VZ8sEqagilhW-$ezeCbly8<8V9K5tM;Nm>| zw0&el3?D=oUg#50#U4E6{(bDj7o39)oPj*a10g;v5dx#!pCdjR>1Q{IhvLv7>2Z@; z%x0K5%w;h)QZom3M}{`>l7z);@_>t&3|~p^Q21V!q=@g96riqNZ$#Bx E8~-`k?*IS* diff --git a/code/__pycache__/sprites.cpython-312.pyc b/code/__pycache__/sprites.cpython-312.pyc index 0cc9210d1954116931b89163d204506ca553de3d..4847a2fc274996efe710244afcae438e38c76aae 100644 GIT binary patch delta 221 zcmca*JkgZ*G%qg~0}w3x*pv2QBX2qn6Bpy;GM)~m6xPXgJcgWX*)a?ZMan76lLNWM zC!goxnjFBb$Wh5y!x+q<$v&BhSBW*#f`x%$vI=iFW5(nfUbD$fyh1`Em$YneNXd4% z^m}%C_ILxClb7*cWHg;z!FP_8lU4Sc*k*73>x^u+K&y-WC+A7XO?DH^W3<`4RWOf< z(PeU`gu&zxk>8BIlLJKeFa}KK6-#Dx-drg5oslsFC^?5Qcru%0g_tR$bVpc!Y-j9s UUd4;NieDIj0$++IPmy#300_oGKL7v# delta 170 zcmbPeddryiG%qg~0}%8a>P`#U$eYf?)dA#9XQ*LJVVuNkIC(vfKT9x!Cfno|UZu&a zdBYhkCNuMyP0r*y%4j%QpZ^>yE351`zRgSm*BRL?fjW!*CqEF8oBUTWkI`atj!+&G zqr+qcNrTDUqQ4nEC$o#~Vf2}NL@b%nezS)7cSgnlpyV7z|H*qLE5r;Lr8~m@H7 U^D18CRs6yL6!?-g*;~pD00X%)PXGV_ diff --git a/code/setup.py b/code/setup.py index cf347da..23cc49d 100644 --- a/code/setup.py +++ b/code/setup.py @@ -19,7 +19,7 @@ def setup_streets_scene_1(): return streets_list -def setup_lanterns_detectors_scene_1(SCREEN_WIDTH): +def setup_lanterns_detectors_scene_1(): lantern_list = [] detectors_list = [] @@ -115,4 +115,76 @@ def setup_streets_scene_2(): streets_list = [street_1, street_2, street_3, street_4, street_5, street_6, street_7, street_8] - return streets_list \ No newline at end of file + return streets_list + +def setup_lanterns_detectors_scene_2(): + + lantern_list = [] + detectors_list = [] + + # intersection 1 + cross_lantern_1 = sprites.Lanterns(825, 425, 25, 25, id=1, street="street_1", crossing_id=1) + cross_lantern_2 = sprites.Lanterns(975, 425, 25, 25, id=1, street="street_2", crossing_id=1) + cross_lantern_3 = sprites.Lanterns(975, 575, 25, 25, id=1, street="street_3", crossing_id=1) + cross_lantern_4 = sprites.Lanterns(825, 575, 25, 25, id=1, street="street_4", crossing_id=1) + cross_detector_1 = sprites.Detectors(900, 500, 260, 260, crossing_id=1) + + lantern_list.extend([cross_lantern_1, cross_lantern_2, cross_lantern_3, cross_lantern_4]) + detectors_list.append(cross_detector_1) + + # Street 1 + for y_pos in range(425, 576, 150): + print("street 1") + x_pos = 725 + id = 2 + while x_pos >= 25: + lantern = sprites.Lanterns(x_pos, y_pos, 25, 25, id, street="street_1") + lantern_list.append(lantern) + detector = sprites.Detectors(x_pos, y_pos, 75, 90, id, street="street_1") + detectors_list.append(detector) + x_pos -= 100 + id += 1 + + # Street 2 + for x_pos in range(825, 976, 150): + y_pos = 325 + id = 2 + while y_pos >= 25: + lantern = sprites.Lanterns(x_pos, y_pos, 25, 25, id, street="street_2") + lantern_list.append(lantern) + detector = sprites.Detectors(x_pos, y_pos, 200, 75, id, street="street_2") + detectors_list.append(detector) + print(y_pos) + y_pos -= 100 + id += 1 + + # Street 3 + for y_pos in range(425, 576, 150): + print("street 1") + x_pos = 1075 + id = 2 + while x_pos <= 1775: + lantern = sprites.Lanterns(x_pos, y_pos, 25, 25, id, street="street_3") + lantern_list.append(lantern) + detector = sprites.Detectors(x_pos, y_pos, 75, 90, id, street="street_3") + detectors_list.append(detector) + x_pos += 100 + id += 1 + + # Street 4 + for x_pos in range(825, 976, 150): + y_pos = 675 + id = 2 + while y_pos <= 975: + lantern = sprites.Lanterns(x_pos, y_pos, 25, 25, id, street="street_4") + lantern_list.append(lantern) + detector = sprites.Detectors(x_pos, y_pos, 200, 75, id, street="street_4") + detectors_list.append(detector) + print(y_pos) + y_pos += 100 + id += 1 + + + + return lantern_list, detectors_list + diff --git a/code/simulation.py b/code/simulation.py index c14e413..8c43092 100644 --- a/code/simulation.py +++ b/code/simulation.py @@ -22,7 +22,11 @@ streets_list_scene_2 = setup.setup_streets_scene_2() lanterns_scene_1 = pygame.sprite.Group() detectors_scene_1 = pygame.sprite.Group() -lantern_list_scene_1, detectors_list_scene_1 = setup.setup_lanterns_detectors_scene_1(SCREEN_WIDTH) +lantern_list_scene_1, detectors_list_scene_1 = setup.setup_lanterns_detectors_scene_1() + +lanterns_scene_2 = pygame.sprite.Group() +detectors_scene_2 = pygame.sprite.Group() +lantern_list_scene_2, detectors_list_scene_2 = setup.setup_lanterns_detectors_scene_2() current_scene = "scene_1" @@ -34,6 +38,10 @@ for item in streets_list_scene_1: streets_scene_1.add(item) for item in streets_list_scene_2: streets_scene_2.add(item) +for item in lantern_list_scene_2: + lanterns_scene_2.add(item) +for item in detectors_list_scene_2: + detectors_scene_2.add(item) @@ -47,7 +55,7 @@ if __name__ == "__main__": if current_scene == "scene_1": functions.scene_1(screen, detectors_scene_1, streets_scene_1, lanterns_scene_1, player) if current_scene == "scene_2": - functions.scene_2(screen, detectors_scene_1, streets_scene_2, lanterns_scene_1, player) + functions.scene_2(screen, detectors_scene_2, streets_scene_2, lanterns_scene_2, player) current_scene = player.sprite.left_scene(current_scene) diff --git a/code/sprites.py b/code/sprites.py index d96f6ed..38f3d0f 100644 --- a/code/sprites.py +++ b/code/sprites.py @@ -44,6 +44,10 @@ class Player(pygame.sprite.Sprite): self.rect.x = 900 self.rect.y = 1050 return "scene_2" + if current_scene == "scene_2" and self.rect.y >= 1080: + self.rect.x = 900 + self.rect.y = -80 + return "scene_1" return current_scene def update(self):