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)
def addFloor(self,x,y,f): __temp = my.attrDict() __temp.x = x __temp.y = y __temp.floor = f self.__floorArray.append(__temp)
def removeFloor(self,x,y,f): __temp = my.attrDict() __temp.x = x __temp.y = y __temp.floor = f self.__floorArray.remove(__temp)
GameObject = person(nameOfPlayer) GamePlayer = Player(nameOfPlayer) DonkeyKong = DonkeyKong("DonkeyKong") lengthOfBoard = 80 breadthOfBoard = 30 myBoard = [] GameSetup = gameDisplaySetup(myBoard, lengthOfBoard, breadthOfBoard) #Now if you want to access the board from outside, access it with GameSetup.myBoard myBoard = GameSetup.myBoard #Input taker without pressing enter getch = _Getch() playerPosition = my.attrDict(x=breadthOfBoard-2,y=2) myBoard[playerPosition.x][playerPosition.y] = 'P' # my.printMyBoard(myBoard) controllerObject = controller.Controller() 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")