From dd103744d6c0b0912e4720f1e17f8678b6dd5446 Mon Sep 17 00:00:00 2001 From: Arthur 'Grizzly' Grisel-Davy Date: Sat, 11 Apr 2020 00:17:49 -0400 Subject: [PATCH] Framerate cap and rotating canon --- asset/asset.svg | 23 ++++++++++++++++++++--- asset/canon.png | Bin 0 -> 265 bytes main.py | 21 ++++++++++++--------- models.py | 49 +++++++++++++++++++++++++++++++++--------------- 4 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 asset/canon.png diff --git a/asset/asset.svg b/asset/asset.svg index fb2c333..0f8ca51 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="1.4" - inkscape:cx="-896.36165" - inkscape:cy="178.40018" + inkscape:zoom="3.959798" + inkscape:cx="-1038.4591" + inkscape:cy="251.12477" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -716,5 +716,22 @@ inkscape:connector-curvature="0" inkscape:export-xdpi="96" inkscape:export-ydpi="96" /> + + diff --git a/asset/canon.png b/asset/canon.png new file mode 100644 index 0000000000000000000000000000000000000000..312e4e6e2aa792be77b2e062a3f415dd97d0c235 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^l0eMI!3HF6S#5U!QY^(zo*^7SP{WbZ0pxQQctjR6 zFo-mQFyqwqrxyVQB}-f*N`mv#O3D+9QW?t2%k?tzvWt@w3sUv+i_&MmvylQSYV&k) z46*3lJ7pv9VFw;&PsI~_GY`(Sd$~Da*++$W2e&TPH+E|C_~`SsfqT0CYGrO&g$YTT zt`gSsJ7#=q<7JaMr<$mKcW+5zTCPRQ6VU^^vpr8sKA*K&@qS0dW<}|SX self.posy: + degres = -degres + if x_mouse < self.posx: + degres = 180-degres + + canon = pygame.transform.rotate(self.canon,degres) + + # Get rects + perso_rect = self.img.get_rect() + canon_rect = canon.get_rect() + + surface.blit(self.img,(self.posx-perso_rect.center[0],self.posy-perso_rect.center[1])) + surface.blit(canon,(self.posx-canon_rect.center[0],self.posy-canon_rect.center[1])) def fire(self,name,texture): if (time()-self.last_fire> 0.2): @@ -142,7 +161,7 @@ class Projectile(): self.direction = direction index = decision_matrix[self.direction[1]+1,self.direction[0]+1] - self.img = pygame.image.load(img_path+texture+suffix_matrix[index]) + self.img = pygame.image.load(img_path+texture+suffix_matrix[index]).convert_alpha() def move(self): self.position = (self.position[0]+self.speed*self.direction[0],self.position[1]+self.speed*self.direction[1])