Ejemplo n.º 1
0
 def __init__(self, rectangle):
     MySprite.__init__(self)
     # The platforms will be rectangles
     self.rect = rectangle
     # The position will be set as the size of the platform
     self.setPosition((self.rect.left, self.rect.bottom))
     # The platforms are invisible
     self.image = pygame.Surface((0, 0))
Ejemplo n.º 2
0
 def __init__(self, rectangle):
     MySprite.__init__(self)
     # The flag will be a rectangle
     self.rect = rectangle
     # The position will be set as the size of the Flag
     self.setPosition((self.rect.left, self.rect.bottom))
     # The flag area is invisible
     self.image = pygame.Surface((0, 0))
Ejemplo n.º 3
0
    def __init__(self, imageFile, coordFile, nImages, runSpeed, jumpSpeed,
                 animDelay):

        # First we call parent's constructor
        MySprite.__init__(self)

        # Loading the spritesheet.
        self.sheet = ResourcesManager.loadImage(imageFile, -1)
        self.sheet = self.sheet.convert_alpha()
        # Starting movement
        self.movement = STILL
        self.looking = RIGHT

        # Reading the coordinates
        data = ResourcesManager.loadFileCoordinates(coordFile)
        data = data.split()
        self.numStance = 1
        self.numImageStance = 0
        counter = 0
        self.sheetCoords = []
        for line in range(0, 3):
            self.sheetCoords.append([])
            tmp = self.sheetCoords[line]
            for stance in range(1, nImages[line] + 1):
                tmp.append(
                    pygame.Rect(
                        (int(data[counter]), int(data[counter + 1])),
                        (int(data[counter + 2]), int(data[counter + 3]))))
                counter += 4

        self.rect = pygame.Rect(
            100, 100, self.sheetCoords[self.numStance][self.numImageStance][2],
            self.sheetCoords[self.numStance][self.numImageStance][3])

        # Default running and jumping speed
        self.runSpeed = runSpeed
        self.jumpSpeed = jumpSpeed
        # Default stance is standing
        self.numStance = STILL
        self.animationDelay = animDelay  # Constant to reset sprite change
        self.movementDelay = 0  # Counter to delay sprite change
        self.jumpTime = PLAYER_BASE_JUMP  # Time you can keep jumping to increase height
        self.attackTime = 0  # If this is larger than 0 character has to wait to attack
        self.attacking = False  # This indicates if character should attack on current frame
        self.dead = False  # This indicates if character should die on current frame
        self.stunDelay = 0  # This is to reset the stun counter
        self.stunnedTime = 0  # If this is larger than 0 character is hitstunned and cannot move
        self.invulTime = 0  # If this is larger than 0 character is invulnerable and cannot be hit
        # For most enemies these two are the same
        self.updateStance()
Ejemplo n.º 4
0
    def __init__(self, imageFile, coordFile, nImages, moveSpeed, animDelay,
                 looking):

        # First we call parent's constructor
        MySprite.__init__(self)

        # Loading the spritesheet.
        self.sheet = ResourcesManager.loadImage(imageFile, -1)
        self.sheet = self.sheet.convert_alpha()
        # Starting movement
        self.movement = looking
        self.looking = looking

        # Reading the coordinates
        data = ResourcesManager.loadFileCoordinates(coordFile)
        data = data.split()
        self.numStance = 1
        self.numImageStance = 0
        counter = 0
        self.sheetCoords = []
        line = 0
        self.sheetCoords.append([])
        tmp = self.sheetCoords[line]
        for stance in range(1, nImages[line] + 1):
            tmp.append(
                pygame.Rect((int(data[counter]), int(data[counter + 1])),
                            (int(data[counter + 2]), int(data[counter + 3]))))
            counter += 4

        # Delay when changing sprite image
        self.movementDelay = 0
        self.numStance = STILL
        self.moveSpeed = moveSpeed
        self.animationDelay = animDelay

        self.rect = pygame.Rect(
            100, 100, self.sheetCoords[self.numStance][self.numImageStance][2],
            self.sheetCoords[self.numStance][self.numImageStance][3])

        self.updateStance()
Ejemplo n.º 5
0
	def __init__(self, pos_x, pos_y, image1, image2, image3): #Initialise MyHero avec une position (x, y), deux images et l'objet lui-meme.
		MySprite.__init__(self, pos_x, pos_y, image1, image2, image3)
		self.rect = pygame.Rect(pos_x, pos_y, 33, 80)
Ejemplo n.º 6
0
 def __init__(
     self, pos_x, pos_y, image1, image2, image3
 ):  #Initialise MyHero avec une position (x, y), deux images et l'objet lui-meme.
     MySprite.__init__(self, pos_x, pos_y, image1, image2, image3)
     self.rect = pygame.Rect(pos_x, pos_y, 33, 80)
Ejemplo n.º 7
0
 def __init__(self, pos_x, pos_y, image1, image2, image3, speed):
     MySprite.__init__(self, pos_x, pos_y, image1, image2, image3)
     self.rect = pygame.Rect(pos_x, pos_y, 28, 30)
     self.speed = speed
Ejemplo n.º 8
0
	def __init__(self, pos_x, pos_y, image1, image2):
		MySprite.__init__(self, pos_x, pos_y, image1, image2)
Ejemplo n.º 9
0
	def __init__(self, pos_x, pos_y, image1, image2, image3, speed):
		MySprite.__init__(self, pos_x, pos_y, image1, image2, image3)
		self.rect = pygame.Rect(pos_x, pos_y, 28, 30)
		self.speed = speed
Ejemplo n.º 10
0
	def __init__(self, pos_x, pos_y, image1, image2, speed):
		MySprite.__init__(self, pos_x, pos_y, image1, image2)
		self.speed = speed