From 745f0905bf332d44f3b4911dece6fa64b33a4f39 Mon Sep 17 00:00:00 2001 From: Skullheadx <704277@pdsb.net> Date: Mon, 11 Jul 2022 02:10:05 -0400 Subject: [PATCH] added player run animation --- Assets/player/Running_animation.gif | Bin 0 -> 3064 bytes Enemy.py | 2 +- Game.py | 24 +++--- Player.py | 117 ++++++++++++++++++---------- 4 files changed, 92 insertions(+), 51 deletions(-) create mode 100644 Assets/player/Running_animation.gif diff --git a/Assets/player/Running_animation.gif b/Assets/player/Running_animation.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ca664daaa97bf390addc6aa91e06b8b3a5cdf18 GIT binary patch literal 3064 zcmZ?wbh9u|bYO5`C}&_${Lk&@8WQa67~pE8XTZ$Jz`&sRlZBIufq_AXfq{Vmq^yO3 zfnkrfMWuq)JPp$ld&?=&&fdO(w-cNfkP9Hs*nv~m>ov~|H-}>(Q!i3aAt(j`tE+8uy7+C)+DD44CKTi2BM1#f%I;Zj}w;Nh+7*PpxJRTla7P5IHS zJFisFUsxxyWirEs%Lkg5@F|(B*dTkjO-Q3+5yQkLT^msyiyg-=DzR{|PK-I=u*r$7 zSKQOKK}7UvQyZ@VDp^vDx7(4bNIl5)7#cQ-Z^)j`;WCPHcpA2 z0z3^i%MJ!uh%9V5EY#?sAj0;dIPgK8C|A>r1u6^fACPG{Yj@zWa_P5*cteSrT2L(1 z^EC1CwYKu}SFj84we<1{^jok`oZQ1dO;E@nqmiM9M_6#dLd|leDZ(38E@0pn5@cAr zjz>g9SY(sX!R$tiZ{NNR$r+GbA|axB{lW!Ez;o+ES?~UZnyEDvdu>}WslPNgBo1p>T z_5eA+jSftP1-Lylz*~8mlv?<@dH6ec1Ox>Iczc^B2uzvUS39GPe@?A{Q0syYhQ;*@ zn--UGEngudv~D^7VxeVC3l`7ZS+QW--ql9J2M!2#2%kE=LFC-I4GfbmY+x^|6)h>r zxFL3IK~{yRn5wwMMdfEN7+$@2d-44SaWTmkQr}e-QG-vCL4%={_!0(Eyj;I<0Xe-s zdGzS?(W7UUPC2-7UVCzUVM6MZs*045sMd;_)TG??-Sx<&4LnS#$YA^L&`{vPBhho$1A;h-u z{sbOLlNW&#-ZcvKRB06c+0p1M<0(9=_D#X011&mob~PuOjQZMVdmHVoQFjsI;G5^{ zB*5@dSffF}qnC{l5yb)w{0tJL*GDW=n6j`%wb56<|ItV1yLIdZ{59G< zJPnPYVyT&@jgPOhlb^pvK#;FvBA?*oKmnm?GkE!D3AP%{6H=bQBfPXqIY)U#d#CWW zs*Mb#D^|9z*(O|ah>JmBo|eeTlN%0g641(FU)IKTK=@MIwOci}ZkOG?cK^XPkus6T zB7F{AqI{>`zZ6`mDJK3+f?ZTnN>X#(5f!t77Z(zl82ClC)+8hwD6~5iN=fZ zD5^i{#0tU1N4pEHlKy;fRAHQ?q|35GMvw^+@SwUtl;pbL|Ns9jom1>JjP~r=BO#)C z>hR$wj~*RbHajFV4HEWemQI0$Iy_6Uet^{l^VTd_)~qmp(;p^hx$C8Mk9W!RKL}PsFYH|7L(`U~eDY$rKzq#-g;o0^gJMP`$FAx=Z zqQbY-o=Z$rRFi+XinzpQNl7WKQWn9F(lY<-v%mH3xS%*;pR*>P(h=o?g>y{!o|b65 zm~h}ohn!I#2U6;$R{4MJ*eXZ}r-Vf9nOFx8TX+%0dUi;Z|Dx=Tg<|5jZ%eQo))14F zc=F_a?IYFa7a3k(e7E7l@=qNsQc`cEf2pBW0VLL-*DqYK*D!(<4lSKiP8~k%?H2Up z(IW{F)iX<{TsyWZB_ygnIUZ6zz=M+YFDL{-qfUi|6GH;PRp2E~Lo9Ul3c)&$Lh@(}JD^_GrVr!ECtH3mttuhu>`}vEj?$%no2x= self.dashCooldown): - self.dashPossible = True - else: - self.dashPossible = False - if (timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True): - self.move_left( - self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function) - self.dashPossible = False - self.lastDash = datetime.utcnow() - self.lastPressedLeft = datetime.utcnow() - - if pressed[pg.K_d] or pressed[pg.K_RIGHT]: + # if (self.lastValueL == False): + # timeSincePressed = datetime.utcnow() - self.lastPressedLeft + # timeSinceLastDash = datetime.utcnow() - self.lastDash + # if (timeSinceLastDash >= self.dashCooldown): + # self.dashPossible = False # True to enable dash + # else: + # self.dashPossible = False + # if (timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True): + # self.move_left( + # self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function) + # self.dashPossible = False + # self.lastDash = datetime.utcnow() + # self.lastPressedLeft = datetime.utcnow() + + elif pressed[pg.K_d] or pressed[pg.K_RIGHT]: + if self.state != "ATTACK": + if self.state != "RUN": + self.current_frame = 0 + self.state = "RUN" + self.move_right() - if (self.lastValueR == False): - timeSincePressed = datetime.utcnow() - self.lastPressedRight - timeSinceLastDash = datetime.utcnow() - self.lastDash - if (timeSinceLastDash >= self.dashCooldown): - self.dashPossible = True - else: - self.dashPossible = False - if (timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True): - self.lastDash = datetime.utcnow() - self.dashPossible = False - self.move_right( - self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function) - self.lastPressedRight = datetime.utcnow() - - self.lastValueL = pressed[pg.K_a] or pressed[pg.K_LEFT] - self.lastValueR = pressed[pg.K_d] or pressed[pg.K_RIGHT] + # if (self.lastValueR == False): + # timeSincePressed = datetime.utcnow() - self.lastPressedRight + # timeSinceLastDash = datetime.utcnow() - self.lastDash + # if (timeSinceLastDash >= self.dashCooldown): + # self.dashPossible = False # True to enable dash + # else: + # self.dashPossible = False + # if (timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True): + # self.lastDash = datetime.utcnow() + # self.dashPossible = False + # self.move_right( + # self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function) + # self.lastPressedRight = datetime.utcnow() + else: + if self.state == "RUN": + self.state = "IDLE" + + # self.lastValueL = pressed[pg.K_a] or pressed[pg.K_LEFT] + # self.lastValueR = pressed[pg.K_d] or pressed[pg.K_RIGHT] mouse_pressed = pg.mouse.get_pressed(3) if mouse_pressed[0]: # LMB @@ -205,9 +244,9 @@ class Player(Actor): # super().draw(surf) # print(self.position, self.velocity, get_display_rect(self.get_collision_rect()).topleft, Setup.camera_offset) # pg.draw.rect(surf, self.colour, get_display_rect(self.get_collision_rect()), border_radius=8) - pg.draw.rect(surf, (255, 0, 0), get_display_rect(self.weapon.get_collision_rect()), width=3) + # pg.draw.rect(surf, (255, 0, 0), get_display_rect(self.weapon.get_collision_rect()), width=3) - pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2) + # pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2) # pg.draw.rect(surf,self.colour,pg.Rect(center, (self.width, self.height)),border_radius=8) -- 2.54.0