コード例 #1
0
ファイル: dungeon.cpp プロジェクト: oss-forks/micropather
	int SetPos( int nx, int ny ) 
	{
		int result = 0;
		if ( Passable( nx, ny ) == 1 )
		{
			#ifdef USE_PATHER
				float totalCost;
				if ( showConsidered )
					pather->Reset();
					
				result = pather->Solve( XYToNode( playerX, playerY ), XYToNode( nx, ny ), &path, &totalCost );

				if ( result == MicroPather::SOLVED ) {
					playerX = nx;
					playerY = ny;
				}
				printf( "Pather returned %d\n", result );

			#else
				playerX = nx;
				playerY = ny;
			#endif
		}
		return result;
	}
コード例 #2
0
ファイル: dungeon.cpp プロジェクト: oss-forks/micropather
	void ToggleDoor() 
	{ 
		doorsOpen = !doorsOpen; 
	
		#ifdef USE_PATHER
		pather->Reset();

		#endif	
	}
コード例 #3
0
ファイル: dungeon.cpp プロジェクト: oss-forks/micropather
	void Print() 
	{
		char buf[ MAPX+1 ];

		MPVector< void* > stateVec;
		
		if ( showConsidered )
			pather->StatesInPool( &stateVec );
		printf( " doors %s\n", doorsOpen ? "open" : "closed" );
		printf( " 0         10        20\n" );
		printf( " 012345678901234567890123456789\n" );
		for( int j=0; j<MAPY; ++j ) {
			// Copy in the line.
			memcpy( buf, &gMap[MAPX*j], MAPX+1 );
			buf[MAPX]=0;

			#ifdef USE_PATHER
			unsigned k;
			// Wildly inefficient demo code.
			unsigned size = path.size();
			for( k=0; k<size; ++k ) {
				int x, y;
				NodeToXY( path[k], &x, &y );
				if ( y == j )
					buf[x] = '0' + k%10;
			}
			if ( showConsidered )
			{
    			for( k=0; k<stateVec.size(); ++k ) {
           			int x, y;
    				NodeToXY( stateVec[k], &x, &y );
    				if ( y == j )
    					buf[x] = 'x';
        		}     
      		}  		
			#endif
			
			// Insert the player
			if ( j==playerY )
				buf[playerX] = 'i';

			printf( "%d%s\n", j%10, buf );
		}
	}
コード例 #4
0
	void ToggleDoor() 
	{ 
		doorsOpen = !doorsOpen; 
	
		#ifdef USE_PATHER
		pather->Reset();
//		// This is very brute force - a "real" app would know where its doors are.
//		const int delta[8] = { 1, 1+MAPX, MAPX, -1+MAPX, -1, -1-MAPX, -MAPX, 1-MAPX };
//
//		for( int i=0; i<MAPX*MAPY; ++i ) 
//		{
//			if ( gMap[i] == 'D' ) {
//				for( int k=0; k<8; ++k ) {
//					int index = i+delta[k];
//					if ( index >= 0 && index < MAPX*MAPY ) {
//						pather->StateCostChange( (void*) index );
//					}
//				}
//			}
//		}
		#endif	
	}
コード例 #5
0
ファイル: dungeon.cpp プロジェクト: oss-forks/micropather
	void ToggleTouched() { 	showConsidered = !showConsidered; 
 							pather->Reset();
						  }
コード例 #6
0
	unsigned Checksum() { return pather->Checksum(); }