diff --git a/asset/asset.svg b/asset/asset.svg
index 3ddc98a..fb2c333 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="2.8"
- inkscape:cx="-787.46383"
- inkscape:cy="200.5935"
+ inkscape:zoom="1.4"
+ inkscape:cx="-896.36165"
+ inkscape:cy="178.40018"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -67,7 +67,7 @@
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
+ 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" />
+ 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" />
+ 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" />
+ 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" />
+ style="opacity:1;fill:#990000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
@@ -518,7 +518,7 @@
inkscape:export-ydpi="96"
inkscape:export-xdpi="96"
y="171.97917"
- x="258.63541"
+ x="269.99368"
height="1.3229166"
width="2.6458333"
id="rect122"
@@ -526,12 +526,12 @@
transform="rotate(90)" />
+ style="opacity:1;fill:#990000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ style="opacity:1;fill:#990000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
@@ -600,8 +600,120 @@
id="rect138"
width="2.6458333"
height="1.3229166"
- x="-291.07327"
- y="72.594566"
+ x="-299.1048"
+ y="80.626083"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main.py b/main.py
index d9d19b1..2039194 100644
--- a/main.py
+++ b/main.py
@@ -15,13 +15,13 @@ screen = pygame.display.set_mode((screen_width, screen_height))
done = False
-BACKGROUND=(0,0,0)
+BACKGROUND=(200,200,200)
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,pygame.K_SPACE,'asset/perso1')
-perso2 = Perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,pygame.K_SPACE,'asset/perso2')
+perso1 = Perso('Alice',200,200,pygame.K_o,pygame.K_l,pygame.K_k,pygame.K_m,pygame.K_SPACE,'perso1','projectile1')
+perso2 = Perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,pygame.K_SPACE,'perso2','projectile2')
speed = 1
diff --git a/models.py b/models.py
index 163bb07..dd57c77 100644
--- a/models.py
+++ b/models.py
@@ -7,9 +7,23 @@ import pygame
from time import time
import numpy as np
+decision_matrix = np.array([[0,1,2],[3,4,5],[6,7,8]])
+suffix_matrix = ['_up_left.png',
+ '_up.png',
+ '_up_right.png',
+ '_left.png',
+ '_up.png',
+ '_right.png',
+ '_down_left.png',
+ '_down.png',
+ '_down_right.png',]
+img_path = 'asset/'
+
+
+
class Perso():
- def __init__(self,name,posx,posy,key_up,key_down,key_left,key_right,key_fire,texture):
+ def __init__(self,name,posx,posy,key_up,key_down,key_left,key_right,key_fire,texture,texture_proj):
self.name = name
self.posx = posx
self.posy = posy
@@ -19,17 +33,17 @@ class Perso():
self.key_left = key_left
self.key_right = key_right
self.key_fire = key_fire
- self.imgs = [pygame.image.load(texture+'_up_left.png'),
- pygame.image.load(texture+'_up.png'),
- pygame.image.load(texture+'_up_right.png'),
- pygame.image.load(texture+'_left.png'),
- pygame.image.load(texture+'_up.png'),
- pygame.image.load(texture+'_right.png'),
- pygame.image.load(texture+'_down_left.png'),
- pygame.image.load(texture+'_down.png'),
- pygame.image.load(texture+'_down_right.png'),]
- self.img_matrix = np.array([[0,1,2],[3,4,5],[6,7,8]])
+ self.imgs = [pygame.image.load(img_path+texture+'_up_left.png'),
+ pygame.image.load(img_path+texture+'_up.png'),
+ pygame.image.load(img_path+texture+'_up_right.png'),
+ pygame.image.load(img_path+texture+'_left.png'),
+ pygame.image.load(img_path+texture+'_up.png'),
+ pygame.image.load(img_path+texture+'_right.png'),
+ pygame.image.load(img_path+texture+'_down_left.png'),
+ pygame.image.load(img_path+texture+'_down.png'),
+ pygame.image.load(img_path+texture+'_down_right.png'),]
self.img = self.imgs[0]
+ self.texture_proj = texture_proj
self.size = self.img.get_size()
self.projectiles = []
@@ -86,14 +100,14 @@ class Perso():
del self.projectiles[k]
# select img
- index = self.img_matrix[self.direction[1]+1,self.direction[0]+1]
+ index = decision_matrix[self.direction[1]+1,self.direction[0]+1]
self.img = self.imgs[index]
surface.blit(self.img,(self.posx,self.posy))
#print("Projectiles for {}: {}".format(self.name,len(self.projectiles)))
def fire(self,name,texture):
if (time()-self.last_fire> 0.2):
- new_proj = Projectile(name,texture,2,(self.posx+int(self.img.get_height()/2),self.posy+int(self.img.get_width()/2)),self.direction)
+ new_proj = Projectile(name,self.texture_proj,3,(self.posx+int(self.img.get_height()/2),self.posy+int(self.img.get_width()/2)),[self.direction[0],self.direction[1]])
self.projectiles.append(new_proj)
self.last_fire = time()
@@ -107,16 +121,8 @@ class Projectile():
self.position = position
self.direction = direction
- if direction[0]!=0:
- if direction[0]>0:
- self.img = pygame.image.load(texture+'_right.png')
- else:
- self.img = pygame.image.load(texture+'_left.png')
- else:
- if direction[1]>0:
- self.img = pygame.image.load(texture+'_down.png')
- else:
- self.img = pygame.image.load(texture+'_up.png')
+ index = decision_matrix[self.direction[1]+1,self.direction[0]+1]
+ self.img = pygame.image.load(img_path+texture+suffix_matrix[index])
def move(self):
self.position = (self.position[0]+self.speed*self.direction[0],self.position[1]+self.speed*self.direction[1])