Add enemies that can die
This commit is contained in:
parent
387890a069
commit
f59ca154d1
3 changed files with 122 additions and 47 deletions
107
asset/asset.svg
107
asset/asset.svg
|
@ -25,9 +25,9 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.11079427"
|
||||
inkscape:cx="-1017.0394"
|
||||
inkscape:cy="-2198.0564"
|
||||
inkscape:zoom="0.31337352"
|
||||
inkscape:cx="-3450.9727"
|
||||
inkscape:cy="-20.573896"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
|
@ -60,52 +60,101 @@
|
|||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="back"
|
||||
style="display:inline">
|
||||
style="display:inline;opacity:1">
|
||||
<rect
|
||||
style="opacity:1;fill:#d38d5f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:4.30875349;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect925"
|
||||
width="838.43549"
|
||||
height="520.83234"
|
||||
x="-1316.5852"
|
||||
y="19.51149" />
|
||||
y="19.51149"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -1270,353.88542 h 66.1458"
|
||||
id="path936"
|
||||
inkscape:connector-curvature="0" />
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -1270,351.23958 h 66.1458"
|
||||
id="path938"
|
||||
inkscape:connector-curvature="0" />
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -1270,348.59375 h 66.1458"
|
||||
id="path940"
|
||||
inkscape:connector-curvature="0" />
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -1270,345.94792 h 66.1458"
|
||||
id="path942"
|
||||
inkscape:connector-curvature="0" />
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
id="path946"
|
||||
style="fill:#008080;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -1211.7917,106.5 v 2.64583 l 7.9375,-5.29166 -7.9375,-5.29167 v 2.64583 m -18.5208,29.10417 v -15.875 l 7.9375,-7.9375 h 10.5833 v -5.29167 h -13.2291 l -10.5834,10.58334 v 18.52083 z"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccccccc" />
|
||||
sodipodi:nodetypes="cccccccccccccc"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
d="m -550.33333,402.83337 h -2.64583 l 5.29166,-7.9375 5.29167,7.9375 h -2.64583 m -29.10417,18.5208 h 15.875 l 7.9375,-7.9375 v -10.5833 h 5.29167 v 13.2291 l -10.58334,10.5834 h -18.52083 z"
|
||||
d="m -576.79163,413.41667 v -2.64583 l -7.9375,5.29166 7.9375,5.29167 v -2.64583 m 18.5208,-29.10417 v 15.875 l -7.9375,7.9375 h -10.5833 v 5.29167 h 13.2291 l 10.5834,-10.58334 v -18.52083 z"
|
||||
style="fill:#008080;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
id="path964" />
|
||||
id="path964"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:34.11780548px;line-height:1.25;font-family:TT2020;-inkscape-font-specification:TT2020;letter-spacing:0px;word-spacing:0px;display:inline;opacity:1;fill:#800000;fill-opacity:1;stroke:none;stroke-width:1.27941763"
|
||||
x="-1270.4515"
|
||||
y="484.4295"
|
||||
id="text925"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan923"
|
||||
x="-1270.4515"
|
||||
y="484.4295"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:TT2020;-inkscape-font-specification:TT2020;fill:#800000;stroke-width:1.27941763">α.</tspan></text>
|
||||
<text
|
||||
id="text931"
|
||||
y="77.058578"
|
||||
x="-543.30963"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:23.21096992px;line-height:1.25;font-family:TT2020;-inkscape-font-specification:TT2020;letter-spacing:0px;word-spacing:0px;display:inline;opacity:1;fill:#800000;fill-opacity:1;stroke:none;stroke-width:0.87041134"
|
||||
xml:space="preserve"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map1_back.png"
|
||||
inkscape:export-xdpi="96.518349"
|
||||
inkscape:export-ydpi="96.518349"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:TT2020;-inkscape-font-specification:TT2020;fill:#800000;stroke-width:0.87041134"
|
||||
y="77.058578"
|
||||
x="-543.30963"
|
||||
id="tspan929"
|
||||
sodipodi:role="line">β.</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
inkscape:label="wall"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
style="display:inline;opacity:0.218">
|
||||
style="display:none;opacity:0.4207921">
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect815"
|
||||
|
@ -170,8 +219,7 @@
|
|||
id="rect862"
|
||||
style="opacity:1;fill:#0000b9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<g
|
||||
id="g5223"
|
||||
style="">
|
||||
id="g5223">
|
||||
<rect
|
||||
style="opacity:1;fill:#0000b9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect856"
|
||||
|
@ -205,8 +253,7 @@
|
|||
<g
|
||||
id="g863"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path845"
|
||||
|
@ -222,8 +269,7 @@
|
|||
id="g869"
|
||||
transform="matrix(1,0,0,-1,71.437496,468.5875)"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.79649597;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="m -276.48388,232.17708 a 1.3274933,1.3274933 0 0 0 -1.32749,1.32491 l -0.006,-0.006 0.007,0.0493 a 1.3274933,1.3274933 0 0 0 0.041,0.28935 l 0.21729,1.51988 0.26549,-0.2655 0.2655,0.7965 0.2655,-0.2655 0.2655,1.32749 0.2655,-1.32749 0.2655,0.2655 0.2655,-0.7965 0.26549,0.2655 0.20638,-1.44313 a 1.3274933,1.3274933 0 0 0 0.0648,-0.40706 1.3274933,1.3274933 0 0 0 -1.32749,-1.3275 z"
|
||||
|
@ -239,8 +285,7 @@
|
|||
transform="matrix(0,-1,-1,0,-7.0062473,-41.666663)"
|
||||
id="g875"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path871"
|
||||
|
@ -256,8 +301,7 @@
|
|||
id="g881"
|
||||
transform="matrix(0,1,1,0,-403.13087,511.11152)"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.79649597;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="m -276.48388,232.17708 a 1.3274933,1.3274933 0 0 0 -1.32749,1.32491 l -0.006,-0.006 0.007,0.0493 a 1.3274933,1.3274933 0 0 0 0.041,0.28935 l 0.21729,1.51988 0.26549,-0.2655 0.2655,0.7965 0.2655,-0.2655 0.2655,1.32749 0.2655,-1.32749 0.2655,0.2655 0.2655,-0.7965 0.26549,0.2655 0.20638,-1.44313 a 1.3274933,1.3274933 0 0 0 0.0648,-0.40706 1.3274933,1.3274933 0 0 0 -1.32749,-1.3275 z"
|
||||
|
@ -393,8 +437,7 @@
|
|||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
id="g80"
|
||||
transform="rotate(45,-267.71741,255.73419)"
|
||||
style="">
|
||||
transform="rotate(45,-267.71741,255.73419)">
|
||||
<path
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.79649597;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="m -276.48388,232.17708 a 1.3274933,1.3274933 0 0 0 -1.32749,1.32491 l -0.006,-0.006 0.007,0.0493 a 1.3274933,1.3274933 0 0 0 0.041,0.28935 l 0.21729,1.51988 0.26549,-0.2655 0.2655,0.7965 0.2655,-0.2655 0.2655,1.32749 0.2655,-1.32749 0.2655,0.2655 0.2655,-0.7965 0.26549,0.2655 0.20638,-1.44313 a 1.3274933,1.3274933 0 0 0 0.0648,-0.40706 1.3274933,1.3274933 0 0 0 -1.32749,-1.3275 z"
|
||||
|
@ -410,8 +453,7 @@
|
|||
transform="matrix(0.70710678,-0.70710678,-0.70710678,-0.70710678,135.23304,204.52832)"
|
||||
id="g86"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path82"
|
||||
|
@ -427,8 +469,7 @@
|
|||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
id="g92"
|
||||
transform="rotate(-135,-231.7835,215.81778)"
|
||||
style="">
|
||||
transform="rotate(-135,-231.7835,215.81778)">
|
||||
<path
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.79649597;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="m -276.48388,232.17708 a 1.3274933,1.3274933 0 0 0 -1.32749,1.32491 l -0.006,-0.006 0.007,0.0493 a 1.3274933,1.3274933 0 0 0 0.041,0.28935 l 0.21729,1.51988 0.26549,-0.2655 0.2655,0.7965 0.2655,-0.2655 0.2655,1.32749 0.2655,-1.32749 0.2655,0.2655 0.2655,-0.7965 0.26549,0.2655 0.20638,-1.44313 a 1.3274933,1.3274933 0 0 0 0.0648,-0.40706 1.3274933,1.3274933 0 0 0 -1.32749,-1.3275 z"
|
||||
|
@ -444,8 +485,7 @@
|
|||
transform="matrix(-0.70710678,0.70710678,0.70710678,0.70710678,-512.2643,264.20758)"
|
||||
id="g98"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path94"
|
||||
|
@ -779,7 +819,7 @@
|
|||
inkscape:export-ydpi="133.33333" />
|
||||
<path
|
||||
style="opacity:1;fill:#7f2aff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.07756615;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="M -1316.4103,20.321616 V 544.17739 h 841.88495 V 20.321616 Z m 327.39969,28.063702 H -867.405 v 46.772834 h 159.02271 v -37.41826 h 196.43983 V 207.41294 h -9.35428 V 310.3132 h 18.70855 v 56.12741 h -28.06284 v 28.06371 h 28.06284 v 121.60936 h -177.73127 v -46.77283 h -74.83421 v -28.06371 h -102.89706 v 28.06371 h -46.77138 v -28.06371 h -112.25139 v 56.12741 h -261.9197 V 357.08603 h 9.3542 V 57.739892 h 65.4799 v 18.709129 h 215.14849 z m -215.14849,74.836532 v 233.86418 h 93.5429 v -84.19111 h -18.7086 v -65.48198 h 140.31419 v -84.19109 z m 336.7541,37.41828 v 121.60936 h 9.35427 v 121.60938 h 102.89706 v -18.70913 h 102.89706 v 9.35458 h 74.8342 V 366.44061 H -699.028 V 310.3132 h 18.70854 V 207.41294 h -28.06283 v -46.77281 z m 233.85693,46.77281 V 310.3132 h 65.47995 V 207.41294 Z m -420.94253,65.48198 v 84.19111 h 37.4171 v 46.77284 h 112.25139 V 310.3132 h -84.1885 v -37.41828 z"
|
||||
d="m -1318.3099,17.99977 v 523.85578 h 841.88491 V 17.99977 Z m 327.39965,28.063702 h 121.60561 v 46.772834 h 159.02271 V 55.418046 H -513.8421 V 205.0911 h -9.35428 v 102.90026 h 18.70855 v 56.12741 h -28.06284 v 28.06371 h 28.06284 V 513.79184 H -682.2191 v -46.77283 h -74.83421 V 438.9553 h -102.89706 v 28.06371 h -46.77138 V 438.9553 h -112.25135 v 56.12741 h -261.9197 V 354.76419 h 9.3542 V 55.418046 h 65.4799 v 18.709129 h 215.14845 z m -215.14845,74.836538 v 233.86418 h 93.5429 v -84.19111 h -18.7086 V 205.0911 h 140.31415 v -84.19109 z m 336.75406,37.41828 v 121.60936 h 9.35427 v 121.60938 h 102.89706 V 382.8279 h 102.89706 v 9.35458 h 74.8342 v -28.06371 h -121.60559 v -56.12741 h 18.70854 V 205.0911 h -28.06283 v -46.77281 z m 233.85693,46.77281 v 102.90026 h 65.47995 V 205.0911 Z m -420.94249,65.48198 v 84.19111 h 37.4171 v 46.77284 h 112.25135 v -93.54567 h -84.1885 v -37.41828 z"
|
||||
id="rect4612"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/grizzly/Documents/Python/tangledmind/maps/map_1.png"
|
||||
|
@ -804,8 +844,7 @@
|
|||
id="g4628"
|
||||
transform="rotate(90,-276.48959,244.08333)"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="">
|
||||
inkscape:export-ydpi="96">
|
||||
<path
|
||||
id="path4621"
|
||||
transform="scale(0.26458333)"
|
||||
|
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 51 KiB |
6
main.py
6
main.py
|
@ -5,7 +5,7 @@
|
|||
|
||||
import pygame
|
||||
|
||||
from models import Game, Perso, Carte, Camera
|
||||
from models import Game, Perso, Carte, Camera, Enemy
|
||||
|
||||
pygame.init()
|
||||
|
||||
|
@ -23,10 +23,12 @@ BLUE=(0,0,255)
|
|||
RED=(255,0,0)
|
||||
|
||||
carte = Carte('map1')
|
||||
# possible positions: 300,300: 1400,1000: 2700,400, 2800,1600
|
||||
# click = 323
|
||||
perso = Perso('Alice',660,1570,center_screen,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,323,'perso.png','canon.png','projectile1_right.png')
|
||||
camera = Camera(660,1570,screen_width,screen_height,0.3)
|
||||
game = Game(carte,perso,camera)
|
||||
enemies = [Enemy('Plop',(300,300),'perso.png')]
|
||||
game = Game(carte,perso,camera,enemies)
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
|
|
56
models.py
56
models.py
|
@ -18,10 +18,11 @@ deceleration = 1.1
|
|||
|
||||
|
||||
class Game():
|
||||
def __init__(self,carte,perso,camera):
|
||||
def __init__(self,carte,perso,camera,enemies):
|
||||
self.carte = carte
|
||||
self.perso = perso
|
||||
self.camera = camera
|
||||
self.enemies = enemies
|
||||
|
||||
def draw(self,surface):
|
||||
# draw the map
|
||||
|
@ -30,7 +31,7 @@ class Game():
|
|||
# draw the projectiles and remove them if needed
|
||||
to_remove = []
|
||||
for k,proj in enumerate(self.perso.projectiles):
|
||||
if not proj.is_out(self.carte):
|
||||
if not proj.is_out(self.carte,self):
|
||||
proj.move()
|
||||
proj.draw(surface,self.camera)
|
||||
else:
|
||||
|
@ -39,6 +40,9 @@ class Game():
|
|||
for k in to_remove[::-1]:
|
||||
del self.perso.projectiles[k]
|
||||
|
||||
for enemy in self.enemies:
|
||||
enemy.draw(surface,self.camera)
|
||||
|
||||
self.perso.draw(surface,self.camera)
|
||||
self.camera.draw(surface)
|
||||
|
||||
|
@ -62,7 +66,6 @@ class Carte():
|
|||
surface.blit(self.wall,(self.posx-offsetx,self.posy-offsety))
|
||||
|
||||
|
||||
|
||||
class Camera():
|
||||
def __init__(self,start_posx,start_posy,screen_width,screen_height,box_ratio):
|
||||
self.posx = start_posx
|
||||
|
@ -233,6 +236,29 @@ class Perso():
|
|||
self.projectiles.append(new_proj)
|
||||
self.last_fire = time()
|
||||
|
||||
|
||||
class Enemy():
|
||||
def __init__(self,name,position,texture):
|
||||
self.name = name
|
||||
self.posx = position[0]
|
||||
self.posy = position[1]
|
||||
|
||||
self.img = pygame.image.load(img_path+texture).convert_alpha()
|
||||
self.rect = self.img.get_rect()
|
||||
self.mask = pygame.mask.from_surface(self.img)
|
||||
|
||||
def draw(self,surface,camera):
|
||||
offsetx,offsety = camera.get_offset()
|
||||
posx_screen = self.posx-offsetx
|
||||
posy_screen = self.posy-offsety
|
||||
surface.blit(self.img,(posx_screen-self.rect.center[0],posy_screen-self.rect.center[1]))
|
||||
|
||||
def die(self,game,index):
|
||||
print(f"{self.name} died with honor.")
|
||||
del game.enemies[index]
|
||||
|
||||
|
||||
|
||||
class Projectile(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self,name,texture,position,speed,angle):
|
||||
|
@ -259,12 +285,20 @@ class Projectile(pygame.sprite.Sprite):
|
|||
|
||||
surface.blit(self.img,(posx_screen-self.rect[0],posy_screen-self.rect[1]))
|
||||
|
||||
def is_out(self,carte):
|
||||
def is_out(self,carte,game):
|
||||
# A projectile is out if it touches a wall or an enemy. Otherwise it continues.
|
||||
|
||||
impact = False
|
||||
|
||||
# Touchs a wall
|
||||
if carte.mask.overlap(self.mask, (self.posx-self.rect.center[0],self.posy-self.rect.center[1])):
|
||||
# if (self.deplacement[0]+surface.get_width()/2<0-self.img.get_width() or
|
||||
# self.deplacement[1]+surface.get_height()/2<0-self.img.get_height() or
|
||||
# self.deplacement[0]+surface.get_width()/2>surface.get_width()+self.img.get_width() or
|
||||
# self.deplacement[1]+surface.get_height()/2>surface.get_height()+self.img.get_height()):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
impact = True
|
||||
|
||||
# Touchs an enemy
|
||||
for k,enemy in enumerate(game.enemies):
|
||||
if enemy.mask.overlap(self.mask, (enemy.posx+enemy.rect.center[0]-self.posx-self.rect.center[0],enemy.posy+enemy.rect.center[1]-self.posy-self.rect.center[1])):
|
||||
print("Impact on enemy {} at position {}".format(enemy.name,(enemy.posx,enemy.posy)))
|
||||
enemy.die(game,k)
|
||||
impact = True
|
||||
|
||||
return impact
|
Loading…
Reference in a new issue