示例#1
0
void ParticleEngine::stepEngineEightGravity(int start, int end) {
	float ratio = (float) EIGHT_SIZE / (float) m_part_nbr;
	for (int j = start; j < end; ++j) {
		if (POS_Y(j) > LIMIT_X || POS_Y(j) < -LIMIT_X || POS_X(j) > LIMIT_X
				|| POS_X(j) < -LIMIT_X || POS_Z(j) > LIMIT_Z
				|| POS_Z(j) < -LIMIT_Z)
			initParticle(j);
		int i = j * ratio;
		float u = m_eightPos[i * 2];
		float X = m_eightPos[i * 2 + 1];
		float Z = X;
		float Y = u - 3;

		POS_X(j) += PSPEED_X(j);
		POS_Y(j) += PSPEED_Y(j);
		POS_Z(j) += PSPEED_Z(j);

		const float x = POS_X(j) - X;
		const float y = POS_Y(j) - Y;
		const float z = POS_Z(j) - Z;

		PSPEED_X(j) = -x / 40;
		PSPEED_Y(j) = -y / 40;
		PSPEED_Z(j) = -z / 40;
	}
}
示例#2
0
void ParticleEngine::stepEngineLorrenz(int start, int end) {
	const float teta = 10 / 10.f;
	const float phi = 28 / 10.f;
	const float beta = 8.0f / 3.0f / 10.f;
	const float speed = .01f;

	for (uint i = start; i < end; ++i) {

		if (POS_Y(i) > LIMIT_X || POS_Y(i) < -LIMIT_X || POS_X(i) > LIMIT_X
				|| POS_X(i) < -LIMIT_X || POS_Z(i) > LIMIT_Z
				|| POS_Z(i) < -LIMIT_Z)
			initParticle(i);
		POS_X(i) += PSPEED_X(i);
		POS_Y(i) += PSPEED_Y(i);
		POS_Z(i) += PSPEED_Z(i);

		const float x = POS_X(i);
		const float y = POS_Y(i) + 3;
		const float z = POS_Z(i) + 3;

		PSPEED_X(i) = (teta * (y - x)) * speed;
		PSPEED_Y(i) = (x * (phi - z) - y) * speed;
		PSPEED_Z(i) = (x * y - beta * z) * speed;

	}
}
示例#3
0
//bool cmpx(long lhs, long rhs)
//{
//	long x1 = POS_X(lhs);
//	long x2 = POS_X(rhs);
//	return x1 > x2;
//}
bool cmpxy(long lhs, long rhs)
{
	long y1 = POS_Y(lhs);
	long y2 = POS_Y(rhs);
	long x1 = POS_X(lhs);
	long x2 = POS_X(rhs);
	//if(y1 == y2)return x1 > x2;
	//else return y1 > y2;
	return (x1+y1) < (x2+y2);
}
示例#4
0
void CFindBestPoint::FindBestPoint(int x,int y, int *bestx, int *besty, const char *tiles)
{
	//printf("col:%d row:%d\nx:%d y:%d",m_col, m_row,x,y);
	if( x < 0 || x >= m_col  ||  y < 0 || y >= m_row )
	{//此结点不合法
		*bestx = -1;*besty = -1;
		return;
	}
	//初始化数组
	for(int i = 0;i < m_row;i ++)
	{
		for(int j = 0;j < m_col;j ++)
		{
			m_visited[i][j]=false;
		}
	}

	if(tiles[INDEX(x,y)])//检查是否能通过
	{//如果能通过
		*bestx = x;*besty = y;
		return;
	}
		
	m_visited[y][x] = true;		//标记已访问

	long u;
	m_que.push(POS(x,y));				//初始结点v入队列

	while(!m_que.empty())			//队列非空时
	{
		u = m_que.front();m_que.pop();	//出队列

		//右下
		if(TestPoint(POS_X(u)+1, POS_Y(u)+1, bestx, besty, tiles))break;

		//下
		if(TestPoint(POS_X(u), POS_Y(u)+1, bestx, besty, tiles))break;

		//左下 
		if(TestPoint(POS_X(u)-1, POS_Y(u)+1, bestx, besty, tiles))break;

		//左 
		if(TestPoint(POS_X(u)-1, POS_Y(u), bestx, besty, tiles))break;

		//左上
		if(TestPoint(POS_X(u)-1, POS_Y(u)-1, bestx, besty, tiles))break;

		//上 
		if(TestPoint(POS_X(u), POS_Y(u)-1, bestx, besty, tiles))break;

		//右上
		if(TestPoint(POS_X(u)+1, POS_Y(u)-1, bestx, besty, tiles))break;

		//右 
		if(TestPoint(POS_X(u)+1, POS_Y(u), bestx, besty, tiles))break;
	}
	m_que.c.clear();
}
示例#5
0
文件: boxUI.cpp 项目: PH111P/perm2
    void boxUI::select( u8 p_index ) {
        if( p_index == (u8) -1 ) {
            IO::OamTop->oamBuffer[ ARROW_ID ].isHidden = true;
            IO::updateOAM( false );
            drawAllBoxStatus( );
            return;
        }
        u8 x = 0, y = 0;
        if( p_index < MAX_PKMN_PER_BOX ) {
            x = POS_X( p_index );
            y = POS_Y( p_index );
        } else if( p_index < MAX_PKMN_PER_BOX + 6 ) {
            x = TEAM_POS_X( p_index - MAX_PKMN_PER_BOX ) - 3;
            y = TEAM_POS_Y( p_index - MAX_PKMN_PER_BOX ) - 10;
        } else if( p_index == MAX_PKMN_PER_BOX + 6 ) {
            x = 24;
            y = 23;
        } else if( p_index == MAX_PKMN_PER_BOX + 7 ) {
            x = 208;
            y = 23;
        }
        bool holding                               = !IO::OamTop->oamBuffer[ HELD_PKMN ].isHidden;
        IO::OamTop->oamBuffer[ ARROW_ID ].x        = x + 20 - 5 * holding;
        IO::OamTop->oamBuffer[ ARROW_ID ].y        = y + 4 - 5 * holding;
        IO::OamTop->oamBuffer[ ARROW_ID ].isHidden = false;

        if( p_index < MAX_PKMN_PER_BOX + 6 ) {
            IO::OamTop->oamBuffer[ p_index + PKMN_START ].x = x;
            IO::OamTop->oamBuffer[ p_index + PKMN_START ].y = y;
        }
        // Held pkmn
        IO::OamTop->oamBuffer[ HELD_PKMN ].x = x - 5;
        IO::OamTop->oamBuffer[ HELD_PKMN ].y = y - 5;
        IO::updateOAM( false );
    }
示例#6
0
void ParticleEngine::initParticleRandom(uint idx) {
	POS_X(idx) = Utils::myRand(-LIMIT_X, LIMIT_X) / 1;
	POS_Y(idx) = Utils::myRand(-LIMIT_X, LIMIT_X) / 1;
	POS_Z(idx) = Utils::myRand(-LIMIT_Z, LIMIT_Z) / 1;

	PSPEED_X(idx) = 0;//Utils::myRand(-SPEED_X, SPEED_X) / 10;
	PSPEED_Y(idx) = 0;//Utils::myRand(-SPEED_Y, SPEED_Y) / 10;
	PSPEED_Z(idx) = 0;//Utils::myRand(-SPEED_Z, SPEED_Z) / 10;
}
示例#7
0
文件: boxUI.cpp 项目: PH111P/perm2
    void boxUI::takePkmn( u8 p_index, u16 p_heldPkmnIdx, bool p_isEgg ) {
        if( p_index != (u8) -1 ) {
            box* box = SAVE::SAV->getCurrentBox( );

            pokemon::boxPokemon bpm;
            if( p_index < MAX_PKMN_PER_BOX )
                bpm = box->m_pokemon[ p_index ];
            else if( _showTeam )
                bpm = SAVE::SAV->getActiveFile( )
                          .m_pkmnTeam[ p_index - MAX_PKMN_PER_BOX ]
                          .m_boxdata;
            else
                bpm = SAVE::SAV->m_clipboard[ p_index - MAX_PKMN_PER_BOX ];

            if( bpm.m_speciesId ) {
                u8 pal = p_index + PKMN_PALETTE_START;
                if( !bpm.m_individualValues.m_isEgg ) {
                    IO::loadPKMNIcon( bpm.m_speciesId, POS_X( p_index ), POS_Y( p_index ),
                                      PKMN_START + p_index, pal / 16, pal % 16,
                                      PKMN_TILES_START + 32 * p_index, false );
                } else
                    IO::loadEggIcon( POS_X( p_index ), POS_Y( p_index ), PKMN_START + p_index,
                                     pal / 16, pal % 16, PKMN_TILES_START + 32 * p_index, false );
            } else {
                IO::OamTop->oamBuffer[ PKMN_START + p_index ].isHidden = true;
            }

            if( p_heldPkmnIdx ) {
                if( !p_isEgg )
                    IO::loadPKMNIcon( p_heldPkmnIdx, POS_X( p_index ), POS_Y( p_index ), HELD_PKMN,
                                      6, 0, 64, false );
                else
                    IO::loadEggIcon( POS_X( p_index ), POS_Y( p_index ), HELD_PKMN, 6, 0, 64,
                                     false );
            } else
                IO::OamTop->oamBuffer[ HELD_PKMN ].isHidden = true;
        } else {
            IO::OamTop->oamBuffer[ HELD_PKMN ].isHidden = true;
        }
        select( p_index );
    }
示例#8
0
void CCommander::Move(float dt)
{
	if(m_pHge->Input_KeyDown(HGEK_RBUTTON))//右键行走
	{
		Point pos = m_pSelectSqure->GetMousePoint();
		CUnit* tagetunit = NULL;
		bool attack = false;
		for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
		{
			CUnit* unit = *itr;
			if (unit->GetRect()->TestPoint(pos.x, pos.y))
			{
				if (unit->m_camp + m_camp == 0) 
				{
					attack = true;
					tagetunit = unit;
				}
			}
		}

		POS_LIST* list = NULL;
		//if(!attack)
			list = CUnit::GetPointList(
			pos.x/m_pMap->m_tileWidth,
			pos.y/m_pMap->m_tileHeight,
			m_pMap->m_map);

		for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
		{
			CUnit* unit = *itr;
			if(unit->IsSelected() && unit->m_camp == m_camp)
			{
				if(attack)
				{
					unit->SetAttackTaget(tagetunit);
				}
				//else
				//{
					if(list->size() > 0)
					{
						long pos = list->front();
						float posx = (POS_X(pos))*m_pMap->m_tileWidth;
						float posy = (POS_Y(pos))*m_pMap->m_tileHeight;
						unit->SetDst(Point(posx,posy));
						list->pop();
					}
				//}
			}
		}
		//if(!attack)
			list->c.clear();
	}
}
示例#9
0
void ParticleEngine::stepEnginePlatform(int start, int end) {
	// Begin loop
	for (uint i = start; i < end; ++i) {
		if (m_active[i] == 1) {
			POS_X(i) += PSPEED_X(i);
			POS_Y(i) += PSPEED_Y(i);
			POS_Z(i) += PSPEED_Z(i);
			PSPEED_Y(i) -= m_gravity;

			if (POS_Y(i) > LIMIT_Y || POS_Y(i) < -LIMIT_Y || POS_X(i) > LIMIT_X
					|| POS_X(i) < -LIMIT_X || POS_Z(i) > LIMIT_Z
					|| POS_Z(i) < -LIMIT_Z)
				initParticle(i);

			// consider the center of the cone at 0,CONE_TOP_Y,0
			// it was supposed to be a cone....
			if (POS_Y(i) <= CONE_TOP_Y && POS_Y(i) >= CONE_BOT_Y
					&& PSPEED_Y(i) <= 0) {
				// compute distance to the center
				float dist = (POS_X(i) * POS_X(i)) + (POS_Z(i) * POS_Z(i));
				float maxDist = ((CONE_TOP_Y - POS_Y(i)) / CONE_DELTA)
						* CONE_RAD_SQR;
				if (dist <= maxDist) {
					if (m_hasWave && dist <= m_waveDist + WAVE_WIDTH
							&& dist >= m_waveDist - WAVE_WIDTH)
						PSPEED_Y(i) = m_waveIntensity;
					else
						PSPEED_Y(i) = -PSPEED_Y(i) * BOUNCYNESS;
				}
			}
			if (POS_Y(i) <= m_randomCursor - m_randomSpeed
					&& POS_Y(i) >= m_randomCursor + m_randomSpeed)
				setRandomSpeed(i);
		} else if (m_emit) {
			++(m_active[i]);
		}
	}
}
示例#10
0
void ParticleEngine::stepEngineGravity(int start, int end) {
	for (uint i = start; i < end; ++i) {

		if (POS_Y(i) > LIMIT_X || POS_Y(i) < -LIMIT_X || POS_X(i) > LIMIT_X
				|| POS_X(i) < -LIMIT_X || POS_Z(i) > LIMIT_Z
				|| POS_Z(i) < -LIMIT_Z)
			initParticle(i);

		POS_X(i) += PSPEED_X(i);
		POS_Y(i) += PSPEED_Y(i);
		POS_Z(i) += PSPEED_Z(i);

		const float x = POS_X(i);
		const float y = POS_Y(i) + 3;
		const float z = POS_Z(i);

		float distance = x * x + y * y + z * z;

		PSPEED_X(i) -= (.001f / distance) * x;
		PSPEED_Y(i) -= (.001f / distance) * y;
		PSPEED_Z(i) -= (.001f / distance) * z;
	}
}
示例#11
0
void ParticleEngine::initParticlePlatform(uint idx) {
	POS_X(idx) = m_pos.x;
	POS_Y(idx) = m_pos.y;
	POS_Z(idx) = m_pos.z;

	PSPEED_Y(idx) = (SPEED_Y * Utils::myRand(RAND / 1.2, RAND)) + m_user.y;
	// sampling a point in a disk to have a round projection of particles
	float x, y;
	//x = Utils::myRand(-RAND, RAND);
	//y = Utils::myRand(-RAND, RAND);

	Utils::genRandomDiskPoint(RAND, x, y);
	PSPEED_X(idx) = (SPEED_X * x) + m_user.x;
	PSPEED_Z(idx) = (SPEED_Z * y) + m_user.z;

	/*
	 COLOR_R(idx) = (float)Utils::myRand(0, 255) / 255.0f;
	 COLOR_G(idx) = (float)Utils::myRand(0, 255) / 255.0f;
	 COLOR_B(idx) = (float)Utils::myRand(0, 255) / 255.0f;
	 */

	m_active[idx] = (int) Utils::myRand(-50, 0);
}
示例#12
0
文件: boxUI.cpp 项目: PH111P/perm2
    std::vector<IO::inputTarget> boxUI::draw( bool p_showTeam ) {
        BG_PALETTE[ COLOR_IDX ] = getBoxColor( SAVE::SAV->getActiveFile( ).m_curBox );

        std::vector<IO::inputTarget> res;
        _ranges.clear( );
        _showTeam = p_showTeam;
        box* box  = SAVE::SAV->getCurrentBox( );

        // SubScreen stuff
        IO::printChoiceBox( 50, 23, 206, 48, 6, COLOR_IDX, false, false ); // Box name
        IO::printChoiceBox( 24, 23, 48, 48, 6, GRAY_IDX, false, false );   // <
        IO::printChoiceBox( 208, 23, 232, 48, 6, GRAY_IDX, false, false ); // >

        IO::regularFont->printString( box->m_name, 127, 28, false, IO::font::CENTER );
        IO::regularFont->printString( "<", 31, 28, false );
        IO::regularFont->printString( ">", 216, 28, false );

        u8  oam     = PKMN_START;
        u8  pal     = PKMN_PALETTE_START;
        u16 tileCnt = PKMN_TILES_START;

        IO::printChoiceBox( 24, 51, 232, 136, 6, COLOR_IDX, false, false );

        for( u8 i = 0; i < MAX_PKMN_PER_BOX; ++i ) {
            res.push_back( IO::inputTarget( POS_X( i ) + 5, POS_Y( i ) + 10, POS_X( i ) + 33,
                                            POS_Y( i ) + 31 ) );
            _ranges.push_back( {oam, res.back( )} );
            if( box->m_pokemon[ i ].m_speciesId ) {
                if( !box->m_pokemon[ i ].m_individualValues.m_isEgg ) {
                    tileCnt
                        = IO::loadPKMNIcon( box->m_pokemon[ i ].m_speciesId, POS_X( i ), POS_Y( i ),
                                            oam++, pal / 16, pal % 16, tileCnt, false );
                } else
                    tileCnt = IO::loadEggIcon( POS_X( i ), POS_Y( i ), oam++, pal / 16, pal % 16,
                                               tileCnt, false );
                ++pal;
            } else {
                IO::OamTop->oamBuffer[ oam++ ].isHidden = true;
                tileCnt += 32;
            }
        }

        IO::printRectangle( 0, 140, 255, 192, false, false, WHITE_IDX );
        IO::regularFont->printString( p_showTeam ? GET_STRING( 59 ) : GET_STRING( 60 ), 2, 176,
                                      false );
        for( u8 i = 0; i < 6; ++i ) {
            res.push_back( IO::inputTarget( TEAM_POS_X( i ), TEAM_POS_Y( i ), TEAM_POS_X( i ) + 28,
                                            TEAM_POS_Y( i ) + 21 ) );
            _ranges.push_back( {oam, res.back( )} );

            IO::printChoiceBox( TEAM_POS_X( i ), TEAM_POS_Y( i ), TEAM_POS_X( i ) + 28,
                                TEAM_POS_Y( i ) + 21, 3, GRAY_IDX, false, false );

            u16 species = p_showTeam
                              ? SAVE::SAV->getActiveFile( ).m_pkmnTeam[ i ].m_boxdata.m_speciesId
                              : SAVE::SAV->m_clipboard[ i ].m_speciesId;
            bool isEgg = p_showTeam ? SAVE::SAV->getActiveFile( )
                                          .m_pkmnTeam[ i ]
                                          .m_boxdata.m_individualValues.m_isEgg
                                    : SAVE::SAV->m_clipboard[ i ].m_individualValues.m_isEgg;

            if( species ) {
                if( !isEgg )
                    tileCnt = IO::loadPKMNIcon( species, TEAM_POS_X( i ) - 3, TEAM_POS_Y( i ) - 10,
                                                oam++, pal / 16, pal % 16, tileCnt, false );
                else
                    tileCnt = IO::loadEggIcon( TEAM_POS_X( i ) - 3, TEAM_POS_Y( i ) - 10, oam++,
                                               pal / 16, pal % 16, tileCnt, false );
                ++pal;
            } else {
                IO::OamTop->oamBuffer[ oam++ ].isHidden = true;
                tileCnt += 32;
            }
        }

        drawAllBoxStatus( );
        IO::updateOAM( false );
        return res;
    }