Permalink
Browse files

autopep8

  • Loading branch information...
antismap committed Sep 9, 2017
1 parent 675f91f commit 2f816d9b96fb525e7f607fad03ca900df9bb32c7
Showing with 1,948 additions and 1,920 deletions.
  1. +53 −55 sources/asteroids.py
  2. +63 −58 sources/background.py
  3. +31 −31 sources/bonus.py
  4. +15 −15 sources/collisions.py
  5. +8 −7 sources/common_pygame.py
  6. +18 −16 sources/effects.py
  7. +363 −371 sources/enemy.py
  8. +352 −363 sources/game.py
  9. +139 −135 sources/hud.py
  10. +8 −8 sources/input.py
  11. +35 −30 sources/lasers.py
  12. +52 −50 sources/load_resources.py
  13. +379 −354 sources/menu.py
  14. +68 −60 sources/particles.py
  15. +29 −24 sources/progressbar.py
  16. +39 −56 sources/scoreboard.py
  17. +241 −237 sources/ship.py
  18. +35 −32 sources/smoke.py
  19. +20 −18 sources/sprite_handling.py
View
@@ -3,61 +3,59 @@
import random
import collisions
pygame = common_pygame.pygame
-screen= common_pygame.screen
+screen = common_pygame.screen
+
class Asteroids():
-
-
- def __init__(self, single_sprites):
- self.single_sprites=single_sprites
- self.compteur=0
- self.asteroidList=list()
- self.rotateAst=0
-
- def updatecompteur(self):
- self.compteur=self.compteur+1
-
- def determine(self, x):
- (x_, y, v, s, sprite, h, w) = x
- if y-h>=screen.get_height():
- return True
- return False
-
- def blitAsteroids(self, laserlist):
- if len(self.asteroidList)<=2 and self.compteur%10==0:
- #x, y, speed, size, sprite, height
- size = random.randrange(10, 150)
-
-
- asteroid=False
- #load the appropriate sprite
- choix = random.randrange(1,7)
- if choix ==1:
- spritearg = pygame.transform.scale(self.single_sprites['asteroid1.png'], (size , size )).convert_alpha()
- elif choix==2:
- spritearg = pygame.transform.scale(self.single_sprites['asteroid3.png'], (size , size )).convert_alpha()
- else:
- spritearg = pygame.transform.scale(self.single_sprites['asteroid2.png'], (size , size )).convert_alpha()
-
- speed = random.randrange(7, 12)
-
-
- height = spritearg.get_height()
- width = spritearg.get_width()
- self.asteroidList.append((random.randrange(0, screen.get_width()),0, speed, size ,spritearg, height, width))
-
- #determine : false if keep, true if delete
- self.asteroidList[:] = [x for x in self.asteroidList if not self.determine(x)]
-
- for index in xrange(len(self.asteroidList)):
- #verify if a laser is not touching the asteroid
-
-
-
- (x, y, v, s, sprite, h, w) = self.asteroidList[index]
- screen.blit(sprite,(x, y-h))
- y=y+v
- self.asteroidList[index]=(x, y, v, s, sprite, h, w)
-
-
+ def __init__(self, single_sprites):
+ self.single_sprites = single_sprites
+ self.compteur = 0
+ self.asteroidList = list()
+ self.rotateAst = 0
+
+ def updatecompteur(self):
+ self.compteur = self.compteur + 1
+
+ def determine(self, x):
+ (x_, y, v, s, sprite, h, w) = x
+ if y - h >= screen.get_height():
+ return True
+ return False
+
+ def blitAsteroids(self, laserlist):
+ if len(self.asteroidList) <= 2 and self.compteur % 10 == 0:
+ #x, y, speed, size, sprite, height
+ size = random.randrange(10, 150)
+
+ asteroid = False
+ # load the appropriate sprite
+ choix = random.randrange(1, 7)
+ if choix == 1:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['asteroid1.png'], (size, size)).convert_alpha()
+ elif choix == 2:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['asteroid3.png'], (size, size)).convert_alpha()
+ else:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['asteroid2.png'], (size, size)).convert_alpha()
+
+ speed = random.randrange(7, 12)
+
+ height = spritearg.get_height()
+ width = spritearg.get_width()
+ self.asteroidList.append((random.randrange(
+ 0, screen.get_width()), 0, speed, size, spritearg, height, width))
+
+ # determine : false if keep, true if delete
+ self.asteroidList[:] = [
+ x for x in self.asteroidList if not self.determine(x)]
+
+ for index in xrange(len(self.asteroidList)):
+ # verify if a laser is not touching the asteroid
+
+ (x, y, v, s, sprite, h, w) = self.asteroidList[index]
+ screen.blit(sprite, (x, y - h))
+ y = y + v
+ self.asteroidList[index] = (x, y, v, s, sprite, h, w)
View
@@ -2,65 +2,70 @@
import common_pygame
import random
pygame = common_pygame.pygame
-screen= common_pygame.screen
+screen = common_pygame.screen
+
class BackGen():
-
-
- def __init__(self, single_sprites):
- self.single_sprites=single_sprites
- self.compteur=0
- self.asteroidList=list()
- self.ast = self.single_sprites['asteroid1.png']
- self.rotateAst=0
-
- def updatecompteur(self):
- self.compteur=self.compteur+1
-
- def blitStars(self):
- screen.blit(self.single_sprites['background.png'],(0,-600+(self.compteur%200*3)))
- screen.blit(self.single_sprites['background.png'],(0,self.compteur%200*3))
-
- def determine(self, x):
- (x_, y, v, s, sprite, h, w) = x
- if y-h>=screen.get_height():
- return True
- return False
-
- def blitPlanets(self):
- if len(self.asteroidList)<=2 and self.compteur%10==0:
- #x, y, speed, size, sprite, height
- size = random.randrange(10, 200)
-
-
- asteroid=False
- #load the appropriate sprite
- choix = random.randrange(1,4)
- if choix==1:
- spritearg = pygame.transform.scale(self.single_sprites['planet1.png'], (size , size )).convert_alpha()
- elif choix==2:
- spritearg = pygame.transform.scale(self.single_sprites['planet2.png'], (size , size )).convert_alpha()
- else:
- spritearg = pygame.transform.scale(self.single_sprites['planet3.png'], (size , size )).convert_alpha()
- speed = random.randrange(2, 4)
-
- height = spritearg.get_height()
- width = spritearg.get_width()
- self.asteroidList.append((random.randrange(0, screen.get_width()),0, speed, size ,spritearg, height, width))
-
- #determine : false if keep, true if delete
- self.asteroidList[:] = [x for x in self.asteroidList if not self.determine(x)]
-
- for index in xrange(len(self.asteroidList)):
- (x, y, v, s, sprite, h, w) = self.asteroidList[index]
- screen.blit(sprite,(x, y-h))
- y=y+v
- self.asteroidList[index]=(x, y, v, s, sprite, h, w)
-
-
- def blitFog(self):
- screen.blit(self.single_sprites['backgroundtransp.png'],(0,-600+(self.compteur%40*15)))
- screen.blit(self.single_sprites['backgroundtransp.png'],(0,self.compteur%40*15))
-
+ def __init__(self, single_sprites):
+ self.single_sprites = single_sprites
+ self.compteur = 0
+ self.asteroidList = list()
+ self.ast = self.single_sprites['asteroid1.png']
+ self.rotateAst = 0
+
+ def updatecompteur(self):
+ self.compteur = self.compteur + 1
+
+ def blitStars(self):
+ screen.blit(self.single_sprites[
+ 'background.png'], (0, -600 + (self.compteur % 200 * 3)))
+ screen.blit(self.single_sprites[
+ 'background.png'], (0, self.compteur % 200 * 3))
+
+ def determine(self, x):
+ (x_, y, v, s, sprite, h, w) = x
+ if y - h >= screen.get_height():
+ return True
+ return False
+
+ def blitPlanets(self):
+ if len(self.asteroidList) <= 2 and self.compteur % 10 == 0:
+ #x, y, speed, size, sprite, height
+ size = random.randrange(10, 200)
+
+ asteroid = False
+ # load the appropriate sprite
+ choix = random.randrange(1, 4)
+ if choix == 1:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['planet1.png'], (size, size)).convert_alpha()
+ elif choix == 2:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['planet2.png'], (size, size)).convert_alpha()
+ else:
+ spritearg = pygame.transform.scale(
+ self.single_sprites['planet3.png'], (size, size)).convert_alpha()
+
+ speed = random.randrange(2, 4)
+
+ height = spritearg.get_height()
+ width = spritearg.get_width()
+ self.asteroidList.append((random.randrange(
+ 0, screen.get_width()), 0, speed, size, spritearg, height, width))
+
+ # determine : false if keep, true if delete
+ self.asteroidList[:] = [
+ x for x in self.asteroidList if not self.determine(x)]
+
+ for index in xrange(len(self.asteroidList)):
+ (x, y, v, s, sprite, h, w) = self.asteroidList[index]
+ screen.blit(sprite, (x, y - h))
+ y = y + v
+ self.asteroidList[index] = (x, y, v, s, sprite, h, w)
+ def blitFog(self):
+ screen.blit(self.single_sprites[
+ 'backgroundtransp.png'], (0, -600 + (self.compteur % 40 * 15)))
+ screen.blit(self.single_sprites[
+ 'backgroundtransp.png'], (0, self.compteur % 40 * 15))
View
@@ -2,36 +2,36 @@
import common_pygame
import random
pygame = common_pygame.pygame
-screen= common_pygame.screen
+screen = common_pygame.screen
+
class Bonus():
- def __init__(self, sounds, menu):
- self.menu=menu
- self.sounds=sounds
- self.bonusType=0
- self.bonusAnim=0
- self.font = pygame.font.Font(None,64)
- self.bonusList = list()
- self.bonusList.append(self.font.render(str("plasma gun !"), True, (255,255, 0)))
- self.score=0
- self.bonuscount=1
-
- def ProcessBonus(self, ship):
- #if ship.score %200 ==0 and ship.weapon==1 and ship.score>0:
-
- if ship.score>400*self.bonuscount and self.score<400*self.bonuscount:
- self.menu.play_sound(self.sounds["plasmagun.wav"])
- ship.setWeapon(2)
- self.bonusType=0
- self.bonusAnim=30
- self.score=ship.score
- self.bonuscount=self.bonuscount+1
-
- if self.bonusAnim>0 :
- self.bonusAnim=self.bonusAnim-1
- #show bonus for the plasma weapon
- if self.bonusType==0:
- screen.blit(self.bonusList[0], (250,250 ))
-
-
-
+
+ def __init__(self, sounds, menu):
+ self.menu = menu
+ self.sounds = sounds
+ self.bonusType = 0
+ self.bonusAnim = 0
+ self.font = pygame.font.Font(None, 64)
+ self.bonusList = list()
+ self.bonusList.append(self.font.render(
+ str("plasma gun !"), True, (255, 255, 0)))
+ self.score = 0
+ self.bonuscount = 1
+
+ def ProcessBonus(self, ship):
+ # if ship.score %200 ==0 and ship.weapon==1 and ship.score>0:
+
+ if ship.score > 400 * self.bonuscount and self.score < 400 * self.bonuscount:
+ self.menu.play_sound(self.sounds["plasmagun.wav"])
+ ship.setWeapon(2)
+ self.bonusType = 0
+ self.bonusAnim = 30
+ self.score = ship.score
+ self.bonuscount = self.bonuscount + 1
+
+ if self.bonusAnim > 0:
+ self.bonusAnim = self.bonusAnim - 1
+ # show bonus for the plasma weapon
+ if self.bonusType == 0:
+ screen.blit(self.bonusList[0], (250, 250))
View
@@ -1,16 +1,16 @@
-#detect collisions of two different rectangles
+# detect collisions of two different rectangles
def iscollision(AposX, AposY, AsizeX, AsizeY, BposX, BposY, BsizeX, BsizeY):
- if ((AposX+AsizeX <= BposX +BsizeX \
- and AposX +AsizeX >= BposX )\
- or
- (AposX <= BposX + BsizeX\
- and AposX +AsizeX >= BposX ))\
- \
- and ((AposY+AsizeY <= BposY +BsizeY \
- and AposY +AsizeY> BposY) \
- or
- (AposY <= BposY +BsizeY \
- and AposY > BposY)):
- return True
- else:
- return False
+ if ((AposX + AsizeX <= BposX + BsizeX
+ and AposX + AsizeX >= BposX)
+ or
+ (AposX <= BposX + BsizeX
+ and AposX + AsizeX >= BposX ))\
+ \
+ and ((AposY + AsizeY <= BposY + BsizeY
+ and AposY + AsizeY > BposY)
+ or
+ (AposY <= BposY + BsizeY
+ and AposY > BposY)):
+ return True
+ else:
+ return False
View
@@ -1,17 +1,18 @@
-import pygame, sys, pygame.mixer
+import pygame
+import sys
+import pygame.mixer
from pygame.locals import *
pygame.init()
clock = pygame.time.Clock()
-screen = pygame.display.set_mode((800,600))
+screen = pygame.display.set_mode((800, 600))
pygame.mouse.set_visible(False)
-#pygame.mouse.set_visible(0)
+# pygame.mouse.set_visible(0)
pygame.mixer.set_num_channels(32)
pygame.display.set_caption("MICshooter")
-screenwidth=screen.get_width()
-screenheight=screen.get_height()
-
-explosions=0
+screenwidth = screen.get_width()
+screenheight = screen.get_height()
+explosions = 0
Oops, something went wrong.

0 comments on commit 2f816d9

Please sign in to comment.