Exemple #1
0
    def __init__(self, win_size):
        pygame.sprite.Sprite.__init__(self)

        # set separate images for moving left/right
        # populate a circular linked list with image objects
        #  they can be cycled-through as the octopus moves to animate it
        self.leftImages = imageList.CircularLinkedList()
        self.leftImages.append(pygame.image.load("images/octopus_l.png"))
        self.leftImages.append(pygame.image.load("images/octopus_l2.png"))
        self.leftImages.set_current(
        )  # sets a 'current image' marker on the last image in the list
        self.rightImages = imageList.CircularLinkedList()
        self.rightImages.append(pygame.image.load("images/octopus_r.png"))
        self.rightImages.append(pygame.image.load("images/octopus_r2.png"))
        self.rightImages.set_current()
        # self.jump_image = pygame.image.load("images/octopus_jump.png")
        self.image = self.rightImages.current.data  # image that is displayed
        self.rect = self.image.get_rect()  # rect used for collision detection

        self.floor = win_size[1] - self.rect[3]

        # set starting position
        self.x = int(win_size[0] *
                     .15)  # octopus starts on the left side of the screen
        self.y = 15  # octopus starts at the top of the screen

        # set rect coordinates to match image position
        self.rect[0] = self.x
        self.rect[1] = self.y

        # set starting speed (stationary)
        self.speed = [15, 10]
        self.jump_speed = -10
Exemple #2
0
	def __init__(self,win_size):
		pygame.sprite.Sprite.__init__(self)

		# set separate images for moving left/right
		self.leftImages = imageList.CircularLinkedList()
		self.leftImages.append(pygame.image.load("images/hero_l.png"))
		self.leftImages.set_current()
		self.rightImages = imageList.CircularLinkedList()
		self.rightImages.append(pygame.image.load("images/hero_r.png"))
		self.rightImages.set_current()
		# self.jumpImage = pygame.image.load("images/herojump.png")
		self.image = self.rightImages.current.data
		self.rect = self.image.get_rect() # rect used for collision detection
		
		self.floor = win_size[1]-self.rect[3]-2

		# set starting position
		self.x = int(win_size[0]/2)
		self.y = self.floor
		self.rect[0] = self.x
		self.rect[1] = self.y

		# set starting speed (stationary)
		self.speed = [0,0]
		self.jump_speed = -21
		self.jump = False
Exemple #3
0
	def __init__(self,win_size):
		pygame.sprite.Sprite.__init__(self)

		# use list to store starting positions and images
		# use random to choose list index of starting position and corresponding image
		# arms will appear semi-randomly on the screen

		i = random.randint(0,3)

		# populate a circular linked list with image objects
		#  they can be cycled-through as the arm moves to animate it
		right_images = imageList.CircularLinkedList()
		# right_images.append(pygame.image.load("images/arm_r.png"))
		# right_images.append(pygame.image.load("images/arm_r2.png"))
		right_images.append(pygame.image.load("images/arm_r.png"))
		right_images.append(pygame.image.load("images/arm_r3.png"))
		left_images = imageList.CircularLinkedList()
		# left_images.append(pygame.image.load("images/arm_l.png"))
		# left_images.append(pygame.image.load("images/arm_l2.png"))
		left_images.append(pygame.image.load("images/arm_l.png"))
		left_images.append(pygame.image.load("images/arm_l3.png"))
		
		images = (left_images,right_images)
		self.images = images[i%2]
		self.images.set_current()

		self.rect = self.images.current.data.get_rect()

		# for falling arms
		# starts = ((0,-self.rect[3]),(win_size[0]-self.rect[2],-self.rect[3]))

		# for pushing arms
		starts = ((-self.rect[2],int(win_size[1]*.25)),(win_size[0],int(win_size[1]*.25)),
					(-self.rect[2],int(win_size[1]*.75)),(win_size[0],int(win_size[1]*.75)))
		speeds = ([2,0],[-2,0])

		self.x = starts[i][0]
		self.y = starts[i][1]
		self.rect[0] = self.x
		self.rect[1] = self.y
		
		self.speed = speeds[i%2] #(0,2)
Exemple #4
0
    def __init__(self, win, octopus):
        pygame.sprite.Sprite.__init__(self)
        self.images = imageList.CircularLinkedList()

        for i in range(4):
            dirname = "images/you_died/"
            img = dirname + "dead-" + str(i) + ".png"
            self.images.append(pygame.image.load(img))

        self.images.set_current()
        self.image = self.images.current.data  # image that is displayed

        self.x = int(win.get_size()[0] / 2 -
                     self.image.get_rect()[2] / 2)  #octopus.x
        self.y = int(win.get_size()[1] / 2 -
                     self.image.get_rect()[3] / 2)  #octopus.y
        self.playedSound = False