예제 #1
0
    def __init__(self, sprite_sheet_data):
        """ Platform constructor. Assumes constructed with user passing in
            an array of 5 numbers like what's defined at the top of this
            code. """
        super().__init__()

        sprite_sheet = SpriteSheet("SPRITES/?box.png")
        # Grab the image for this platform
        self.image = sprite_sheet.get_image(sprite_sheet_data[0],
                                            sprite_sheet_data[1],
                                            sprite_sheet_data[2],
                                            sprite_sheet_data[3])

        self.rect = self.image.get_rect()
예제 #2
0
    def __init__(self):
        super().__init__()
        self.width = 43
        self.height = 43
        self.direction = "R"
        self.slash_frame_r = []
        self.slash_frame_l = []
        self.slash_none = []
        sprite_sheet = SpriteSheet("SPRITES/p2_weapon_slash.png")

        # Load all the right facing walking images into a list
        image = sprite_sheet.get_image(107, 218, 43, 43)
        self.slash_frame_r.append(image)
        image = sprite_sheet.get_image(107, 173, 43, 43)
        self.slash_frame_r.append(image)
        image = sprite_sheet.get_image(107, 130, 43, 43)
        self.slash_frame_r.append(image)
        image = sprite_sheet.get_image(107, 86, 43, 43)
        self.slash_frame_r.append(image)
        image = sprite_sheet.get_image(107, 44, 43, 43)
        self.slash_frame_r.append(image)
        image = sprite_sheet.get_image(107, 0, 43, 43)
        self.slash_frame_r.append(image)

        # Load all the left facing walking images, then flip them
        # to face left.
        image = sprite_sheet.get_image(107, 218, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)
        image = sprite_sheet.get_image(107, 173, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)
        image = sprite_sheet.get_image(107, 130, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)
        image = sprite_sheet.get_image(107, 86, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)
        image = sprite_sheet.get_image(107, 44, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)
        image = sprite_sheet.get_image(107, 0, 43, 43)
        image = pygame.transform.flip(image, True, False)
        self.slash_frame_l.append(image)

        # Set a reference to the image rect.
        image = sprite_sheet.get_image(0, 0, 1, 1)
        self.slash_none.append(image)
        self.image = self.slash_none[0]
        self.rect = self.image.get_rect()
예제 #3
0
    def __init__(self):
        """ Constructor function """

        # Call the parent's constructor
        super().__init__()
        # -- Attributes
        self.width = 18
        self.height = 32
        # Set speed vector of player
        self.change_x = 0
        self.change_y = 0

        # This holds all the images for the animated walk left/right
        # of our player
        self.walking_frames_l = []
        self.walking_frames_r = []
        self.idle_walking_l = []
        self.idle_walking_r = []
        self.idle_forward_frame = []
        self.gun_frames_l = []
        self.gun_frames_r = []
        self.idle_gun_l = []
        self.idle_gun_r = []
        self.sword_frames_l = []
        self.sword_frames_r = []
        self.idle_sword_l = []
        self.idle_sword_r = []

        # For winning page
        self.Large = []
        sprite_sheet = SpriteSheet("SPRITES/Player1_Large.png")
        image = sprite_sheet.get_image(60, 96, 190, 384)
        self.Large.append(image)

        # What direction is the player facing?
        self.direction = "F"
        self.idling = True

        self.has_gun = False
        self.has_sword = False
        self.WEAPON = None
        self.ammo = 10
        self.swing = 10

        # List of sprites we can bump against
        self.level = None

        sprite_sheet = SpriteSheet("SPRITES/Sprite1_sheet.png")

        # Load all the right facing walking images into a list
        image = sprite_sheet.get_image(54, 8, 18, 32)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(80, 8, 18, 32)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(54, 8, 18, 32)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(103, 8, 18, 32)
        self.walking_frames_r.append(image)

        image = sprite_sheet.get_image(30, 8, 18, 32)
        self.idle_walking_r.append(image)

        # Load all the right facing gun images into a list
        image = sprite_sheet.get_image(54, 88, 22, 32)
        self.gun_frames_r.append(image)
        image = sprite_sheet.get_image(80, 88, 22, 32)
        self.gun_frames_r.append(image)
        image = sprite_sheet.get_image(54, 88, 22, 32)
        self.gun_frames_r.append(image)
        image = sprite_sheet.get_image(103, 88, 22, 32)
        self.gun_frames_r.append(image)

        image = sprite_sheet.get_image(30, 88, 22, 32)
        self.idle_gun_r.append(image)

        # Load all the right facing sword images into a list
        image = sprite_sheet.get_image(54, 48, 21, 32)
        self.sword_frames_r.append(image)
        image = sprite_sheet.get_image(80, 48, 21, 32)
        self.sword_frames_r.append(image)
        image = sprite_sheet.get_image(54, 48, 21, 32)
        self.sword_frames_r.append(image)
        image = sprite_sheet.get_image(103, 48, 21, 32)
        self.sword_frames_r.append(image)

        image = sprite_sheet.get_image(30, 48, 21, 32)
        self.idle_sword_r.append(image)

        # Load all the left facing walking images, then flip them
        # to face left.
        image = sprite_sheet.get_image(54, 8, 18, 32)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(80, 8, 18, 32)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(54, 8, 18, 32)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(103, 8, 18, 32)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)

        image = sprite_sheet.get_image(30, 8, 18, 32)
        image = pygame.transform.flip(image, True, False)
        self.idle_walking_l.append(image)

        # Load all the left facing gun images, then flip them
        # to face left.
        image = sprite_sheet.get_image(54, 88, 22, 32)
        image = pygame.transform.flip(image, True, False)
        self.gun_frames_l.append(image)
        image = sprite_sheet.get_image(80, 88, 22, 32)
        image = pygame.transform.flip(image, True, False)
        self.gun_frames_l.append(image)
        image = sprite_sheet.get_image(54, 88, 22, 32)
        image = pygame.transform.flip(image, True, False)
        self.gun_frames_l.append(image)
        image = sprite_sheet.get_image(103, 88, 22, 32)
        image = pygame.transform.flip(image, True, False)
        self.gun_frames_l.append(image)

        image = sprite_sheet.get_image(30, 88, 22, 32)
        image = pygame.transform.flip(image, True, False)
        self.idle_gun_l.append(image)

        # Load all the left facing sword images, then flip them
        # to face left.
        image = sprite_sheet.get_image(54, 48, 21, 32)
        image = pygame.transform.flip(image, True, False)
        self.sword_frames_l.append(image)
        image = sprite_sheet.get_image(80, 48, 21, 32)
        image = pygame.transform.flip(image, True, False)
        self.sword_frames_l.append(image)
        image = sprite_sheet.get_image(54, 48, 21, 32)
        image = pygame.transform.flip(image, True, False)
        self.sword_frames_l.append(image)
        image = sprite_sheet.get_image(103, 48, 21, 32)
        image = pygame.transform.flip(image, True, False)
        self.sword_frames_l.append(image)

        image = sprite_sheet.get_image(30, 48, 21, 32)
        image = pygame.transform.flip(image, True, False)
        self.idle_sword_l.append(image)

        # Set the image the player starts with
        image = sprite_sheet.get_image(5, 8, 18, 32)
        self.idle_forward_frame.append(image)
        self.image = self.idle_forward_frame[0]

        # Set a reference to the image rect.
        self.rect = self.image.get_rect()
예제 #4
0
    def __init__(self):
        """Call the contructor of the super class now"""
        pygame.sprite.Sprite.__init__(self)
        sprite_sheet = SpriteSheet("p1_walk.png")
        image = sprite_sheet.get_image(0, 0, 66, 90)
        self.walking_frames_right.append(image)
        image = sprite_sheet.get_image(66, 0, 66, 90)
        self.walking_frames_right.append(image)

        image = sprite_sheet.get_image(132, 0, 67, 90)
        self.walking_frames_right.append(image)

        image = sprite_sheet.get_image(0, 93, 66, 90)
        self.walking_frames_right.append(image)

        image = sprite_sheet.get_image(66, 93, 66, 90)
        self.walking_frames_right.append(image)

        image = sprite_sheet.get_image(132, 93, 72, 90)
        self.walking_frames_right.append(image)

        image = sprite_sheet.get_image(0, 186, 70, 90)
        self.walking_frames_right.append(image)

        #Walking Left
        sprite_sheet = SpriteSheet("p1_walk.png")
        image = sprite_sheet.get_image(0, 0, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(66, 0, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(132, 0, 67, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(0, 93, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(66, 93, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(132, 93, 72, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        image = sprite_sheet.get_image(0, 186, 70, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_left.append(image)

        self.image = self.walking_frames_right[0]

        # Set a reference to the image rect.
        self.rect = self.image.get_rect()
예제 #5
0
	def __init__(self):

		"""Call the contructor of the super class now"""
		pygame.sprite.Sprite.__init__(self)
		sprite_sheet = SpriteSheet("p1_walk.png")
		image = sprite_sheet.get_image(0,0,66,90)
		self.walking_frames_right.append(image)
		image = sprite_sheet.get_image(66,0,66,90)
		self.walking_frames_right.append(image)

		image = sprite_sheet.get_image(132,0,67,90)
		self.walking_frames_right.append(image)

		image = sprite_sheet.get_image(0,93,66,90)
		self.walking_frames_right.append(image)

		image = sprite_sheet.get_image(66,93,66,90)
		self.walking_frames_right.append(image)

		image = sprite_sheet.get_image(132,93,72,90)
		self.walking_frames_right.append(image)

		image = sprite_sheet.get_image(0,186,70,90)
		self.walking_frames_right.append(image)

		#Walking Left
		sprite_sheet = SpriteSheet("p1_walk.png")
		image = sprite_sheet.get_image(0,0,66,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		image = sprite_sheet.get_image(66,0,66,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		image = sprite_sheet.get_image(132,0,67,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)


		image = sprite_sheet.get_image(0,93,66,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		image = sprite_sheet.get_image(66,93,66,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		image = sprite_sheet.get_image(132,93,72,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		image = sprite_sheet.get_image(0,186,70,90)
		image = pygame.transform.flip(image,True,False)
		self.walking_frames_left.append(image)

		self.image = self.walking_frames_right[0]

        # Set a referance to the image rect.
		self.rect = self.image.get_rect()
예제 #6
0
    def __init__(self):
        """ Constructor function """

        # Call the parent's constructor
        super().__init__()

        sprite_sheet = SpriteSheet("p1_walk.png")
        # Load all the right facing images into a list
        image = sprite_sheet.get_image(0, 0, 66, 90)
        self.walking_frames_r.append(image)
        self.walking_frames_u.append(image)
        self.walking_frames_d.append(image)
        image = sprite_sheet.get_image(66, 0, 66, 90)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(132, 0, 67, 90)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(0, 93, 66, 90)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(66, 93, 66, 90)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(132, 93, 72, 90)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(0, 186, 70, 90)
        self.walking_frames_r.append(image)

        # Load all the right facing images, then flip them
        # to face left.
        image = sprite_sheet.get_image(0, 0, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(66, 0, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(132, 0, 67, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(0, 93, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(66, 93, 66, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(132, 93, 72, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(0, 186, 70, 90)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_l.append(image)

        # Set the image the player starts with
        self.image = self.walking_frames_r[0]

        # Set a referance to the image rect.
        self.rect = self.image.get_rect()