Exemplo n.º 1
0
    def __init__(self, position, image):

        #configuration variables
        self.speed = config._PLAYERSPEED
        self.timeForShooting = config._SHOOTINGSPEED  #in mili seconds

        #construction variables

        #upgrade management
        self.upgrades = 0
        self.shotUpgrades = config._SHOT_UPGRADES
        self.velocityUpgrades = 0
        self.bombs = 0
        self.initTime = pygame.time.get_ticks()

        #position and movement
        self.position = vector2.Vec2d(position)
        self.velocity = vector2.Vec2d(0, 0)
        self.vertical = 0
        self.horizontal = 0

        #image/collision
        self.img = pygame.image.load(image).convert_alpha()
        self.radius = self.img.get_width() / 2
        self.size = [int(x) for x in self.img.get_size()]

        #shooting data
        self.shootingTime = 0
        self.shooting = False
        self.bullets = []
        self.deletionArray = []
        self.shootSound = pygame.mixer.Sound(config._ASSET_DIR +
                                             config._BULLETSOUNDFILE)
        self.state = "neutral"
        self.crashSound = pygame.mixer.Sound(config._ASSET_DIR + "Jump.wav")
Exemplo n.º 2
0
 def __init__(self, position, type, tag, direction):
     self.position = vector2.Vec2d(position)
     #self.img = pygame.image.load(G._ASSET_DIR + G._WEAPONS_DIR + img).convert_alpha()
     self.img = G._BULLET_IMG_SURFACE[type]
     self.img = pygame.transform.scale(
         self.img, (self.img.get_width() * 2, self.img.get_height() * 2))
     self.velocity = vector2.Vec2d(0, 0.3 * direction)
     self.radius = self.img.get_width() / 2
     self.size = [int(x) for x in self.img.get_size()]
     self.initTime = pygame.time.get_ticks()
     self.deleteMe = False
     self.tag = tag
Exemplo n.º 3
0
    def __init__(self, position, img):

        self.velocity = vector2.Vec2d(0, G._ENEMY_SPEED)
        self.img = pygame.image.load(G._ASSET_DIR + G._SHIPS_DIR +
                                     img).convert_alpha()
        self.radius = self.img.get_width() / 2
        self.size = [int(x) for x in self.img.get_size()]
        self.img = pygame.transform.scale(self.img,
                                          (self.size[0] * 2, self.size[1] * 2))
        self.position = vector2.Vec2d(position)
        self.state = "up"
        self.lastShot = pygame.time.get_ticks()

        #array of boss bullets
        self.bullets = []
Exemplo n.º 4
0
 def __init__(self, position, type, worth):
     self.position = vector2.Vec2d(position)
     self.velocity = vector2.Vec2d(0,-G._ENEMY_SPEED)
     self.initTime = pygame.time.get_ticks()
    # self.img = pygame.image.load( img ).convert_alpha()
     self.img = G._ENEMIES_SURFACE[type]
     self.alive = True
     self.size = self.img.get_size()
     self.radius = self.img.get_width()/2
     self.worth = worth
     self.deleteMe = False
     self.tag = "enemy"
     self.crashSound = G._ENEMYDEATHSOUND
     self.lastShot = pygame.time.get_ticks()
     
     #DIRECTION: 1 down, 2 up, 3 left, 4 right
     self.direction = 2
     self.setRandomDirection = False
Exemplo n.º 5
0
 def __init__(self, count, type, startingPos):
     self.deleteMe = False
     self.enemies = []
     self.countX = count
     self.countY = 1
     self.type = type
     self.startingpos = vector2.Vec2d(startingPos)
     #self.imgType = pygame.image.load( G._ASSET_DIR +  G._SHIPS_DIR + G._ENEMYTYPE[self.type] ).convert()
     self.imgType = G._ENEMIES_SURFACE[self.type]
     self.size = self.imgType.get_size()
     self.initTime = pygame.time.get_ticks()
     self.initialize()
Exemplo n.º 6
0
 def __init__(self, img, position):
     self.img = pygame.image.load(G._ASSET_DIR + str(img))
     self.position = vector2.Vec2d(position)
     self.velocity = vector2.Vec2d(0, -G._ENEMY_SPEED)
Exemplo n.º 7
0
 def __init__(self, screen, img):
     self.demoimg = pygame.draw.circle(screen, (255, 255, 225),
                                       G._SCREEN_HEIGHT, 5)
     self.velocity = vector2.Vec2d(0, G._ENEMY_SPEED)
     self.position = vector2.Vec2d(position)
     self.radius = self.img.get_width() / 2
Exemplo n.º 8
0
    def __init__(self, position, image, sType, maxed):
        self.img = G._BULLET_IMG_SURFACE[G._SHOT_UPGRADES]
        #bullets created based on upgrade type
        if maxed:
            self.radius = 10
        else:
            self.radius = 5

        #base bullet, also used in shotgun
        if sType == "0":
            self.velocity = vector2.Vec2d(0, -1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y -= image.get_height() / 2
            self.deleteMe = False

        #Doubleshot 1
        elif sType == "1a":
            self.velocity = vector2.Vec2d(0, -1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y -= image.get_height() / 2
            self.position.x -= 10
            self.deleteMe = False

        #Doubleshot 2
        elif sType == "1b":
            self.velocity = vector2.Vec2d(0, -1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y -= image.get_height() / 2
            self.position.x += 10
            self.deleteMe = False

        #shotgun 1
        elif sType == "2a":
            self.velocity = vector2.Vec2d(-1, -1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y -= image.get_height() / 2
            self.position.x -= 10
            self.deleteMe = False

        #shotgun 2
        elif sType == "2b":
            self.velocity = vector2.Vec2d(1, -1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y -= image.get_height() / 2
            self.position.x += 10
            self.deleteMe = False

        #rearshot
        elif sType == "3":
            self.velocity = vector2.Vec2d(0, 1)
            self.position = vector2.Vec2d(position.x, position.y)
            self.initTime = pygame.time.get_ticks()
            self.position.y += image.get_height() / 2
            self.deleteMe = False