Exemplo n.º 1
0
class Adventure(GUI):
	# creates the Adventure
	# syntax: Adventure(width, height)
	# parameters: 
		# width: of the window in pixels (int)
		# height: of the window in pixels (int)
	# returns: None
	def __init__(self, width, height):
		super().__init__()
		self.isDone = False
		self.cutscene = None
		self.__width = width
		self.__height = height
		self.__currentLevel = 0
	# goes to the next level
	# syntax: self.win()
	# parameters: None
	# returns:None
	def win(self):
		self.__currentLevel += 1
		if self.__currentLevel >= len(standardAdventure):
			self.isDone = True
			# ultimate victory
	# gets the game settings for the current level
	# syntax: self.getPlaySettings()
	# parameters: None
	# returns: None
	def getPlaySettings(self):
		return standardAdventure[self.__currentLevel]['settings']
	# displays and animates a cutscene
	# syntax: showCutscene(window)
	# parameters:
		# window: window to draw custscene to (graphics.GraphWin)
	# returns: None
	def showCutscene(self, window):
		self.cutscene = GUI()
		background = Rectangle(Point(0, 0), Point(self.__width, self.__height))
		background.setFill("blue")
		cutsceneText = TextArea(Point(-100, 50))
		level = standardAdventure[self.__currentLevel]
		cutsceneText.add(level['catchphrase'], "black", 12, 0, 40)
		cutsceneText.add(level['villain'], "black", 20, 0, 20)
		cutsceneText.add("Click to continue...", "black", 12, 0, self.__height - 100)
		cutsceneText.add("Level "+str(self.__currentLevel+1), "black", 12, 0, 0)
		self.cutscene.add(background)
		self.cutscene.add(cutsceneText)
		self.cutscene.draw(window)
		for i in range (100):
			cutsceneText.move(5, 0)
			sleep(1/30)
	# undraws and hides the cutscene drawn from showCutscene
	# syntax: hideCutscene()
	# parameters: None
	# returns: None
	def hideCutscene(self):
		self.cutscene.undraw()
		self.cutscene = None