当前位置: 首页>>代码示例>>C++>>正文


C++ World::CreateObject方法代码示例

本文整理汇总了C++中World::CreateObject方法的典型用法代码示例。如果您正苦于以下问题:C++ World::CreateObject方法的具体用法?C++ World::CreateObject怎么用?C++ World::CreateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World::CreateObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Tick

void WallProjectile::Tick(World & world){
	Uint8 life = 20;
	if(state_i == 1){
		EmitSound(world, world.resources.soundbank["!laserel.wav"], 64);
	}
	if(state_i < 7){
		res_index = state_i;
	}
	if(state_i >= 7){
		if(state_i > 12 + life){
			world.MarkDestroyObject(id);
			res_index = 12;
			return;
		}
		if(state_i >= 12 + life - 5){
			res_index = state_i - life;
		}else{
			res_index = 7;
		}
	}
	if(state_i >= 7){
		Object * object = 0;
		Platform * platform = 0;
		if(TestCollision(*this, world, &platform, &object)){
			Overlay * overlay = (Overlay *)world.CreateObject(ObjectTypes::OVERLAY);
			if(overlay){
				overlay->res_bank = 222;
				overlay->x = x;
				overlay->y = y;
				if(platform){
					if(rand() % 2 == 0){
						overlay->EmitSound(world, world.resources.soundbank["strike03.wav"], 96);
					}else{
						overlay->EmitSound(world, world.resources.soundbank["strike04.wav"], 96);
					}
				}
			}
			float xn = 0, yn = 0;
			if(platform){
				platform->GetNormal(x, y, &xn, &yn);
			}
			for(int i = 0; i < 8; i++){
				Shrapnel * shrapnel = (Shrapnel *)world.CreateObject(ObjectTypes::SHRAPNEL);
				if(shrapnel){
					shrapnel->x = x;
					shrapnel->y = y;
					shrapnel->xv = (rand() % 9) - 4;
					shrapnel->yv = (rand() % 9) - 8;
					shrapnel->xv = (xn * abs(shrapnel->xv)) + (rand() % 9) - 4;
					shrapnel->yv = (yn * abs(shrapnel->yv)) + (rand() % 9) - 8;
				}
			}
			world.MarkDestroyObject(id);
		}
	}
	state_i++;
}
开发者ID:zsilencer,项目名称:zSILENCER,代码行数:57,代码来源:wallprojectile.cpp

示例2: CheckTractVictim

bool Civilian::CheckTractVictim(World & world){
	if(!tractteamid){
		return false;
	}
	std::vector<Uint8> types;
	types.push_back(ObjectTypes::PLAYER);
	int x1, y1, x2, y2;
	GetAABB(world.resources, &x1, &y1, &x2, &y2);
	std::vector<Object *> objects = world.TestAABB(x1, y1, x2, y2, types);
	for(std::vector<Object *>::iterator it = objects.begin(); it != objects.end(); it++){
		Player * player = static_cast<Player *>(*it);
		if(player->teamid != tractteamid){
			draw = false;
			for(int i = 0; i < 6; i++){
				BodyPart * bodypart = (BodyPart *)world.CreateObject(ObjectTypes::BODYPART);
				if(bodypart){
					bodypart->suitcolor = suitcolor;
					bodypart->x = x;
					bodypart->y = y - 50;
					bodypart->type = i;
					if(i == 0){
						bodypart->xv = 0;
						bodypart->yv = -20;
					}
				}
			}
			state = DYINGEXPLODE;
			EmitSound(world, world.resources.soundbank["seekexp1.wav"], 128);
			Object tractprojectile(ObjectTypes::PLASMAPROJECTILE);
			tractprojectile.healthdamage = 80;
			tractprojectile.shielddamage = 80;
			tractprojectile.ownerid = id;
			player->HandleHit(world, 50, 50, tractprojectile);
			Sint8 xvs[] = {-14, 14, -10, 10, -10, 10};
			Sint8 yvs[] = {-25, -25, -10, -10, -5, -5};
			for(int i = 0; i < 6; i++){
				PlasmaProjectile * plasmaprojectile = (PlasmaProjectile *)world.CreateObject(ObjectTypes::PLASMAPROJECTILE);
				if(plasmaprojectile){
					plasmaprojectile->large = false;
					plasmaprojectile->x = x;
					plasmaprojectile->y = y - 40;
					plasmaprojectile->ownerid = id;
					plasmaprojectile->xv = xvs[i];
					plasmaprojectile->yv = yvs[i];
				}
			}
			return true;
		}
	}
	return false;
}
开发者ID:Phobia0ptik,项目名称:zSILENCER,代码行数:51,代码来源:civilian.cpp

示例3: HandleHit

void Civilian::HandleHit(World & world, Uint8 x, Uint8 y, Object & projectile){
	Hittable::HandleHit(*this, world, x, y, projectile);
	if(projectile.healthdamage == 0){
		return;
	}
	if(state == DYINGFORWARD || state == DYINGBACKWARD || state == DEAD || state == DYINGEXPLODE){
		return;
	}
	float xpcnt = -((x - 50) / 50.0) * (mirrored ? -1 : 1);
	if(x < 50){
		state = DYINGFORWARD;
	}else{
		state = DYINGBACKWARD;
	}
	if((xpcnt < 0 && xv < 0) || (xpcnt > 0 && xv > 0)){
		xv = abs(xv) * xpcnt;
	}else{
		xv = speed * xpcnt;
	}
	switch(projectile.type){
		case ObjectTypes::BLASTERPROJECTILE:
		case ObjectTypes::LASERPROJECTILE:{
			if(rand() % 2 == 0){
				EmitSound(world, world.resources.soundbank["strike03.wav"], 96);
			}else{
				EmitSound(world, world.resources.soundbank["strike04.wav"], 96);
			}
		}break;
		case ObjectTypes::ROCKETPROJECTILE:{
			state = DYINGEXPLODE;
			draw = false;
			for(int i = 0; i < 6; i++){
				BodyPart * bodypart = (BodyPart *)world.CreateObject(ObjectTypes::BODYPART);
				if(bodypart){
					bodypart->suitcolor = suitcolor;
					bodypart->x = Civilian::x;
					bodypart->y = Civilian::y - 50;
					bodypart->type = i;
					bodypart->xv += (abs(xv) * 2) * xpcnt;
					if(i == 0){
						bodypart->xv = 0;
						bodypart->yv = -20;
					}
				}
			}
		}break;
	}
	Object * owner = world.GetObjectFromId(projectile.ownerid);
	if(owner && owner->type == ObjectTypes::PLAYER){
		Player * player = static_cast<Player *>(owner);
		Peer * peer = player->GetPeer(world);
		if(peer){
			peer->stats.civilianskilled++;
		}
	}
	state_i = 0;
}
开发者ID:Phobia0ptik,项目名称:zSILENCER,代码行数:57,代码来源:civilian.cpp

示例4: Tick

void FlamerProjectile::Tick(World & world){
	for(int i = 0; i < plumecount; i++){
		if(!plumeids[i]){
			Plume * plume = (Plume *)world.CreateObject(ObjectTypes::PLUME);
			if(plume){
				plume->type = 4;
				plume->xv = (rand() % 17) - 8 + (xv * 8);
				plume->yv = (rand() % 17) - 8 + (yv * 8);
				plume->SetPosition(x + (xv * (i * 1)), y + (yv * (i * 1)));
				plumeids[i] = plume->id;
				plume->state_i = i;
				
			}
		}
	}
	Object * object = 0;
	Platform * platform = 0;
	if(TestCollision(*this, world, &platform, &object)){
		float xn = 0, yn = 0;
		if(platform){
			platform->GetNormal(x, y, &xn, &yn);
			for(int i = 0; i < plumecount; i++){
				Plume * plume = (Plume *)world.GetObjectFromId(plumeids[i]);
				if(plume){
					plume->xv /= 3;
					plume->yv /= 3;
					//world->MarkDestroyObject(plumeids[i]);
				}
			}
		}
		//world->MarkDestroyObject(id);
	}
	res_index = state_i;
	if(state_i >= 14){
		world.MarkDestroyObject(id);
	}
	state_i++;
}
开发者ID:Phobia0ptik,项目名称:zSILENCER,代码行数:38,代码来源:flamerprojectile.cpp

示例5: Tick

void RocketProjectile::Tick(World & world){
	if(yv < 0 && xv == 0){ // up
		res_index = 4;
	}
	if(yv < 0 && xv > 0){ // up right
		res_index = 3;
		mirrored = false;
	}
	if(yv == 0 && xv > 0){ // right
		res_index = 0;
		mirrored = false;
	}
	if(yv > 0 && xv > 0){ // down right
		res_index = 1;
		mirrored = false;
	}
	if(yv > 0 && xv == 0){ // down
		res_index = 2;
	}
	if(yv > 0 && xv < 0){ // down left
		res_index = 1;
		mirrored = true;
	}
	if(yv == 0 && xv < 0){ // left
		res_index = 0;
		mirrored = true;
	}
	if(yv < 0 && xv < 0){ // up left
		res_index = 3;
		mirrored = true;
	}
	if(state_i == 100){
		oldxv = xv;
		oldyv = yv;
		xv = ceil(float(xv) * 0.3);
		yv = ceil(float(yv) * 0.3);
		soundchannel = EmitSound(world, world.resources.soundbank["rocket4.wav"], 128);
		state_i = 11;
		res_bank = 87;
	}
	if(state_i == 0){
		oldxv = xv;
		oldyv = yv;
		xv = ceil(float(xv) * 0.2);
		yv = ceil(float(yv) * 0.2);
		soundchannel = EmitSound(world, world.resources.soundbank["rocket9.wav"], 128);
	}
	if(state_i == 3){
		res_bank = 87;
	}
	if(state_i == 11){
		if(xv > 0){
			xv++;
		}else{
			xv--;
		}
		if(yv > 0){
			yv++;
		}else{
			yv--;
		}
		if(abs(xv) > abs(oldxv)){
			xv = oldxv;
		}
		if(abs(yv) > abs(oldyv)){
			yv = oldyv;
		}
		Platform * platform = 0;
		Object * object = 0;
		Sint16 oldx = x;
		Sint16 oldy = y;
		if(TestCollision(*this, world, &platform, &object)){
			float xn = 0, yn = 0;
			if(platform){
				platform->GetNormal(x, y, &xn, &yn);
			}
			int numplumes = 6;
			float anglen = (rand() % 100) / float(100);
			for(int i = 0; i < numplumes; i++){
				Plume * plume = (Plume *)world.CreateObject(ObjectTypes::PLUME);
				if(plume){
					plume->type = 4;
					/*plume->xv = (rand() % 17) - 8;
					plume->yv = (rand() % 17) - 8;
					plume->xv = (xn * abs(plume->xv)) + (rand() % 33) - 16;
					plume->yv = (yn * abs(plume->yv)) + (rand() % 33) - 16;*/
					float angle = (i / float(numplumes)) * (2 * 3.14);
					angle += anglen;
					plume->xv = (sin(angle)) * 15;
					plume->yv = (cos(angle)) * 15;
					if(xn || yn){
						plume->xv = (xn * abs(plume->xv)) + (rand() % 17) - 8;
						plume->yv = (yn * abs(plume->yv)) + (rand() % 17) - 8;
					}
					plume->SetPosition(x, y);
					
					Plume * plume2 = (Plume *)world.CreateObject(ObjectTypes::PLUME);
					if(plume2){
						plume2->type = 4;
						plume2->xv = plume->xv + (rand() % 7) - 3;
//.........这里部分代码省略.........
开发者ID:zsilencer,项目名称:zSILENCER,代码行数:101,代码来源:rocketprojectile.cpp

示例6: Tick

void Detonator::Tick(World & world){
	// 182:0-3 det/camera
	if(state_i == 0){
		EmitSound(world, world.resources.soundbank["shield2.wav"], 96);
	}
	res_index = (state_i / 4) % 4;
	if(state_i == 4 * 4){
		state_i = 0;
	}
	if(state_i > 4 * 4){
		if(state_i >= (4 * 4) + 6){
			if(state_i == (4 * 4) + 6){
				// explode
				if(iscamera){
					draw = false;
					EmitSound(world, world.resources.soundbank["q_expl02.wav"], 64);
					for(int i = 0; i < 8; i++){
						Plume * plume = (Plume *)world.CreateObject(ObjectTypes::PLUME);
						if(plume){
							plume->type = 5;
							plume->SetPosition(x + (rand() % 33) - 16, y + (rand() % 33) - 16);
						}
					}
				}else{
					EmitSound(world, world.resources.soundbank["seekexp1.wav"], 128);
					Sint8 xvs[] = {-14, 14, -10, 10, -10, 10};
					Sint8 yvs[] = {-25, -25, 0, 0, 5, 5};
					Sint8 ys[] = {0, 0, 0, 0, 0, 0, 0, 0};
					for(int i = 0; i < 6; i++){
						PlasmaProjectile * plasmaprojectile = (PlasmaProjectile *)world.CreateObject(ObjectTypes::PLASMAPROJECTILE);
						if(plasmaprojectile){
							plasmaprojectile->large = false;
							plasmaprojectile->x = x;
							plasmaprojectile->y = y + ys[i];
							plasmaprojectile->ownerid = ownerid;
							plasmaprojectile->xv = xvs[i];
							plasmaprojectile->yv = yvs[i];
						}
					}
				}
			}
			if(state_i == (4 * 4) + 8){
				if(!iscamera){
					// explode
					Sint8 xvs[] = {-14, 0, 14, -5, 0, 5};
					Sint8 yvs[] = {-5, -10, -5, 5, 5, 5};
					Sint8 ys[] = {0, 0, 0, 0, 0, 0};
					for(int i = 0; i < 6; i++){
						PlasmaProjectile * plasmaprojectile = (PlasmaProjectile *)world.CreateObject(ObjectTypes::PLASMAPROJECTILE);
						if(plasmaprojectile){
							plasmaprojectile->large = true;
							plasmaprojectile->x = x;
							plasmaprojectile->y = y + ys[i];
							plasmaprojectile->ownerid = ownerid;
							plasmaprojectile->xv = xvs[i];
							plasmaprojectile->yv = yvs[i];
						}
					}
				}
			}
			draw = false;
			if(state_i >= (4 * 4) + 50){
				world.MarkDestroyObject(id);
			}
		}else{
			int velocity = (((4 * 4) - (state_i)) * 2) + 20;
			if(velocity < 0){
				velocity = 0;
			}
			y -= velocity;
		}
	}
	state_i++;
}
开发者ID:Phobia0ptik,项目名称:zSILENCER,代码行数:74,代码来源:detonator.cpp


注:本文中的World::CreateObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。