当前位置: 首页>>代码示例>>Python>>正文


Python Menu.addChoice方法代码示例

本文整理汇总了Python中Menu.Menu.addChoice方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.addChoice方法的具体用法?Python Menu.addChoice怎么用?Python Menu.addChoice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Menu.Menu的用法示例。


在下文中一共展示了Menu.addChoice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Person

# 需要导入模块: from Menu import Menu [as 别名]
# 或者: from Menu.Menu import addChoice [as 别名]
class Person(pygame.sprite.Sprite):
    # Set speed vector
	change_x=0
	change_y=0
	
	#this variable is for when you begin, and the old x and old y, match
	#up to the new/current x and y
	default_left = 90
	default_top = 90

	def __init__(self):
		self.front = 0
		self.back = 1
		self.left = 2
		self.right = 3
		self.oldLeft = 0
		self.oldTop = 0         
		self.strips = []
		self.starting_pos = True
		self.rect = pygame.Rect(0,0,0,0)
		self.list = []
		self.graphicChoice = 0
		self.itemList = []
		self.choice = self.front
		self.dictLookUp = {}
		self.count = 0
		self.cho = 0
		self.clicked = False
		self.clickedSpot = (0,0)
		self.rightButton = False
		self.menu = Menu()
		self.walking = WalkingGUI()
		self.menu.addChoice("walking")
		self.menu.addChoice("back_pack")
		self.menu.addChoice("testing")
		self.menu.makeBasicMenu()
		#self.LTSelectedString = "nothing" 
		self.which = "nothing"
		#print "----"

		#self.backPack = BackPack()
		

	def sizeOfload(self,size):
		for number in range(size):
			self.strips.append(number)
	
	def load(self, filename, rects, count,which,name,colorkey=None, loop=False, frames=1):
		temp = SpriteStripAnim(filename, rects, count, colorkey, loop, frames)
		#self.strips.append(temp)
		#self.strips.append(str(which):  SpriteStripAnim(self, filename, rects, count, colorkey, loop, frames) )
		
		#print "name: ",name
		#print "which: ",which
		if which == "front" or which == "down" :
			num = self.front + self.locForStrips()
			
		if which == "back" or which == "up":
			num = self.back + self.locForStrips()
			
		if which == "left":
			num = self.left + self.locForStrips()
			
		if which == "right":
			num = self.right + self.locForStrips()
		
		self.count += 1
		tempString = name + "-" + which 
		self.dictLookUp[tempString] = num
		#print "num is: ", num 
		#print "-------------"
		self.strips[num] = temp
		self.rect = pygame.Rect(90,90,rects[0][2],rects[0][3])
		
	def locForStrips(self):
		
		diff = self.count % 4
		#print "diff (",diff,") = self.count (",self.count,") % 4"
		#print "returned: ",self.count - diff
		return self.count - diff
		
	def setRect(self,leftX = default_left,topY = default_top):
		self.rect.left = leftX
		self.rect.top = topY
		
	def changeX(self,x):
		self.rect.left += x
	
	def changeY(self,y):
		self.rect.top += y
	
	def setX(self,x):
		self.rect.left = x

	def setY(self,y):
		self.rect.top = y
		
	def getX(self):
		return self.rect.left
		
#.........这里部分代码省略.........
开发者ID:MichaelHaendler,项目名称:python_video_game1,代码行数:103,代码来源:Person.py

示例2: __init__

# 需要导入模块: from Menu import Menu [as 别名]
# 或者: from Menu.Menu import addChoice [as 别名]
class WalkingGUI:

	def __init__(self):
		self.blend = 1
		self.clicked = False
		self.circles = []
		self.initialCircleAddedTF = False
		self.menu = Menu()
		self.menu.addChoice("walk")
		self.menu.addChoice("adjustCircle")
		self.menu.makeBasicMenu()
		self.rightButton = False # for displaying the (big)menu itself
		self.disCirMenu = False #display Circle Menu...for displaying the circle menu on a particular circle
		self.setTo = False #for showing the circles themselves
		self.oldTup = ()
		self.displayMenuAtLoc =(0,0)
		self.tempTupOfPath = []	

	def getMenu(self,map):		
		
		if self.menu.clickedOn(map): #menu.clickedOn returns true if you clicked on one of the squares, and false otherwise
			self.rightButton = False
			self.disCirMenu = False
		string = "here self.disCirMenu is22: ", str(self.disCirMenu)
		Objs2.tempSqs.add(string)
		return self.menu.currentMenu(map,self.displayMenuAtLoc)
		
	def clickedOn(self):
		return self.rightButton 
		
	def run(self):
		return self.setTo 
		
	def setToRun(self):
		self.setTo = True
		
	def stopRun(self):
		print "very bad"
		self.setTo = False
		
	def getAction(self):
		return self.menu.selectedBox()
		
	def resetAction(self):
		self.menu.resetSelectedBox()
		#self.which = "nothing11"
		
	def closeMenu(self):
		self.rightButton = False
		
	def closeCircleMenu(self):#check this out again
		self.disCirMenu = False
		

	def rightClickedACircle(self,map):
	
		#a silly, simple, and hacked way to keep this returning 
		# True so that the Menu doesn't disappear on the next iteration
		string = "self.disCirMenu is11: ", str(self.disCirMenu)
		Objs2.tempSqs.add(string)
		if self.disCirMenu == True:
			return True
				
		#print "bang" 
		for circle in self.circles:
			#print "zoom" 
			if circle.rightClickedOn(map) == True and circle.contains(map['coords']):
				self.displayMenuAtLoc = map['coords']
				self.disCirMenu = True
				return True
				
				
		return False
		#print "---------"
		#return False		
		
	def adjCirclePos(self,map,mouse):
		for circle in self.circles:
			if circle.leftClickedOn(map) and circle.contains(map['coords']):
				if len(self.oldCoords) == 0:
					self.oldCoords = new_tup
					circle.setColor(Color("blue"))
				else:
					new_coords = mouse.getLoc()
					#print "finally!"
					changeXby = new_coords[0] - self.oldCoords[0]
					changeYby = new_coords[1] - self.oldCoords[1]
					circle.adjLoc((changeXby,changeYby))
					old_tup = new_tup	
	
	def noLongerHoldingDownLeftButton(self):
		self.oldTup = ()
		circle.setColor("green")
		
	def hadBeenClickedOn(self,map):
		if len(self.oldTup) >= 1 and (map['button'] == "up" or map['button1'] == False):
			return True
		else:
			return False

#.........这里部分代码省略.........
开发者ID:MichaelHaendler,项目名称:python_video_game1,代码行数:103,代码来源:WalkingGUI.py


注:本文中的Menu.Menu.addChoice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。