示例#1
0
文件: spikeball.cpp 项目: sKabYY/SMC
void cSpikeball :: Handle_Collision_Enemy( cObjectCollision *collision )
{
	if( collision->m_direction == DIR_RIGHT || collision->m_direction == DIR_LEFT )
	{
		Turn_Around( collision->m_direction );
	}

	Send_Collision( collision );
}
示例#2
0
void cMovingSprite :: Check_on_Ground( void )
{
	// can't be on ground
	if( !m_can_be_on_ground )
	{
		return;
	}

	if( m_type != TYPE_PLAYER && m_sprite_array != ARRAY_ENEMY && m_sprite_array != ARRAY_ACTIVE )
	{
		return;
	}

	// if ground object
	if( m_ground_object )
	{
		GL_rect rect2( m_col_rect.m_x, m_col_rect.m_y + m_col_rect.m_h, m_col_rect.m_w, 1.0f );

		// if on ground object
		if( m_ground_object->m_col_rect.Intersects( rect2 ) && m_ground_object->m_can_be_ground )
		{
			return;
		}
	}

	// don't check if flying or linked
	if( m_state == STA_FLY || m_state == STA_OBJ_LINKED )
	{
		return;
	}

	// new onground check
	cObjectCollisionType *col_list = Collision_Check_Relative( 0.0f, m_col_rect.m_h, 0.0f, 1.0f, COLLIDE_ONLY_BLOCKING );

	Reset_On_Ground();

	// possible ground objects
	for( cObjectCollision_List::iterator itr = col_list->objects.begin(), itr_end = col_list->objects.end(); itr != itr_end; ++itr )
	{
		cObjectCollision *col = (*itr);

		// ground collision found
		if( col->direction == DIR_BOTTOM )
		{
			if( Set_On_Ground( col->obj ) )
			{
				// send collision ( needed for falling platform )
				Send_Collision( col );
				break;
			}
		}
	}

	delete col_list;
}
示例#3
0
文件: spikeball.cpp 项目: sKabYY/SMC
void cSpikeball :: Handle_Collision_Massive( cObjectCollision *collision )
{
	if( m_state == STA_OBJ_LINKED )
	{
		return;
	}

	Send_Collision( collision );

	// get colliding object
	cSprite *col_object = m_sprite_manager->Get_Pointer( collision->m_number );

	if( col_object->m_type == TYPE_BALL )
	{
		return;
	}

	if( collision->m_direction == DIR_TOP )
	{
		if( m_vely < 0.0f )
		{
			m_vely = 0.0f;
		}
	}
	else if( collision->m_direction == DIR_BOTTOM )
	{
		if( m_vely > 0.0f )
		{
			m_vely = 0.0f;
		}
	}
	else if( collision->m_direction == DIR_RIGHT || collision->m_direction == DIR_LEFT )
	{
		Turn_Around( collision->m_direction );
	}
}