Example #1
0
Collision CollisionManager::collideWithMapPieceAndMovableObjects( Entity *e )
{
    dFloat contacts[16] = {0.0f};
    dFloat normals[16] = {0.0f};
    dFloat penetration[16] = {0.0f};
    Collision col = Collision(false,normals,contacts,penetration);

    Vector3 pos = e->getParentSceneNode()->_getFullTransform().getTrans();

    Entity* ents[5];
    mp->getEntitiesForCollisionFromAPosition( &pos, ents );

    for( int i = 0; i < 5; i++ )
    {
        if( ents[i] != NULL)
        {
            col = cd->staicAndDynamicCollision( e, ents[i], false );
            if( col.isCollided ) return col;
        }
    }

    for(std::vector<Entity*>::const_iterator it=movableObj.begin();it!=movableObj.end(); ++it)
    {
        col = cd->staicAndDynamicCollision( e, *it, true);
        if( col.isCollided ) return col;
    }
    return col;
}
void CWeaponProjectile::Collision(CFeature* feature)
{
	if(gs->randFloat()>weaponDef->fireStarter)
		feature->StartFire();

	Collision();
}
//only to be used with map pieces where the second element is not transformed
Collision CollisionDetection::staicAndDynamicCollision(Entity *e1, Entity *e2, bool dynamic)
{
    dFloat e1Matrix[16];
    dFloat e2Matrix[16];

    NewtonCollision *e1Collision;
    NewtonCollision *e2Collision;

    std::map<Entity *,NewtonCollision *>::const_iterator iter =
    		collisionsMap.find(e1);
    if(iter != collisionsMap.end()) {
    	e1Collision=iter->second;
    } else {
        cout<<"in mapCollision(e1,e2) the collision mesh for enitiy e1 could not be found in (C++)map"<< endl;
        dFloat contacts[16] = {0.0f};
        dFloat normals[16] = {0.0f};
        dFloat penetration[16] = {0.0f};
    	return Collision(false,normals,contacts,penetration);
    }

    iter = collisionsMap.find(e2);
    if(iter != collisionsMap.end()) {
    	e2Collision=iter->second;
    } else {
        cout<<"in mapCollision(e1,e2) collision mesh for mapEnitiy e2 could not be found in (C++)map"<<endl;
        dFloat contacts[16] = {0.0f};
        dFloat normals[16] = {0.0f};
        dFloat penetration[16] = {0.0f};
    	return Collision(false,normals,contacts,penetration);;
    }
    getMatrix(e1,e1Matrix, true);       //allwarys transform
    getMatrix(e2,e2Matrix, dynamic);    //transfrom second entity only if not static

    dFloat contacts[16];
    dFloat normals[16];
    dFloat penetration[16];
    int numCollisionPoints = NewtonCollisionCollide (newtonWorld, 1,
                                e1Collision, &e1Matrix[0],
                                e2Collision, &e2Matrix[0],
                                &contacts[0], &normals[0], &penetration[0], 0);

    if (numCollisionPoints > 0) {
        return Collision(true,normals,contacts,penetration);
    } else {
        return Collision(false,normals,contacts,penetration);
    }
}
Example #4
0
void CParticles::Update(float TimePassed)
{
	static float FrictionFraction = 0;
	FrictionFraction += TimePassed;

	if(FrictionFraction > 2.0f) // safty messure
		FrictionFraction = 0;
	
	int FrictionCount = 0;
	while(FrictionFraction > 0.05f)
	{
		FrictionCount++;
		FrictionFraction -= 0.05f;
	}
	
	for(int g = 0; g < NUM_GROUPS; g++)
	{
		int i = m_aFirstPart[g];
		while(i != -1)
		{
			int Next = m_aParticles[i].m_NextPart;
			//m_aParticles[i].vel += flow_get(m_aParticles[i].pos)*time_passed * m_aParticles[i].flow_affected;
			m_aParticles[i].m_Vel.y += m_aParticles[i].m_Gravity*TimePassed;
			
			for(int f = 0; f < FrictionCount; f++) // apply friction
				m_aParticles[i].m_Vel *= m_aParticles[i].m_Friction;
			
			// move the point
			vec2 Vel = m_aParticles[i].m_Vel*TimePassed;
			Collision()->MovePoint(&m_aParticles[i].m_Pos, &Vel, 0.1f+0.9f*frandom(), NULL);
			m_aParticles[i].m_Vel = Vel* (1.0f/TimePassed);
			
			m_aParticles[i].m_Life += TimePassed;
			m_aParticles[i].m_Rot += TimePassed * m_aParticles[i].m_Rotspeed;

			// check particle death
			if(m_aParticles[i].m_Life > m_aParticles[i].m_LifeSpan)
			{
				// remove it from the group list
				if(m_aParticles[i].m_PrevPart != -1)
					m_aParticles[m_aParticles[i].m_PrevPart].m_NextPart = m_aParticles[i].m_NextPart;
				else
					m_aFirstPart[g] = m_aParticles[i].m_NextPart;
					
				if(m_aParticles[i].m_NextPart != -1)
					m_aParticles[m_aParticles[i].m_NextPart].m_PrevPart = m_aParticles[i].m_PrevPart;
					
				// insert to the free list
				if(m_FirstFree != -1)
					m_aParticles[m_FirstFree].m_PrevPart = i;
				m_aParticles[i].m_PrevPart = -1;
				m_aParticles[i].m_NextPart = m_FirstFree;
				m_FirstFree = i;
			}
			
			i = Next;
		}
	}
}
Example #5
0
void CControls::ClampMousePos()
{
	if(m_pClient->m_Snap.m_SpecInfo.m_Active && !m_pClient->m_Snap.m_SpecInfo.m_UsePosition)
	{
		m_MousePos[g_Config.m_ClDummy].x = clamp(m_MousePos[g_Config.m_ClDummy].x, 200.0f, Collision()->GetWidth()*32-200.0f);
		m_MousePos[g_Config.m_ClDummy].y = clamp(m_MousePos[g_Config.m_ClDummy].y, 200.0f, Collision()->GetHeight()*32-200.0f);
	}
	else
	{
		float CameraMaxDistance = 200.0f;
		float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f;
		float MouseMax = min(CameraMaxDistance/FollowFactor + g_Config.m_ClMouseDeadzone, (float)g_Config.m_ClMouseMaxDistance);

		if(length(m_MousePos[g_Config.m_ClDummy]) > MouseMax)
			m_MousePos[g_Config.m_ClDummy] = normalize(m_MousePos[g_Config.m_ClDummy])*MouseMax;
	}
}
void player::update(float time)
{
    rect.left +=dx*time;
    Collision(0);
    rect.top += dy*time;
    Collision(1);
    Regeneration(time);
    frame++;
    if(frame > 2) frame -= 2;
    if(dx>0) playerSp.setTextureRect(IntRect(32*(int)frame, 96, 32, 48));
    if(dx<0) playerSp.setTextureRect(IntRect(32*(int)frame, 48, 32, 48));
    if(dy<0) playerSp.setTextureRect(IntRect(32*(int)frame, 146, 32, 48));
    if(dy>0) playerSp.setTextureRect(IntRect(32*(int)frame, 2, 32, 48));
    playerSp.setPosition(rect.left, rect.top);
    dx = 0;
    dy = 0;
}
	void CollisionPack::load(Core::File& pFile)
	{
		const int collisionSize = pFile.readInt32();
		for(int i = 0; i < collisionSize; ++i)
		{
			add(Collision(pFile));
		}
	}
Example #8
0
bool ObjectsCollision(SDL_Rect *rect)
{
        for (int i = 0; i < object_number; i++)
                if (objects[i].solid && 
                                Collision(objects[i].sprite->rect, rect) != NONE)
                        return true;
        return false;
}
void CExplosiveProjectile::Update()
{	
	pos+=speed;
	speed.y+=gs->gravity;

	if(!--ttl)
		Collision();
}
Example #10
0
void FGame::Process()
{
	// 키보드 입력 처리
	if(game.m_Input.GetKeyState(VK_LEFT))
	{
		character.Move(0);
	}
	if(game.m_Input.GetKeyState(VK_RIGHT))
	{
		character.Move(2);
	}
	if(!character.m_use && game.m_Input.GetKeyState(VK_SPACE) == KEY_PRESS)
	{
		game.StartState(Game::STATE_GAME);
	}

	// 고구마 생성 처리
	static int iRapid = 0;
	if(game.GetFrameTime() < Game.FPS * 20)
	{
		iRapid = 6;
	}
	else if(game.GetFrameTime() < Game.FPS * 40)
	{
		iRapid = 10;
	}
	else if(game.GetFrameTime() < Game.FPS * 60)
	{
		iRapid = 14;
	}
	else if(game.GetFrameTime() < Game.FPS * 80)
	{
		iRapid = 20;
	}
	else if(game.GetFrameTime() < Game.FPS * 100)
	{
		iRapid = 30;
	}

	if(game.GetFrameTime() % (Game::FPS / iRapid) == 0)
	{
		MakeGogooma();
	}

	Collision();

	character.Process();

	int i;
	for(i = 0; i < GOGOOMA_COUNT; i++)
	{
		gogoomas[i].Process();
		if(gogoomas[i].m_frame == 1 && character.m_use)
		{
			iScore++;
		}
	}
}
Example #11
0
CollisionEvents& PhysicsEngine::getCollisionEvents() {
    const uint32_t CONTINUE_EVENT_FILTER_FREQUENCY = 10;
    _collisionEvents.clear();

    // scan known contacts and trigger events
    ContactMap::iterator contactItr = _contactMap.begin();

    while (contactItr != _contactMap.end()) {
        ContactInfo& contact = contactItr->second;
        ContactEventType type = contact.computeType(_numContactFrames);
        if(type != CONTACT_EVENT_TYPE_CONTINUE || _numSubsteps % CONTINUE_EVENT_FILTER_FREQUENCY == 0) {
            ObjectMotionState* motionStateA = static_cast<ObjectMotionState*>(contactItr->first._a);
            ObjectMotionState* motionStateB = static_cast<ObjectMotionState*>(contactItr->first._b);
            glm::vec3 velocityChange = (motionStateA ? motionStateA->getObjectLinearVelocityChange() : glm::vec3(0.0f)) +
                (motionStateB ? motionStateB->getObjectLinearVelocityChange() : glm::vec3(0.0f));

            if (motionStateA && motionStateA->getType() == MOTIONSTATE_TYPE_ENTITY) {
                QUuid idA = motionStateA->getObjectID();
                QUuid idB;
                if (motionStateB && motionStateB->getType() == MOTIONSTATE_TYPE_ENTITY) {
                    idB = motionStateB->getObjectID();
                }
                glm::vec3 position = bulletToGLM(contact.getPositionWorldOnB()) + _originOffset;
                glm::vec3 penetration = bulletToGLM(contact.distance * contact.normalWorldOnB);
                _collisionEvents.push_back(Collision(type, idA, idB, position, penetration, velocityChange));
            } else if (motionStateB && motionStateB->getType() == MOTIONSTATE_TYPE_ENTITY) {
                QUuid idB = motionStateB->getObjectID();
                glm::vec3 position = bulletToGLM(contact.getPositionWorldOnA()) + _originOffset;
                // NOTE: we're flipping the order of A and B (so that the first objectID is never NULL)
                // hence we must negate the penetration.
                glm::vec3 penetration = - bulletToGLM(contact.distance * contact.normalWorldOnB);
                _collisionEvents.push_back(Collision(type, idB, QUuid(), position, penetration, velocityChange));
            }
        }

        if (type == CONTACT_EVENT_TYPE_END) {
            ContactMap::iterator iterToDelete = contactItr;
            ++contactItr;
            _contactMap.erase(iterToDelete);
        } else {
            ++contactItr;
        }
    }
    return _collisionEvents;
}
Example #12
0
void Tank::Handle()
{
	Update();

	CheckFlags();
	if (m_iTimeFiring > BULLET_CREATION_TIME && m_bShoot)
	{
		m_oBulletHandle->New(
			m_fPosX + (30 * cos((m_glSurfaceTurret.rotation - 90) * (PI / 180.0f))),
			m_fPosY + (30 * sin((m_glSurfaceTurret.rotation - 90) * (PI / 180.0f))),
			m_glSurfaceTurret.rotation);

		m_iTimeFiring = 0;
	}
	m_oBulletHandle->Handle();

	Collision();

	if (m_iTimeTraveled > TREAD_CREATION_TIME)
	{
		//at some point we will meet a condition where we need
		//to spawn a treadmark
		//after we spawn a treadmark
		//that new object that is created
		//will be linked to the tank because it was created by it
		//but the object would "turn itself off" given a condition it would
		//meet internally
		//ie: tank is moving and gains a total distance of 100 units
		//the tank then spawns a treadmark
		//the tank keeps moving and will continue to spawn a treadmark every 100 units
		//the treadmark itself on creation would begin it's own internal "counter/timer/distancetraveled"
		//then undraw itself once it meets that condition
		//usage example:
		//tank.move();
		//if(tank.distance > 100)
		//for i 10 x
		//{	
			//tank.spawntreadmark(initial + offset);
		//}
		 //do other stuff
		//tank.spawntreadmark()
		//{ if(this->timer > 0)
		//draw(treadmarkTexture)
		//}
		m_oTreadMarks->New(
			m_fPosX + ((m_glSurfaceBase.w - 35) * cos((m_glSurfaceBase.rotation + 45) * (PI / 180.0f))),
			m_fPosY + ((m_glSurfaceBase.h - 33) * sin((m_glSurfaceBase.rotation + 45) * (PI / 180.0f))),
			m_glSurfaceBase.rotation);

		m_oTreadMarks->New(
			m_fPosX + ((m_glSurfaceBase.w - 35) * cos((m_glSurfaceBase.rotation - 225) * (PI / 180.0f))),
			m_fPosY + ((m_glSurfaceBase.h - 33) * sin((m_glSurfaceBase.rotation - 225) * (PI / 180.0f))),
			m_glSurfaceBase.rotation);

		m_iTimeTraveled = 0;
	}
}
Example #13
0
//-----------------------------------------------------------------
// Name: RotateTet()
// Desc: Rotates the tetrad by 90 degrees CCW or CW
//-----------------------------------------------------------------
void CTetris::RotateCurrTet( int angle )
{//Have to take the current position move it to the origan, rotate, then move it back
	int i=0, tempX = 0, tempY = 0,
		nOrgX = m_CurrentTet.iX, nOrgY = m_CurrentTet.iY;
	Tetrad temp(m_CurrentTet);

	//x'= xcos(angle) - ysin(angle);
	//y'= xsin(angle) + ycos(angle);
	if( m_nCurrentTetName == SALLY ) 
		return;
	//pre do the rotation then check bounds and if it works store in currentTet
	if( angle == CW )//
	{
		TranslateTet(temp,0,0);
		for(i=0; i<BLOCKS_PER_TET; i++)
		{
			tempX = 0*temp.tet[i].iX + -1*(temp.tet[i].iY);
			tempY = 1*temp.tet[i].iX + 0*(temp.tet[i].iY);
			temp.tet[i].iX = tempX;
			temp.tet[i].iY = tempY;
		}
		TranslateTet(temp,nOrgX,nOrgY);
		for(i=0; i<BLOCKS_PER_TET; i++)
			if( !Collision(temp.tet[i].iX, temp.tet[i].iY) ) 
				return;
		m_CurrentTet = temp;
	}
	else if( angle == CCW )
	{
		TranslateTet(temp,0,0);
		for(i=0; i<BLOCKS_PER_TET; i++)
		{
			tempX = 0*temp.tet[i].iX + 1*temp.tet[i].iY;
			tempY = (-1*temp.tet[i].iX + 0*temp.tet[i].iY);
			temp.tet[i].iX = tempX;
			temp.tet[i].iY = tempY;
		}
		TranslateTet(temp,nOrgX,nOrgY);
		for(i=0; i<BLOCKS_PER_TET; i++)
			if( !Collision(temp.tet[i].iX, temp.tet[i].iY) ) 
				return;
		m_CurrentTet = temp;
	}
}
Example #14
0
Collision State::hitBy(Collidable* other) {
	if(!collisionsEnabled || !enabled || this == other || !m_map) {
		return Collision();
	}

	// Test collisions with the map
	Collision c = m_map->hitBy(other);

	return c;
}
Example #15
0
void Enemy::Update()
{
	Movement();
	Collision();

	if (m_timer > m_duration)
		Destroy();

	m_timer += Time::DeltaTime();
}
Example #16
0
void CControls::ClampMousePos()
{
	if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID < 0)
	{
		m_MousePos[g_Config.m_ClDummy].x = clamp(m_MousePos[g_Config.m_ClDummy].x, 200.0f, Collision()->GetWidth()*32-200.0f);
		m_MousePos[g_Config.m_ClDummy].y = clamp(m_MousePos[g_Config.m_ClDummy].y, 200.0f, Collision()->GetHeight()*32-200.0f);
	}
	else
	{
		float CameraMaxDistance = 200.0f;
		float FollowFactor = (g_Config.m_ClDyncam ? g_Config.m_ClDyncamFollowFactor : g_Config.m_ClMouseFollowfactor) / 100.0f;
		float DeadZone = g_Config.m_ClDyncam ? g_Config.m_ClDyncamDeadzone : g_Config.m_ClMouseDeadzone;
		float MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
		float MouseMax = min(CameraMaxDistance/FollowFactor + DeadZone, MaxDistance);

		if(length(m_MousePos[g_Config.m_ClDummy]) > MouseMax)
			m_MousePos[g_Config.m_ClDummy] = normalize(m_MousePos[g_Config.m_ClDummy])*MouseMax;
	}
}
Example #17
0
void CGameMap::draw(CVisibileSqear & playerVisions)
{
	//glColor3f(0.0f,0.0f,0.0f);// Предает эффект сумерек

	for (size_t indexOfFloor = 0; m_floor.size() > indexOfFloor; ++indexOfFloor)
	{
		if (Collision(playerVisions, m_floor[indexOfFloor]))
		{
			m_floor[indexOfFloor].draw();
		}
	}

	for (size_t indexOfWall = 0; m_walls.size() > indexOfWall; ++indexOfWall)
	{
		if (Collision(playerVisions, m_walls[indexOfWall]))
		{
			m_walls[indexOfWall].draw();
		}
	}
}
Example #18
0
// TODO: this could be optimized with better algorithm?
bool CLevel::VisibilityCheck(const CCoord<float>& aSrc,const CCoord<float>& aDst,CCoord<float>* aCollisionPoint)
{
	int a;
    int iterations=int(max(1.0f,max(abs(aDst.X()-aSrc.X()),abs(aDst.Y()-aSrc.Y()))));
	int x_sign = sign(aDst.X()-aSrc.X());
	int y_sign = sign(aDst.Y()-aSrc.Y());
	float xDelta=((float)aDst.X()-aSrc.X())/iterations;
	float yDelta=((float)aDst.Y()-aSrc.Y())/iterations;
	CCoord<float> oldPos = aSrc;
	CCoord<float> newPos;
    
	for (a=0;a<=iterations;a++)
	{
		newPos = aSrc.Add(xDelta*a,yDelta*a);
		DEBUG_ASSERT((a==0) || (newPos != oldPos));

		if (Collision(newPos.Div(KBlockSpriteSize)))
		{
			if (aCollisionPoint)
				(*aCollisionPoint) = oldPos;
            return false;
		}

		if (x_sign!=0 && y_sign !=0 && a>0)
		{
			if (Collision(newPos.Add(-x_sign,0).Div(KBlockSpriteSize)) &&
				Collision(newPos.Add(0,-y_sign).Div(KBlockSpriteSize)))
				{
					if (aCollisionPoint)
						(*aCollisionPoint) = oldPos;
					return false;
				}
		}

		oldPos = newPos;
	}

	if (aCollisionPoint)
		(*aCollisionPoint) = aDst;
	return true;
}
bool ConjAliens::collidedWith(Object* other)
{
    if (Collision(position, size, other->position, other->size))
    {
        int col = (other->position.x - position.x) / SIZE_COLUMNA;
        int fil = (other->position.y - position.y) / SIZE_FILA;

        return aliens[col][fil].collidedWith(other);
    }

    return false;
}
Example #20
0
bool CControls::OnMouseMove(float x, float y)
{
	if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Paused)
		return false;
	m_MousePos += vec2(x, y); // TODO: ugly

	//
	float CameraMaxDistance = 200.0f;
	float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f;
	float DeadZone = g_Config.m_ClMouseDeadzone;
	float MouseMax = min(CameraMaxDistance/FollowFactor + DeadZone, (float)g_Config.m_ClMouseMaxDistance);
	
	//vec2 camera_offset(0, 0);

	if(m_pClient->m_Snap.m_Spectate)
	{
		if(m_MousePos.x < 200.0f) m_MousePos.x = 200.0f;
		if(m_MousePos.y < 200.0f) m_MousePos.y = 200.0f;
		if(m_MousePos.x > Collision()->GetWidth()*32-200.0f) m_MousePos.x = Collision()->GetWidth()*32-200.0f;
		if(m_MousePos.y > Collision()->GetHeight()*32-200.0f) m_MousePos.y = Collision()->GetHeight()*32-200.0f;
		
		m_TargetPos = m_MousePos;
	}
	else
	{
		float l = length(m_MousePos);
		
		if(l > MouseMax)
		{
			m_MousePos = normalize(m_MousePos)*MouseMax;
			l = MouseMax;
		}
		
		//float offset_amount = max(l-deadzone, 0.0f) * follow_factor;
		//if(l > 0.0001f) // make sure that this isn't 0
			//camera_offset = normalize(mouse_pos)*offset_amount;
	}
	
	return true;
}
Example #21
0
int Dodgeall (SDL_Surface *ecran)
{
    SDL_ShowCursor(0);
    //SDL_WarpMouse(480,320);
    int score=0;
    int aff=10, affichage=1;
    int p[2]={480,320};
    int y[50], xdeb[50], xfin[50];
    int sens=1; // 1 : bas, -1 : haut, 2 : gauche, -2 : droite
    int ecart=100, trou=200; // ecart +-1/4 et trou +-1/2


    sens=rand()%4;
    if(sens==0) sens=-2;
    else if (sens==3) sens=-1;

    int i=0;
    while(i<50)
    {
        y[i]=-1;
        xdeb[i]=-1;
        xfin[i]=-1;
        i++;
    }
    y[0]=0; xdeb[0]=50; xfin[0]= TAILLE_X-50; ///Au cas ou le decor ne démarre pas


    while(!Situation.exit && Collision(p[0], p[1], y, xdeb, xfin, sens))
    {
        if(affichage)SDL_Flip(ecran);
        if(affichage)Blit(ecran,0,0,TAILLE_X,TAILLE_Y,0,0,0);
        Changer_situation();
        Genere_mobile(ecran, sens, y, xdeb, xfin, ecart, trou, affichage);
        if(affichage)Bouge_souris(ecran, p);
        score++;
        if( aff>1 && score%500==0) aff--;
        if(aff<2)
        {
            if(score%((3-aff)*1000)==0) aff--;
            affichage=score%(4-aff);
            if(affichage) affichage=0;
            else affichage=1;
        }
        else affichage=score%aff;
        if(affichage)Affichage_score2(ecran,score,TAILLE_X-67,TAILLE_Y-15);
        //SDL_Delay(5);

    }

    SDL_ShowCursor(1);
    return score;
}
void CExplosiveProjectile::Update()
{	
	pos+=speed;
	speed.y+=gs->gravity;

	if(!--ttl)
		Collision();

	if(weaponDef->noExplode) {
		if(TraveledRange())
			CProjectile::Collision();
	}
}
Example #23
0
// Restore non collision tiles like water, ladder, etc
void MapContainer::RestoreCollisionTiles()
{
	
	for( int y = 0; y < Base.GetHeight(); y++ )
	{
		for( int x = 0; x < Base.GetWidth() ; x++ )
		{
			int Tile = Base(x,y);
			if( Tile < BLOCK_COLLIDE ) Collision(x,y) = Tile;
		}
	}
	
}
Example #24
0
// WARNING: recursive
void
SceneNode::CheckNodeCollision(
    SceneNode& node,
    std::set<Pair>& collisionPairs
) {
    // TODO: put this complex condition into function
    if ( this != &node && Collision( *this, node ) && !IsDestroyed() && !node.IsDestroyed() ) {
        collisionPairs.insert( std::minmax( this, &node ) );
    }
    for( Ptr& child : mChildren ) {
        child->CheckNodeCollision( node, collisionPairs );
    }
}
Example #25
0
bool Rocket::Step(){
	unsigned int tempCoorX=this->GetCoorX();
	unsigned int tempCoorY=this->GetCoorY();

	tempCoorX++;
	if (tempCoorX>WIDTHOFFIELD){
		this->Destroy();
		return false;
	}

	if (this->marvelValue==true) {
		bool temp=true;
		for (unsigned int i=tempCoorX-2;i<tempCoorX+2;i++){
			for (unsigned int q=tempCoorY-2;q<tempCoorY+2;q++){
				Unit* collisionUnit=Collision(i,q);
				if (collisionUnit!=nullptr) {
					collisionUnit->Destroy();
					temp=false;
				}
			}
		}
		if (temp==false){
			this->Destroy();
			return false;
		}
	}
	else {
		Unit* collisionUnit=Collision(tempCoorX,tempCoorY);

		if (collisionUnit!=nullptr) {
			collisionUnit->Destroy();
			this->Destroy();
			return false;
		}
	}
	this->SetCoordinate(tempCoorX,tempCoorY);
	return true;
}
Example #26
0
// 当たり判定を行う関数
void Screen::RectAndRectCollision(){
	for (int i = 0; i < BLOCK_NUM; ++i){
		// ブロックに衝突したらやり直し
		if (Collision(
			player->getPlayer(),
			stage->getBlock(i)).Judgment()){
			// プレイヤーの位置を最初に戻す
			player->PlayerReset();
			// ブロックの乱数初期化
			stage->BlockReset();
			break;
		}
	}
}
Example #27
0
void MUTI_SKILL_MANAGER::CrashMouse(MOUSE *mouse, hgeAnimation *anim, PUBLIC *pub, BALLbase *ball)
{
	for (int j = 0; j != arrows.size(); ++j)
	{
		if (mouse->god == false && arrows[j].alive && arrows[j].foe && Collision(pub->cskill1, arrows[j].angle, arrows[j].x, arrows[j].y, mouse->x, mouse->y))
		{
			arrows[j].alive = false;
			mouse->mouseHP -= damage(arrows[j].damage, mouse->base_m_def);
			mouse->god = true;
			mouse->godcount = 20;
		}
	}

}
Example #28
0
void
UpdateBallz (ball * ballz)
{

  ball *head = ballz;

  while (head)
    {
      UpdateBall (head);
      head = head->next;
    }

  Collision (ballz);

}
Example #29
0
bool Water::IsCollide(Object* obj)
{
	// TODO
	if (obj->type() == OBJ_CHARACTER)
	{		
	   Point pt = obj->GetPosition();
	   
	   return Collision(pos(), 20, pt);
	}
	else if (obj->type() == OBJ_BOX)
	{
		Point pt = obj->GetPosition();

		return Collision(pos(), 20, pt);
	}
	else if (obj->type() == OBJ_WATERBOMB)
	{
		Point pt = obj->GetPosition();

		return Collision(pos(), 20, pt);
	}

	return false;
}
Example #30
0
bool Alien::collidedWith(Object* other)
{
    if (!dead)
    {
        if (Collision(position, size, other->position, other->size))
        {
            dead = true;
            game->getPlayer()->donarPunts(position.y * 20);
            game->getConjAliens()->restarAlien();
            return true;
        }
    }

    return false;
}