From 230259d941036becb260b2ecf9438b81e1edf497 Mon Sep 17 00:00:00 2001 From: Arthur 'Grizzly' Grisel-Davy Date: Sun, 29 Mar 2020 15:45:37 -0400 Subject: [PATCH] Add direction and assets --- asset/asset.svg | 211 +++++++++++++++++++++++++++++++++++++++-- asset/perso1.png | Bin 238 -> 0 bytes asset/perso1_down.png | Bin 0 -> 235 bytes asset/perso1_left.png | Bin 0 -> 242 bytes asset/perso1_right.png | Bin 0 -> 236 bytes asset/perso1_up.png | Bin 0 -> 231 bytes asset/perso2.png | Bin 238 -> 0 bytes asset/perso2_down.png | Bin 0 -> 229 bytes asset/perso2_left.png | Bin 0 -> 223 bytes asset/perso2_right.png | Bin 0 -> 224 bytes asset/perso2_up.png | Bin 0 -> 224 bytes main.py | 4 +- models.py | 10 +- 13 files changed, 213 insertions(+), 12 deletions(-) delete mode 100644 asset/perso1.png create mode 100644 asset/perso1_down.png create mode 100644 asset/perso1_left.png create mode 100644 asset/perso1_right.png create mode 100644 asset/perso1_up.png delete mode 100644 asset/perso2.png create mode 100644 asset/perso2_down.png create mode 100644 asset/perso2_left.png create mode 100644 asset/perso2_right.png create mode 100644 asset/perso2_up.png diff --git a/asset/asset.svg b/asset/asset.svg index 64228d0..f2a26f4 100644 --- a/asset/asset.svg +++ b/asset/asset.svg @@ -25,9 +25,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="11.2" - inkscape:cx="-1065.1419" - inkscape:cy="195.80413" + inkscape:zoom="2.8" + inkscape:cx="-990.35093" + inkscape:cy="138.68996" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -49,7 +49,7 @@ image/svg+xml - + @@ -58,12 +58,12 @@ inkscape:groupmode="layer" id="layer1"> + + + + + + + + + + + + + + + + + + + + + diff --git a/asset/perso1.png b/asset/perso1.png deleted file mode 100644 index a23c14847b5f1e27712fc5d2d507b0ae42633445..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nC-mSQK*5Dp-y;YjHK@;M7UB8wRq z_>O=u<5X=vX`rBFiEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$Qb0x7o-U3d z8I5l*2l5^;;9v-}vJ^E76b`dK!z8b>d&_qg2Yp__Nqq*p*q_NpM*aEnZl6{A-;)Bf za-B}GPcNRMzG~>y8LWIcM-JG;BGBm7(G}Y2RliK__4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1StJY5_^ zB3j?x*vQ*pz{7e`zU&Ma&rvQ(BOZqqCUwWI>ZQ{2W2`2YtnO*s`t4t-$D}P`dbYRa z75ybVBymFC{n49$&0DD-VR`R;mdKI;Vst0HwZ1 A?f?J) literal 0 HcmV?d00001 diff --git a/asset/perso1_left.png b/asset/perso1_left.png new file mode 100644 index 0000000000000000000000000000000000000000..52807def8fb09c9839d3631d44ea3d18fb2e08f4 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1U@JzX3_ zB3j>G-^klwz~gd}`&3sNOIuPa&vA}K26vAaES?|ZU%ooso631$v5}P9mw)9QDqF*X z&YLMe;bn?t*~L*J_+r)HfL&6*O_ft~e)0;vP`co{pxYr_H~pWt(x=jysR%I!`Q40+ X@458MR3}ORt!D6a^>bP0l+XkK*l$nd literal 0 HcmV?d00001 diff --git a/asset/perso1_right.png b/asset/perso1_right.png new file mode 100644 index 0000000000000000000000000000000000000000..cca4d3004022641fc0d30fcfde86ea126c36d30e GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1StJzX3_ zB3j>G-^klwz~ge!IO*t`0|9F$DEfA%w6ypsYW~xXt=+j%hp|G`|L`@V|9lgd+*|x5 z$Jl9~!Ufj_-45c7>uSpm#L8)j=ltXqdZ7dsydE@N<=ii2-TjVCu`IhdN(4C)HgNxo WV0Va@jJyK0l)=;0&t;ucLK6TxuTBgA literal 0 HcmV?d00001 diff --git a/asset/perso1_up.png b/asset/perso1_up.png new file mode 100644 index 0000000000000000000000000000000000000000..2c49444dedf978ecf40d375e402808d912254d67 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1T2JY5_^ zB3j>GI>_6gz~gZ7nr!63g)xnauNkToY7AxmSzrEe*@St8an_UAxQUzVWi~h08&0@o x_u*?r^y-C=|3|(5`Qm0>Gg}Z&=oR&bZSEv?*N)R4b^+~U@O1TaS?83{1OUK8OK|`I literal 0 HcmV?d00001 diff --git a/asset/perso2.png b/asset/perso2.png deleted file mode 100644 index 43ab79ecfb61ff4f43397ca3a7f5f120215459fd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nC-mSQK*5Dp-y;YjHK@;M7UB8wRq z_>O=u<5X=vX`rBFiEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$Qb0x7o-U3d z8I5l*2l5^;;9v-}>fdS*xH(|r876t1-CMr1IOy{VPU zmFskh-8_9--;Uc+i@zMptvezh<($E@(6HqgR)&h_q6EGMzMK3xCfD9~C4Pgg&e IbxsLQ0E#kA!2kdN diff --git a/asset/perso2_down.png b/asset/perso2_down.png new file mode 100644 index 0000000000000000000000000000000000000000..340fc499858a17f139db8149255901998ebdec8d GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1T&JY5_^ zB3j?x*vQ*pz{7emzb#c`8ZUQ5-~$zp!u2JOCwr?;TDD5MFQrCylFHRDGW9Jsi3+JW u;nlkBVZFs~xx=piw!IyH!6EDS0qOowR#&Drhxqpc8 literal 0 HcmV?d00001 diff --git a/asset/perso2_left.png b/asset/perso2_left.png new file mode 100644 index 0000000000000000000000000000000000000000..e9226a2d95b8ab7d0a8a1ca231a9a1a30d8a99a9 GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1TIJY5_^ zB3j>G-^klwz{7e`{>U1hqnpk#v2o5-5c%#Eu5La}*mJv^`I;sB_&g_F{F0;XG|ymy z5g6Wjow4rN&IL~ny*JNLNCm^E{!Wq}V5spjRe0$~cI(L9Kdu4oVeoYIb6Mw<&;$U# CJ4jUk literal 0 HcmV?d00001 diff --git a/asset/perso2_right.png b/asset/perso2_right.png new file mode 100644 index 0000000000000000000000000000000000000000..f3861e0f1996db5d8927ded8fbe6f3226890af77 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1TIJzX3_ zB3j>G-^hDFfrs^?e_QH*-V+RtE*CW)Jc@hy>dCPprOcIQ+mt1DJ5O5TTeVJDF4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1TIJzX3_ zB3j>G+Q`eG$aCO8OQK{~>R~1kj?emB@xCphs?00owtm)gfAUiPZOI3HwxILudi~pz q-v7uy?Rx&Rw8;b`Trl9$akZpaR#ztVTY5l?7(8A5T-G@yGywp~H%8Y0 literal 0 HcmV?d00001 diff --git a/main.py b/main.py index c963a09..92b5016 100644 --- a/main.py +++ b/main.py @@ -20,8 +20,8 @@ WHITE=(255,255,255) BLUE=(0,0,255) RED=(255,0,0) -perso1 = perso('Alice',200,200,pygame.K_o,pygame.K_l,pygame.K_k,pygame.K_m,'asset/perso1.png') -perso2 = perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,'asset/perso2.png') +perso1 = perso('Alice',200,200,pygame.K_o,pygame.K_l,pygame.K_k,pygame.K_m,'asset/perso1') +perso2 = perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,'asset/perso2') speed = 1 diff --git a/models.py b/models.py index fc49fbe..30984ab 100644 --- a/models.py +++ b/models.py @@ -15,7 +15,11 @@ class perso(): self.key_down = key_down self.key_left = key_left self.key_right = key_right - self.img = pygame.image.load(texture) + self.img_up = pygame.image.load(texture+'_up.png') + self.img_down = pygame.image.load(texture+'_down.png') + self.img_right = pygame.image.load(texture+'_right.png') + self.img_left = pygame.image.load(texture+'_left.png') + self.img = self.img_up self.size = self.img.get_size() def check_move(self,keystate,screen_width,screen_height,speed): @@ -23,18 +27,22 @@ class perso(): self.posx -= speed if self.posx <0: self.posx=0 + self.img = self.img_left if keystate[self.key_right]: self.posx += speed if self.posx+self.size[0] > screen_width: self.posx = screen_width-self.size[0] + self.img = self.img_right if keystate[self.key_up]: self.posy -= speed if self.posy < 0: self.posy = 0 + self.img = self.img_up if keystate[self.key_down]: self.posy += speed if self.posy+self.size[1] > screen_height: self.posy = screen_height-self.size[1] + self.img = self.img_down def draw(self,surface): surface.blit(self.img,(self.posx,self.posy)) \ No newline at end of file