Exemple #1
0
void GameLogic_init::initClip(){
    for (int i=0; i<BLOCK_NUM_WH; i++) {
        if (m_blocks[i]->getBottomType() == BLOCK_BOTTOM_SPACE||
            m_blocks[i]->getBottomType() == BLOCK_BOTTOM_GUN||
            m_blocks[i]->getBottomType() == BLOCK_BOTTOM_COIL_GUN) {
            continue;
        }
        clip(m_clipper,GetBlockPos(i), BLOCK_WH);
    }
}
Exemple #2
0
void GameLogic_init::initBlockOffset(){
    m_block_offset = CCPointZero;
    float minX = 0;
    float minY = 0;
    float maxX = 0;
    float maxY = 0;
    bool first = true;
    for (int i=0; i<BLOCK_NUM_WH; i++) {
        if (m_blocks[i]->getBottomType() == BLOCK_BOTTOM_SPACE||
            m_blocks[i]->getBottomType() == BLOCK_BOTTOM_GUN||
            m_blocks[i]->getBottomType() == BLOCK_BOTTOM_COIL_GUN) {
            continue;
        }
        
        //if (m_blocks[i]>0) {
        CCPoint pos = GetBlockPos(i);
        if (first) {
            minX = pos.x;
            minY = pos.y;
            maxX = pos.x;
            maxY = pos.y;
            first = false;
        }else{
            minX = MIN(minX,pos.x);
            minY = MIN(minY,pos.y);
            maxX = MAX(maxX,pos.x);
            maxY = MAX(maxY,pos.y);
        }
        // }
        
    }
    CCPoint _center = ccp((maxX+minX)/2,(minY+maxY)/2);
    switch (G::g_game_mode) {
        case GAMEMODE_STAGE:
            m_block_offset = ccp(_pCenter.x -_center.x,_pCenter.y -_center.y-50);
            break;
        case GAMEMODE_HOLE:
        {
            float offsety =  (_pScreenSize.height - 960)/2;
            m_block_offset = ccp(_pCenter.x -_center.x,_pBottom + 762 + BLOCK_WH/2+offsety);
        }
            break;
        case GAMEMODE_SEA:
            m_block_offset = ccp(_pCenter.x -_center.x,_pCenter.y -_center.y-50);
            break;
        default:
            break;
    }
   
    CCLOG("%f,%f",m_block_offset.x,m_block_offset.y);
}
Exemple #3
0
const bool	CLevel::LoadItemList( std::fstream& stream )
{
	Log.Log( "GLEVEL( " + file + " ): £adowanie listy przedmiotów.");

	std::string str;
	std::vector<std::string> params;
	ITEM_TYPE type;
	int x, y;

	while( stream )
	{
		str = GetLine( stream );

		if( str == "END ITEMLIST" )
			return true;

		str = ClearWhiteSpace( str );	

		params.clear();
		if( ParseItem( str, x, y, type, params ) )
		{
			CItem* item = nullptr;
			switch (type)
			{
				break;
			case ITEM_TYPE::AMMO:
				item = new CItemAmmo( ParseWeapon( params[0] ) , StrToUInt( params[1] ) );
				break;

			case ITEM_TYPE::HEALTH:
				item = new CItemHealth( StrToFloat( params[0] ) );
				break;

			case ITEM_TYPE::ARMOR:
				item = new CItemArmor( StrToFloat( params[0] ) );
				break;

			case ITEM_TYPE::WEAPON:
				item = new CItemWeapon( ParseWeapon( params[0] ), StrToUInt( params[1] ) );
				break;

			case ITEM_TYPE::UNKNOWN:
			default:
				Log.Error("GLEVEL( " + file + " ): B³¹d parsowania przedmiotu, nieznany typ z parsowania ci¹gu: " + str + ".");
				break;
			}

			if(item != nullptr)
			{
				item->Pos = GetBlockPos( x, y );
				AddEntity( item );
				Items.push_back( item );
			}
		}
		else
		{
			Log.Error("GLEVEL( " + file + " ): B³¹d parsowania przedmiotu dla ci¹gu: " + str + ".");
		}
	}

	Log.Error( "GLEVEL( " + file + " ): Brak koñca listy przedmiotów!" );
	return false;
}
Exemple #4
0
const Vector3f CLevel::GetBlockPos( const unsigned i ) const
{
	return GetBlockPos( i % Cols, i / Cols );
}