void Enemy::SpawnEnemies()
{
    float k = 0.f;
    SetEnemySpawnTime();
    for (int i = 0; i < 4; i++) {
        CreateEnemy(i);
        agk::SetSpritePosition(enemySprites[i], 500.f + k, ENEMY_START_HEIGHT);
        k += 24.f;
    }
    std::cout << "Enemy mass: " << agk::GetSpritePhysicsMass(enemySprites[2]) << std::endl << std::endl;
}
Ejemplo n.º 2
0
	void GameStage::OnCreate() {
		try {
			//ビューとライトの作成
			CreateViewLight();
			//プレートの作成
			CreatePlate();
			//プレーヤーの作成
			CreatePlayer();
			//敵の作成
			CreateEnemy();
		}
		catch (...) {
			throw;
		}
	}
Ejemplo n.º 3
0
GenerateShit::GenerateShit(QGraphicsScene *_scene, Jopa *_jopa, Player *_player)
{

    QObject::connect( &timer_create_enemy, SIGNAL(timeout()), this, SLOT(CreateEnemy()) );
    timer_create_enemy.start(1000 / 0.5);

    QObject::connect( &timer_update, SIGNAL(timeout()), this, SLOT(Update()));
    timer_update.start(1000 / 30);

    scene = _scene;
    jopa = _jopa;
    player = _player;

    time.start();

    isActive = false;
}
Ejemplo n.º 4
0
void Enemies::Initialize()
{
	std::list<Wave*>::iterator iterWave = waves.begin();
	while (iterWave != waves.end())
	{
		std::list<EnemyEvent*>::iterator iterEnemyEvents = (*iterWave)->GetEnemyEvents()->begin();
		while (iterEnemyEvents != (*iterWave)->GetEnemyEvents()->end())
		{
			(*iterWave)->GetEnemies()->push_back(CreateEnemy(*iterEnemyEvents));
			(*iterWave)->GetEnemies()->back()->SetSpawnTime((*iterEnemyEvents)->spawnTime);
			(*iterWave)->GetEnemies()->back()->Initialize();
			iterEnemyEvents++;
		}
		(*iterWave)->GetEnemyEvents()->clear();
		iterWave++;
	}
	currentWave = waves.begin();
}
Ejemplo n.º 5
0
	void GameStage::OnCreate() {
		try {
			wstring DataDir;
			App::GetApp()->GetDataDirectory(DataDir);
			//XMLの読み込み
			m_XmlDocReader.reset(new XmlDocReader(DataDir + L"GameStage.xml"));
			//ビューとライトの作成
			CreateViewLight();
			//プレートの作成
			CreatePlate();
			//ボックスの作成
			CreateFixedBox();
			//プレーヤーの作成
			CreatePlayer();
			//敵の作成
			CreateEnemy();
		}
		catch (...) {
			throw;
		}
	}
Ejemplo n.º 6
0
Archivo: map.cpp Proyecto: f3yagi/mysrc
void CreateObject(Map *map)
{
    int i;

    InitEnemy();
    InitItem();
    InitBomb();
    InitEffect();
    for (i = 0; i < map->objectNum; i++) {
        float x = (float)map->object[i].x * BLOCK_WIDTH;
        float y = (float)map->object[i].y * BLOCK_HEIGHT;
        char type = map->object[i].type;
        int r;
        if (type == PLAYER) {
            InitPlayer(x, y);
        }
        r = CreateEnemy(type, x, y);
        if (r) {
            continue;
        }
        CreateItem(type, x, y);
    }
    MoveMap(map);
}    
Ejemplo n.º 7
0
string osl_ExecuteSystemFunction(vector<OSL_LEXEM>* list)
{
	string _result;
	_result.resize(0);

	#ifdef _DEBUG_OSL
	WriteToLog(DEFAULT_OSL_LOG_NAME, "Executing system function...");
	#endif

	unsigned int param_count = 1;

	for(vector<OSL_LEXEM>::iterator it = list->begin();
		it != list->end();
		it++)
	{
		OSL_LEXEM lx = *it;

		if(osl_IsComma(lx.token))
			param_count++;
	}

	vector<OSL_LEXEM>::iterator i_first = list->begin();
	OSL_LEXEM first = *i_first;

	if(first.token == "echo")
	{
		vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
		OSL_LEXEM second = *i_second;

		char* message = new char[second.token.length()+1];
		strcpy(message, (char*)second.token.data());

		message = osl_RemoveQuotesChr(message);
		DoEcho(message);
	}
	else if(first.token == "load")
	{
		vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
		OSL_LEXEM second = *i_second;

		bool ok = DoLoad(osl_RemoveQuotesStr(second.token));

		ok == true ? _result = OSL_EXEC_OK : _result = OSL_EXEC_FAIL;
	}
	else if(first.token == "exit")
	{
		DoExit();
	}
	else if(first.token == "init")
	{
					vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
					OSL_LEXEM second = *i_second;

					if(second.token == "gui")
					{
						if(!gui)
						{
							gui = new GUI();
							_result = OSL_EXEC_OK;
						}
						else
						{
							osl_Error("GUI already initialized");
							_result = OSL_EXEC_FAIL;
						}
					}
					else
					{
						osl_Error("init(): unknown parameter");
						_result = OSL_EXEC_FAIL;
					}
	}
	else if(first.token == "loadconfig")
	{
		vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
		OSL_LEXEM second = *i_second;

		if(osl_IsStrConstant(second.token))
		{
			char* file = new char[second.token.length()+1];
			strcpy(file, (char*)second.token.data());
			file = osl_RemoveQuotesChr(file);

			bool ok = LoadConfig(file, &cfg);

			if(ok)
			{
				ApplyConfig(&cfg);
				_result = OSL_EXEC_OK;
			}
			else
				_result = OSL_EXEC_FAIL;
		}
		else
			osl_Error("LoadConfig(): Invalid argument");
	}
	else if(first.token == "loadfontfromfile")
	{
		WriteToLog(DEFAULT_OSL_LOG_NAME, "Trying to load font from file...");

		if(param_count == 3)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;
			vector<OSL_LEXEM>::iterator i_fourth = list->begin()+6;
			OSL_LEXEM fourth = *i_fourth;

			if(osl_IsIntConstant(third.token) &&
				osl_IsIntConstant(fourth.token))
			{
				try
				{
					if(LoadFontFromFile((char*)osl_RemoveQuotesStr(second.token).c_str(),
						osl_StrToInt(third.token),
						osl_StrToInt(fourth.token)))
					{
						WriteToLog(DEFAULT_OSL_LOG_NAME, "LoadFontFromFile OK");
						_result = OSL_EXEC_OK;
					}
					else
					{
						WriteToLog(DEFAULT_OSL_LOG_NAME, "LoadFontFromFile FAILED");
						_result = OSL_EXEC_FAIL;
					}
				}
				catch(...)
				{
					osl_Error("Exception in try block: LoadFontFromFile");
					_result = OSL_EXEC_FAIL;
				}			
			}
			else
			{
				osl_Error("LoadFontFromFile() error: incompatible types");
				_result = OSL_EXEC_FAIL;
			}
		}
		else
		{
			osl_Error("LoadFontFromFile() error: function require one parameter");
			_result = OSL_EXEC_FAIL;
		}
	}
	else if(first.token == "loadfont")
	{
		WriteToLog(DEFAULT_OSL_LOG_NAME, "Trying to load font...");
		if(param_count == 4)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;
			vector<OSL_LEXEM>::iterator i_fourth = list->begin()+6;
			OSL_LEXEM fourth = *i_fourth;
			vector<OSL_LEXEM>::iterator i_fifth = list->begin()+8;
			OSL_LEXEM fifth = *i_fifth;

			try
			{
				bool ok =
					LoadFont((char*)osl_RemoveQuotesStr(second.token).c_str(),
						osl_StrToInt(third.token),
						osl_StrToInt(fourth.token),
						(char*)osl_RemoveQuotesStr(fifth.token).c_str());

				ok == true ? _result = OSL_EXEC_OK : _result = OSL_EXEC_FAIL;
			}
			catch(...)
			{
				osl_Error("Exception in try block: LoadFont");
				_result = OSL_EXEC_FAIL;
			}
			WriteToLog(DEFAULT_OSL_LOG_NAME, "LoadFont OK");

		}
		else
		{
			osl_Error("LoadFont() error: function requires two parametres");
			_result = OSL_EXEC_FAIL;
		}
	}
	else if(first.token == "loadtexture")
	{
		WriteToLog(DEFAULT_OSL_LOG_NAME, "Trying to load texture...");
		if(param_count == 1)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;

			try
			{
				string s = osl_RemoveQuotesStr(second.token);
				char* n = new char[strlen(s.data())+1];
				sprintf(n, "%s\0", s.data());

				if(!LoadTexture(n))
				{
					osl_Error("LoadTexture() failed");
					_result = OSL_EXEC_FAIL;
				}
				else
					_result = OSL_EXEC_OK;
				delete[] n;
			}
			catch(...)
			{
				osl_Error("Exception in try block: LoadTexture");
				_result = OSL_EXEC_FAIL;
			}
			WriteToLog(DEFAULT_OSL_LOG_NAME, "LoadTexture OK");
		}
		else
		{
			osl_Error("LoadTexture() error: function requires one parameter");
			_result = OSL_EXEC_FAIL;
		}
	}
	else if(first.token == "newguielem")
	{
		if(param_count == 2)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;

			NewGUIElem(osl_RemoveQuotesStr(second.token),
				osl_RemoveQuotesStr(third.token));
		}
		else
			osl_Error("NewGUIElem() error: function requires two parametres");
	}
	else if(first.token == "setguielem")
	{
		if(param_count == 3)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;
			vector<OSL_LEXEM>::iterator i_fourth = list->begin()+6;
			OSL_LEXEM fourth = *i_fourth;

			SetGUIElem(osl_RemoveQuotesStr(second.token),
				osl_RemoveQuotesStr(third.token),
				osl_RemoveQuotesStr(fourth.token));
		}
		else if(param_count == 5)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;
			vector<OSL_LEXEM>::iterator i_fourth = list->begin()+6;
			OSL_LEXEM fourth = *i_fourth;
			vector<OSL_LEXEM>::iterator i_fifth = list->begin()+8;
			OSL_LEXEM fifth = *i_fifth;
			vector<OSL_LEXEM>::iterator i_sixth = list->begin()+10;
			OSL_LEXEM sixth = *i_sixth;

			SetGUIElem(osl_RemoveQuotesStr(second.token),
				osl_RemoveQuotesStr(third.token),
				osl_RemoveQuotesStr(fourth.token),
				osl_RemoveQuotesStr(fifth.token),
				osl_RemoveQuotesStr(sixth.token));
		}
		else if(param_count == 6)
		{
			vector<OSL_LEXEM>::iterator i_second = list->begin()+2;
			OSL_LEXEM second = *i_second;
			vector<OSL_LEXEM>::iterator i_third = list->begin()+4;
			OSL_LEXEM third = *i_third;
			vector<OSL_LEXEM>::iterator i_fourth = list->begin()+6;
			OSL_LEXEM fourth = *i_fourth;
			vector<OSL_LEXEM>::iterator i_fifth = list->begin()+8;
			OSL_LEXEM fifth = *i_fifth;
			vector<OSL_LEXEM>::iterator i_sixth = list->begin()+10;
			OSL_LEXEM sixth = *i_sixth;
			vector<OSL_LEXEM>::iterator i_seventh = list->begin()+12;
			OSL_LEXEM seventh = *i_seventh;

			SetGUIElem(osl_RemoveQuotesStr(second.token),
				osl_RemoveQuotesStr(third.token),
				osl_RemoveQuotesStr(fourth.token),
				osl_RemoveQuotesStr(fifth.token),
				osl_RemoveQuotesStr(sixth.token),
				osl_RemoveQuotesStr(seventh.token));
		}
		else
			osl_Error("NewGUIElem() error: incorrect number of parametres");
	}
	else if(first.token == "createplayer")
	{
		if(param_count == 28)
		{
			vector<OSL_LEXEM>::iterator p1 = list->begin()+2;
			vector<OSL_LEXEM>::iterator p2 = list->begin()+4;
			vector<OSL_LEXEM>::iterator p3 = list->begin()+6;
			vector<OSL_LEXEM>::iterator p4 = list->begin()+8;
			vector<OSL_LEXEM>::iterator p5 = list->begin()+10;
			vector<OSL_LEXEM>::iterator p6 = list->begin()+12;
			vector<OSL_LEXEM>::iterator p7 = list->begin()+14;
			vector<OSL_LEXEM>::iterator p8 = list->begin()+16;
			vector<OSL_LEXEM>::iterator p9 = list->begin()+18;
			vector<OSL_LEXEM>::iterator p10 = list->begin()+20;
			vector<OSL_LEXEM>::iterator p11 = list->begin()+22;
			vector<OSL_LEXEM>::iterator p12 = list->begin()+24;
			vector<OSL_LEXEM>::iterator p13 = list->begin()+26;
			vector<OSL_LEXEM>::iterator p14 = list->begin()+28;
			vector<OSL_LEXEM>::iterator p15 = list->begin()+30;
			vector<OSL_LEXEM>::iterator p16 = list->begin()+32;
			vector<OSL_LEXEM>::iterator p17 = list->begin()+34;
			vector<OSL_LEXEM>::iterator p18 = list->begin()+36;
			vector<OSL_LEXEM>::iterator p19 = list->begin()+38;
			vector<OSL_LEXEM>::iterator p20 = list->begin()+40;
			vector<OSL_LEXEM>::iterator p21 = list->begin()+42;
			vector<OSL_LEXEM>::iterator p22 = list->begin()+44;
			vector<OSL_LEXEM>::iterator p23 = list->begin()+46;
			vector<OSL_LEXEM>::iterator p24 = list->begin()+48;
			vector<OSL_LEXEM>::iterator p25 = list->begin()+50;
			vector<OSL_LEXEM>::iterator p26 = list->begin()+52;
			vector<OSL_LEXEM>::iterator p27 = list->begin()+54;
			vector<OSL_LEXEM>::iterator p28 = list->begin()+56;

			CreatePlayer((*p1).token, (*p2).token, (*p3).token, (*p4).token,
				(*p5).token, (*p6).token, (*p7).token, (*p8).token, (*p9).token,
				(*p10).token, (*p11).token, (*p12).token, (*p13).token, (*p14).token,
				(*p15).token, (*p16).token, (*p17).token, (*p18).token, (*p19).token,
				(*p20).token, (*p21).token, (*p22).token, (*p23).token, (*p24).token,
				(*p25).token, (*p26).token, (*p27).token, (*p28).token);


		}
		else
			osl_Error("CreatePlayer() error: incorrect number of parametres");
	}
	else if(first.token == "createpowerup")
	{
		if(param_count == 4)
		{
			vector<OSL_LEXEM>::iterator p1 = list->begin()+2;
			vector<OSL_LEXEM>::iterator p2 = list->begin()+4;
			vector<OSL_LEXEM>::iterator p3 = list->begin()+6;
			vector<OSL_LEXEM>::iterator p4 = list->begin()+8;

			CreatePowerup((*p1).token, (*p2).token, (*p3).token, (*p4).token);

		}
		else
			osl_Error("CreatePowerup() error: incorrect number of parametres");
	}
	else if(first.token == "createenemy")
	{
		if(param_count == 3)
		{
			vector<OSL_LEXEM>::iterator p1 = list->begin()+2;
			vector<OSL_LEXEM>::iterator p2 = list->begin()+4;
			vector<OSL_LEXEM>::iterator p3 = list->begin()+6;

			CreateEnemy((*p1).token, (*p2).token, (*p3).token);
		}
		else
			osl_Error("CreateEnemy() error: incorrect number of parametres");
	}
	else
		osl_Error("Command is not implemented yet");

	return _result;

}
Ejemplo n.º 8
0
void CStageMap::Move(int x, int y)
{
	const int APPEAR_X = 780 - 150;

	int i, result;

	//?? 상수가 들어 갔음
	if (s_impl.map_absolute_x + 17 >= MAP_X_MAX)
	{
		s_impl.end_of_map = true;
		return;
	}

	s_impl.map_local_x = s_impl.map_local_x + x;
	s_impl.map_local_y = s_impl.map_local_y + y;

	while ((s_impl.map_local_x + x) < 0)
	{
		s_impl.map_local_x += TILE_X_SIZE;
		--s_impl.map_absolute_x;
	}

	while ((s_impl.map_local_x + x) >= TILE_X_SIZE)
	{
		s_impl.map_local_x -= TILE_X_SIZE;
		++s_impl.map_absolute_x;

		result = -1;
		if (s_impl.map_absolute_x + 13 < MAP_X_MAX)
		{
			switch ((*s_impl.map_data)[s_impl.map_absolute_x + 12][0])
			{
				case 1:
					result = CreateEnemy(TILENAME_ZACO_FLY, 5, APPEAR_X, 50, true);
					break;
				case 2:
					result = CreateEnemy(TILENAME_ZACO_ROACH, 10, APPEAR_X, 150, false);
					break;
				case 3:
					result = CreateEnemy(TILENAME_ZACO_BIG_SHIT, 5, APPEAR_X, 100, false);
					break;
				case 4:
					result = CreateEnemy(TILENAME_ZACO_TEETH, 10, APPEAR_X, 150, false);
					break;
				case 5 :
				{
					SetSysDesc().stage.message.remained_ticks = 100;

					tchar stage_message[256];
					util::ComposeString(stage_message, TCHAR("'STAGE @ BOSS : "), GetSysDesc().stage.current_stage);
					// -> sprintf(stage_message, "'STAGE %i BOSS : ", GetSysDesc().stage.current_stage);

					switch (GetSysDesc().stage.current_stage % 5)
					{
						case 1 :
							result = CreateEnemy(TILENAME_BOSS_GAS_MAN, 100, APPEAR_X, 10, false);
							STRCAT(stage_message, RES_STR_BOSS_NAME[0]);
							break;
						case 2 :
							result = CreateEnemy(TILENAME_BOSS_NOSE_WAX_MAN, 200, APPEAR_X, 10, false);
							STRCAT(stage_message, RES_STR_BOSS_NAME[1]);
							break;
						case 3 :
							result = CreateEnemy(TILENAME_BOSS_HAIR_WAX_MAN2, 200, APPEAR_X, 10, false);
							STRCAT(stage_message, RES_STR_BOSS_NAME[2]);
							break;
						case 4 :
							result = CreateEnemy(TILENAME_BOSS_OVEREAT_MAN, 300, APPEAR_X, 10, false);
							STRCAT(stage_message, RES_STR_BOSS_NAME[3]);
							break;
						case 0 :
							result = CreateEnemy(TILENAME_BOSS_SHIT_FIGHTER, 500, APPEAR_X + 20, 10, false);
							STRCAT(stage_message, RES_STR_BOSS_NAME[4]);
							break;
						default:
							//??
							break;
					}

					SetSysDesc().stage.message.Set(stage_message);
				}
				break;
				default:
					//??
					break;
			}
		}

		if (result == 0)
		{
			s_impl.map_local_x += TILE_X_SIZE;
			--s_impl.map_absolute_x;

			s_impl.map_local_x = s_impl.map_local_x - x;
			s_impl.map_local_y = s_impl.map_local_y - y;

			return;
		}
		else if ((*s_impl.map_data)[s_impl.map_absolute_x + 12][0] == 5)
		{
			if (GetSysDesc().use_sound)
			{
				// endTMF;
				// playTMF('Boss');
			}
		}
	}

	while ((s_impl.map_local_y + y) < 0)
	{
		s_impl.map_local_y += TILE_Y_SIZE;
		--s_impl.map_absolute_y;
	}

	while ((s_impl.map_local_y + y) >= TILE_Y_SIZE)
	{
		s_impl.map_local_y -= TILE_Y_SIZE;
		++s_impl.map_absolute_y;
	}

	for (i = MIN_ENEMY; i <= MAX_ENEMY; i++)
	{
		if (objects[i])
		{
			objects[i]->Move(x, y);
			objects[i]->Move(-x, -y);
		}
	}

	for (i = MIN_FRIEND; i <= MAX_FRIEND; i++)
	{
		if (objects[i])
		{
			objects[i]->Move(x, y);
			objects[i]->Move(-x, -y);
		}
	}
}
Ejemplo n.º 9
0
//Upate all enemies
void CEnemyManager::Update(float delta)
{
	if (!(mEnemies.size() || mActiveSpawners.size())) //If both are empty
	{
		if (mInactiveSpawners.size() > 0)
		{
			do
			{
				mActiveSpawners.push_back(move(mInactiveSpawners.front()));
				mInactiveSpawners.pop_front();
			} while (mInactiveSpawners.size() > 0 && !mInactiveSpawners.front()->mPause);
		}
	}

	//Move all enemies
	auto enemy = mEnemies.begin();

	while (enemy != mEnemies.end())
	{
		(*enemy)->Update(delta);
		(*enemy)->CheckCollision();

		//Iterate by either erasing or incrementing
		if ((*enemy)->IsDead())
		{
			CreateRandomDrop((*enemy)->GetCenterPoint());
			++mNumOfKills;
			mLevelScore += (*enemy)->GetValue();
			enemy = mEnemies.erase(enemy);
		}
		else if ((*enemy)->IsFinished())
		{
			enemy = mEnemies.erase(enemy);
		}
		else
		{
			++enemy;
		}
	}

	//Spawn enemies
	auto spawner = mActiveSpawners.begin();

	while (spawner != mActiveSpawners.end())
	{
		(*spawner)->mTimer += delta;

		//If it can spawn an enemy then do so
		while ((*spawner)->mTimer > (*spawner)->mSpawnRate && (*spawner)->mEnemyAmount > 0)
		{
			(*spawner)->mTimer -= (*spawner)->mSpawnRate;
			(*spawner)->mEnemyAmount--;

			//Create the enemy
			unique_ptr<CEnemy> enemy = move(CreateEnemy((*spawner)->mType, (*spawner)->mpPath, (*spawner)->mOffset));

			if (mNickMode)
			{
				enemy->ActivateTheCage();
			}

			//mTimer is currently the amount of time passed since the enemy should have spawned
			//So update enemy with mTimer for delta
			enemy->Update((*spawner)->mTimer);

			//Total up the enemy scores
			mMaxScore += enemy->GetValue();

			//Place the enemy on the list
			mEnemies.push_back(move(enemy));
		}

		//If spawner is depleted (no more enemies to spawn) then remove it from the list
		if ((*spawner)->mEnemyAmount == 0)
		{
			spawner = mActiveSpawners.erase(spawner);
		}
		else
		{
			spawner++;
		}
	}

	//Update drops
	auto drop = mDrops.begin();

	while (drop != mDrops.end())
	{
		(*drop)->Update(delta);

		for (auto player = mpPlayers->begin(); player != mpPlayers->end(); ++player)
		{
			if ((*player)->CollidesSphere(drop->get()))
			{
				(*drop)->ApplyDrop(*player);
			}
		}

		if ((*drop)->IsOutOfBounds() || (*drop)->IsDead())
		{
			drop = mDrops.erase(drop);
		}
		else
		{
			drop++;
		}
	}
}