Beispiel #1
0
 def moveDonkey(self, myBoard, currentDonkeyPosition):
     while True:
         a = random.randint(4, 10)
         for y in xrange(currentDonkeyPosition, a + 1):
             myBoardLock.acquire()
             myBoard[1][currentDonkeyPosition] = " "
             myBoard[1][y] = "D"
             my.printMyBoard(myBoard)
             myBoardLock.release()
             time.sleep(1)
             currentDonkeyPosition = y
             my.clearScreen()
Beispiel #2
0
def StartGame(myBoard, GamePlayer, GameObject, GameSetup, playerPosition):

    flag = 0
    key = None
    while key != "Q":
        # print("You must know that the game is started")
        # key = GamePlayer._takeInput()
        key = raw_input()
        # key = key
        my.clearScreen()
        myBoardLock.acquire()
        my.printMyBoard(myBoard)

        if flag == 1:
            myBoard[playerPosition.x][playerPosition.y] = "H"
            flag = 0
        elif myBoard[playerPosition.x][playerPosition.y] != "H":
            myBoard[playerPosition.x][playerPosition.y] = " "

        key = key.upper()

        # This statement speeds up the game to very good extent
        try:
            playerPosition = getattr(controllerObject, "move" + key)(myBoard, playerPosition, GameSetup, GameObject)
            GamePlayer._scoreChanger(GameObject.score)
        except Exception, e:
            # This should never occur :-D
            pass

            # if key=='a':
            # 	playerPosition = controllerObject.moveLeft(myBoard,playerPosition,GameSetup, GameObject)
            # elif key=='d':
            # 	playerPosition = controllerObject.moveRight(myBoard,playerPosition,GameSetup, GameObject)
            # elif key=='s':
            # 	playerPosition = controllerObject.moveDown(myBoard,playerPosition,GameSetup, GameObject)
            # elif key=='w':
            # 	playerPosition = controllerObject.moveUp(myBoard,playerPosition,GameSetup, GameObject)

        if myBoard[playerPosition.x][playerPosition.y] == "H":
            flag = 1
        GamePlayer._positionChanger(myBoard, playerPosition)
        myBoardLock.release()
Beispiel #3
0
def screenManagement(myBoard):
	my.clearScreen()
	my.printMyBoard(myBoard)
Beispiel #4
0
def StartGame(myBoard, GamePlayer, GameObject, GameSetup, playerPosition,currentDonkeyPosition):

	flag=0
	key=None
	currentDonkeyPositionDict = my.attrDict()
	currentDonkeyPositionDict.currentDonkeyPosition = currentDonkeyPosition
	# setInterval(screenManagement,1,myBoard)
	setInterval(DonkeyKong.moveDonkey,1,myBoard,currentDonkeyPositionDict)
	while key!='Q':
		# key = key
		# print(chr(27) + "[2J")
		my.clearScreen()
		my.printMyBoard(myBoard)
		key = GamePlayer._takeInput()
		currentDonkeyPosition=(currentDonkeyPosition+1)%10+1
		if flag==1:
			myBoard[playerPosition.x][playerPosition.y] = 'H'
			flag=0
		elif myBoard[playerPosition.x][playerPosition.y] !='H':
			myBoard[playerPosition.x][playerPosition.y] = ' '

		key=key.upper()

		# This statement speeds up the game to very good extent
		try:
			playerPosition = getattr(controllerObject,'move' + key)(myBoard,playerPosition,GameSetup,GameObject)
			GamePlayer._scoreChanger(GameObject.score)
		except Exception, e:
			# This should never occur :-D
			pass
		
		# if key=='a':
		# 	playerPosition = controllerObject.moveLeft(myBoard,playerPosition,GameSetup, GameObject)
		# elif key=='d':
		# 	playerPosition = controllerObject.moveRight(myBoard,playerPosition,GameSetup, GameObject)
		# elif key=='s':
		# 	playerPosition = controllerObject.moveDown(myBoard,playerPosition,GameSetup, GameObject)
		# elif key=='w':
		# 	playerPosition = controllerObject.moveUp(myBoard,playerPosition,GameSetup, GameObject)
		
		if myBoard[playerPosition.x][playerPosition.y] == 'H':
			flag=1
		prev = myBoard[playerPosition.x][playerPosition.y]
		# test = raw_input()
		if controllerObject.dropPlayer(myBoard, playerPosition, GameSetup, GameObject):
			# print("Hello, I am going to drop")
			# prev = myBoard[playerPosition.x][playerPosition.y]
			# print(prev)
			# test = raw_input()
			while myBoard[playerPosition.x+1][playerPosition.y]!='X':
				if prev!='H' and prev!='C':
					# print("Inside first if part")
					myBoard[playerPosition.x][playerPosition.y] = ' '
					# screenManagement(myBoard)
					# print("Changing position to empty space")
				else:
					# print("I am inside the else part")
					myBoard[playerPosition.x][playerPosition.y] = prev
					# screenManagement(myBoard)
				# print("Incrementing player's position")
				playerPosition.x+=1
				prev = myBoard[playerPosition.x][playerPosition.y]
				# print("Storing the value of prev which is", prev)

				controllerObject.CoinCollector(myBoard, playerPosition, GameSetup, GameObject)
				
				if prev!='H' and prev!='C':
					# print("Going to change playerPosition with prev " + prev)
					# test = raw_input()
					GamePlayer._positionChanger(myBoard,playerPosition)
					screenManagement(myBoard)
				# test = raw_input("Going to clear the board")
				screenManagement(myBoard)
				# print(playerPosition, myBoard[playerPosition.x][playerPosition.y])
				time.sleep(0.1)
				# test = raw_input() #The debugger in between
		GamePlayer._positionChanger(myBoard,playerPosition)
		# print("Outside the prev is ", prev)
		screenManagement(myBoard)
#---------------------------------ACCESING OTHER FILES AND THEIR FUNCTIONS----------------------------
nameOfPlayer = raw_input("Please enter your name :-\n")
GameObject = person()
GamePlayer = Player(nameOfPlayer)
lengthOfBoard = 80
breadthOfBoard = 30
myBoard = []
GameSetup = gameDisplaySetup(myBoard, lengthOfBoard, breadthOfBoard)
myBoard = GameSetup.myBoard
myBoard[3][18]='q'
getch = _Getch()
playerPosition = my.attrDict(x=breadthOfBoard-2,y=2)
myBoard[playerPosition.x][playerPosition.y] = 'P'
myBoard[8][3]='D'
myBoard[8][4]='O'
my.printMyBoard(myBoard)

controllerObject = controller.Controller()

#------------------------------------------VARIABLES INITIALISATION------------------------------------------------------------------

flag=0
f=0
var=1
vary=2
varx=8
flag22=0
life=5
flagd=-1
oldf=0
oldf1=0