diff --git a/asset/asset.svg b/asset/asset.svg
index e2196d8..3ddc98a 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="22.4"
- inkscape:cx="-1033.5604"
- inkscape:cy="234.95109"
+ inkscape:zoom="2.8"
+ inkscape:cx="-787.46383"
+ inkscape:cy="200.5935"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -87,8 +87,8 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id="rect102"
+ style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
-
-
+
+
+
+
+
+
+
+
diff --git a/asset/missile.png b/asset/missile.png
deleted file mode 100644
index 7400f32..0000000
Binary files a/asset/missile.png and /dev/null differ
diff --git a/asset/perso1_down_left.png b/asset/perso1_down_left.png
new file mode 100644
index 0000000..7d87b18
Binary files /dev/null and b/asset/perso1_down_left.png differ
diff --git a/asset/perso1_down_right.png b/asset/perso1_down_right.png
new file mode 100644
index 0000000..be786c7
Binary files /dev/null and b/asset/perso1_down_right.png differ
diff --git a/asset/perso1_up_left.png b/asset/perso1_up_left.png
new file mode 100644
index 0000000..3c17bba
Binary files /dev/null and b/asset/perso1_up_left.png differ
diff --git a/asset/perso1_up_right.png b/asset/perso1_up_right.png
new file mode 100644
index 0000000..bfd708a
Binary files /dev/null and b/asset/perso1_up_right.png differ
diff --git a/asset/perso2_down_left.png b/asset/perso2_down_left.png
new file mode 100644
index 0000000..48aae71
Binary files /dev/null and b/asset/perso2_down_left.png differ
diff --git a/asset/perso2_down_right.png b/asset/perso2_down_right.png
new file mode 100644
index 0000000..0555757
Binary files /dev/null and b/asset/perso2_down_right.png differ
diff --git a/asset/perso2_up_left.png b/asset/perso2_up_left.png
new file mode 100644
index 0000000..5b8fc8a
Binary files /dev/null and b/asset/perso2_up_left.png differ
diff --git a/asset/perso2_up_right.png b/asset/perso2_up_right.png
new file mode 100644
index 0000000..1bf335b
Binary files /dev/null and b/asset/perso2_up_right.png differ
diff --git a/asset/projectile_down.png b/asset/projectile1_down.png
similarity index 100%
rename from asset/projectile_down.png
rename to asset/projectile1_down.png
diff --git a/asset/projectile1_down_left.png b/asset/projectile1_down_left.png
new file mode 100644
index 0000000..2cf032a
Binary files /dev/null and b/asset/projectile1_down_left.png differ
diff --git a/asset/projectile1_down_right.png b/asset/projectile1_down_right.png
new file mode 100644
index 0000000..0c3d566
Binary files /dev/null and b/asset/projectile1_down_right.png differ
diff --git a/asset/projectile_left.png b/asset/projectile1_left.png
similarity index 100%
rename from asset/projectile_left.png
rename to asset/projectile1_left.png
diff --git a/asset/projectile_right.png b/asset/projectile1_right.png
similarity index 100%
rename from asset/projectile_right.png
rename to asset/projectile1_right.png
diff --git a/asset/projectile_up.png b/asset/projectile1_up.png
similarity index 100%
rename from asset/projectile_up.png
rename to asset/projectile1_up.png
diff --git a/asset/projectile1_up_left.png b/asset/projectile1_up_left.png
new file mode 100644
index 0000000..755d642
Binary files /dev/null and b/asset/projectile1_up_left.png differ
diff --git a/asset/projectile1_up_right.png b/asset/projectile1_up_right.png
new file mode 100644
index 0000000..e8bbd53
Binary files /dev/null and b/asset/projectile1_up_right.png differ
diff --git a/asset/projectile2_down.png b/asset/projectile2_down.png
new file mode 100644
index 0000000..8b16213
Binary files /dev/null and b/asset/projectile2_down.png differ
diff --git a/asset/projectile2_down_left.png b/asset/projectile2_down_left.png
new file mode 100644
index 0000000..03320e4
Binary files /dev/null and b/asset/projectile2_down_left.png differ
diff --git a/asset/projectile2_down_right.png b/asset/projectile2_down_right.png
new file mode 100644
index 0000000..5470227
Binary files /dev/null and b/asset/projectile2_down_right.png differ
diff --git a/asset/projectile2_left.png b/asset/projectile2_left.png
new file mode 100644
index 0000000..35dd8db
Binary files /dev/null and b/asset/projectile2_left.png differ
diff --git a/asset/projectile2_right.png b/asset/projectile2_right.png
new file mode 100644
index 0000000..70dcad4
Binary files /dev/null and b/asset/projectile2_right.png differ
diff --git a/asset/projectile2_up.png b/asset/projectile2_up.png
new file mode 100644
index 0000000..c7e3982
Binary files /dev/null and b/asset/projectile2_up.png differ
diff --git a/asset/projectile2_up_left.png b/asset/projectile2_up_left.png
new file mode 100644
index 0000000..77da10f
Binary files /dev/null and b/asset/projectile2_up_left.png differ
diff --git a/asset/projectile2_up_right.png b/asset/projectile2_up_right.png
new file mode 100644
index 0000000..b78a2ce
Binary files /dev/null and b/asset/projectile2_up_right.png differ
diff --git a/models.py b/models.py
index e5cd621..163bb07 100644
--- a/models.py
+++ b/models.py
@@ -5,6 +5,7 @@
import pygame
from time import time
+import numpy as np
class Perso():
@@ -12,52 +13,67 @@ class Perso():
self.name = name
self.posx = posx
self.posy = posy
- self.direction = (0,-1)
+ self.direction = [0,-1]
self.key_up = key_up
self.key_down = key_down
self.key_left = key_left
self.key_right = key_right
self.key_fire = key_fire
- 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.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.img = self.imgs[0]
+
self.size = self.img.get_size()
self.projectiles = []
self.last_fire = time()
def check_keys(self,keystate,screen_width,screen_height,speed):
- if keystate[self.key_left]:
- self.posx -= speed
- if self.posx <0:
- self.posx=0
- self.img = self.img_left
- self.direction = (-1,0)
- 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
- self.direction = (1,0)
- if keystate[self.key_up]:
- self.posy -= speed
- if self.posy < 0:
- self.posy = 0
- self.img = self.img_up
- self.direction = (0,-1)
- 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
- self.direction = (0,1)
+
+ if keystate[self.key_left] or keystate[self.key_right] or keystate[self.key_up] or keystate[self.key_down]:
+ if keystate[self.key_left]:
+ self.posx -= speed
+ if self.posx <0:
+ self.posx=0
+ self.direction[0] = -1
+
+ if keystate[self.key_right]:
+ self.posx += speed
+ if self.posx+self.size[0] > screen_width:
+ self.posx = screen_width-self.size[0]
+ self.direction[0] = 1
+
+ if keystate[self.key_up]:
+ self.posy -= speed
+ if self.posy < 0:
+ self.posy = 0
+ self.direction[1] = -1
+
+ if keystate[self.key_down]:
+ self.posy += speed
+ if self.posy+self.size[1] > screen_height:
+ self.posy = screen_height-self.size[1]
+ self.direction[1] = 1
+
+ if not keystate[self.key_left] and not keystate[self.key_right]:
+ self.direction[0] = 0
+
+ if not keystate[self.key_up] and not keystate[self.key_down]:
+ self.direction[1] = 0
if keystate[self.key_fire]:
self.fire('fireball','asset/projectile')
def draw(self,surface):
+ # Make all projectiles move or disepear and draw them
to_remove = []
for k,proj in enumerate(self.projectiles):
if not proj.is_out(surface):
@@ -69,8 +85,11 @@ class Perso():
for k in to_remove[::-1]:
del self.projectiles[k]
+ # select img
+ index = self.img_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)))
+ #print("Projectiles for {}: {}".format(self.name,len(self.projectiles)))
def fire(self,name,texture):
if (time()-self.last_fire> 0.2):