コード例 #1
0
	def keysdown(self, thetyped):
		self.theword = self.letter(thetyped, self.userinput)	#the growing string
		if self.event.type == KEYDOWN and self.event.key == K_RETURN:
			self.text = ''   ###
			self.text2 = ''  ###
			self.text3 = ''  ###
			self.text4 = ''  ###
			self.text5 = ''  ###
			self.thefinalword = self.theword		#the final string
			self.thefinalword = self.thefinalword.lower()
			self.thefinalword = self.thefinalword.strip()
			
			#identifying the string & running backend
			self.thefinalstring = self.thefinalword.split()
			j = len(self.thefinalstring)
			if j == 0:
				pass	#later turn into "continue" for conversation?
			else:
				firstword = self.thefinalstring[0]
				self.lastword = self.thefinalstring[1:j]	
				self.lastwordlength = len(self.lastword)
				
				#GOTO identifier
				if firstword == 'goto' or firstword == 'go':
					self.goto()
					
				#EMAIL identifier	###
				if firstword == 'check':
					self.emailfunc()

				#ASK identifier        ###
				if firstword == 'ask':
					self.changelastwordtostring()
					print self.lastword
					self.newtext = backend_naomi.ask(self.lastword)
					print self.newtext
					if self.newtext == None:
						self.text = 'Sorry, you have to stay in the bubble.'
					else:
						self.text = self.newtext

				#EXIT identifier	###
				if firstword == 'exit' or firstword == 'quit':
					self.emailurl = 'blankemail.png'
					self.miniquesturl = 'blankminiquests.png'
								
				#loading the bg and person images
				self.image = pygame.image.load(os.path.join('Backgrounds',self.url))
				self.person = pygame.image.load(os.path.join('Characters', 'StickFig2.png'))
				self.emailpic = pygame.image.load(os.path.join('Backgrounds', self.emailurl))	###
				self.miniquestspic = pygame.image.load(os.path.join('Backgrounds', self.miniquesturl))	###
				self.userinput = []		#resetting the userinput
				self.theword = ''		#resetting the displayed text
				
		if self.event.type == KEYDOWN and self.event.key == K_BACKSPACE:	#backspace!
			i = len(self.theword)
			self.userinput = self.userinput[0:i-2]
			self.theword = self.theword[0:i-2]
コード例 #2
0
	def ask(self):
		self.ask = backend_naomi.ask(self.lastword)