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


Python Board.printP方法代码示例

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


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

示例1: main

# 需要导入模块: import Board [as 别名]
# 或者: from Board import printP [as 别名]
def main():
	life=3
	move=0
	side=0
	level=1
	while(1):
		screen=Board()
		p1=Player(24,2)
		screen.printP(24,2,'P')
		d1=Donkey(4,5)
		screen.printD(4,5,'D')
		os.system("clear")  #clears the terminal screen!
		screen.coingen()
		screen.screenout()
		while(1):
			print "Let's Save The Queen!!"
			print "Enter your move :"
			PX=p1.getX()
			PY=p1.getY()
			ch=getchar()
			if(ch=='q'):
				break
			if(ch=='a' or ch=='A'):
				side=1
				if(screen.checkCHAR(PX,PY-1,'Q')):
					screen.saved('1')
					level+=1
					break
			elif(ch=='D' or ch=='d'):
				side=0
			prevPX=p1.getX()
			prevPY=p1.getY()
			prevDX=d1.getX()
			prevDY=d1.getY()
			d1.move(screen,d1)
			DX=d1.getX()
			DY=d1.getY()
			p1.move(ch,screen,side)
			PX=p1.getX()
			PY=p1.getY()
			
			if(((((ch=='a' or ch=='A') or(ch=='d' or ch=='D') )and ((prevDX==PX and prevDY==PY) and (prevPX==DX and prevPY==DY)))  or (DX==PX and DY==PY) )and (life>0)):
				life-=1
				break
			print ""
			os.system("clear")
			screen.screenout()
			print "Level :",
			print level
			print "Score :",
			print screen.getscore()
			print "Life :",
			print life
			if(DX==PX and DY==PY):
				screen.printD(PX,PY,'D')
				if(life>0):
					continue
				else:
					break
		if(ch=='q'):
			break
		if(life==0):
			print "Sorry U can't make it!!"
			break
		elif(life>0):
			continue
		elif(screen.checkSAVED()==1):
			print "Queen Saved!!",
			continue
		elif(screen.checkSAVED()==0):
			print "Let's Try Again!!",
		print ""
	print "Final Score :",
	print screen.getscore()
	print "Life :",
	print life
	print "Level Reached :",
	print level
开发者ID:SilentFlame,项目名称:Donkey_Kong_Game,代码行数:80,代码来源:Donkey_kong.py


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