Exemplo n.º 1
0
void cMovingSprite :: Auto_Slow_Down( float x_speed, float y_speed /* = 0 */ )
{
	// horizontal slow down
	if( x_speed > 0.0f )
	{
		if( m_velx > 0.0f )
		{
			Add_Velocity( -x_speed, 0.0f );

			if( m_velx < 0.0f )
			{
				m_velx = 0.0f;
			}
		}
		else if( m_velx < 0.0f )
		{
			Add_Velocity( x_speed, 0.0f );

			if( m_velx > 0.0f )
			{
				m_velx = 0.0f;
			}
		}
	}

	// vertical slow down
	if( y_speed > 0.0f )
	{
		if( m_vely > 0.0f )
		{
			Add_Velocity( 0.0f, -y_speed );

			if( m_vely < 0.0f )
			{
				m_vely = 0.0f;
			}
		}
		else if( m_vely < 0.0f )
		{
			Add_Velocity( 0.0f, y_speed );

			if( m_vely > 0.0f )
			{
				m_vely = 0.0f;
			}
		}
	}
}
Exemplo n.º 2
0
void cRokko :: Update_Dying( void )
{
	// add gravity
	if( m_vely < 25 )
	{
		Add_Velocity( 0, 1.5f );
	}

	Move( m_velx, m_vely );

	if( m_rot_z - m_start_rot_z < 90 )
	{
		Add_Rotation_Z( pFramerate->m_speed_factor );
	}

	// generate smoke
	m_smoke_counter += pFramerate->m_speed_factor * 4;
	if( m_smoke_counter >= 2 )
	{
		Generate_Smoke( static_cast<int>(m_smoke_counter) );
		Generate_Sparks( static_cast<int>(m_smoke_counter * 0.5f) );
		m_smoke_counter -= static_cast<int>(m_smoke_counter);
	}

	// below ground
	if( m_col_rect.m_y - 200.0f > pActive_Camera->limit_rect.m_y + game_res_h )
	{
		m_rot_z = 0.0f;
		m_massive_type = MASS_PASSIVE;
		Set_Active( 0 );
		m_velx = 0.0f;
	}
}
Exemplo n.º 3
0
 void cEnemy::Update_Gravity(void)
 {
     if (!m_ground_object)
     {
         if (m_vely < 25)
         {
             Add_Velocity(0, 1.5f);
         }
         if (m_col_rect.m_y > pActive_Camera->limit_rect.m_y + game_res_h)
         {
             DownGrade(1);
         }
     }
     else
     {
         if (m_vely > 0)
         {
             m_vely = 0;
         }
     }
 }
Exemplo n.º 4
0
 void cMushroom::Update(void)
 {
     if (!m_valid_update || !Is_In_Player_Range())
     {
         return;
     }
     
     if (!m_ground_object)
     {
         if (m_vely < 25.0f)
         {
             Add_Velocity(0.0f, 1.5f);
         }
     }
     else
     {
         m_vely = 0.0f;
     }
     
     if (m_type == TYPE_MUSHROOM_LIVE_1 || m_type == TYPE_MUSHROOM_BLUE)
     {
         counter += pFramerate->m_speed_factor * 0.8f;
         
         while (counter > 1.0f)
         {
             cParticle_Emitter* anim = new cParticle_Emitter();
             anim->Set_Pos(m_col_rect.m_x + Get_Random_Float(0, m_col_rect.m_w), m_col_rect.m_y + Get_Random_Float(0, m_col_rect.m_h));
             anim->Set_Pos_Z(m_pos_z - 0.000001f);
             anim->Set_Direction_Range(180, 180);
             anim->Set_Scale(0.4f, 0.1f);
             
             if (m_type == TYPE_MUSHROOM_LIVE_1)
             {
                 anim->Set_Time_to_Live(0.4f);
                 anim->Set_Color(Color(static_cast<Uint8>(rand() % 30), 100 + (rand() % 150), rand() % 30));
                 anim->Set_Speed(0.5f, 0.5f);
                 anim->Set_Blending(BLEND_ADD);
             }
             else if (m_type == TYPE_MUSHROOM_BLUE)
             {
                 anim->Set_Time_to_Live(0.6f);
                 anim->Set_Color(Color(static_cast<Uint8>(180 + (rand() % 50)), 180 + (rand() % 50), 255, 128));
                 anim->Set_Speed(0.2f, 0.1f);
             }
             
             anim->Set_Image(pVideo->Get_Surface("animation/particles/light.png"));
             
             pAnimation_Manager->Add(anim);
             
             counter--;
         }
         
         if (m_type == TYPE_MUSHROOM_BLUE)
         {
             float new_glim = m_combine_color[2];
             
             if (glim_mod)
             {
                 new_glim += pFramerate->m_speed_factor * 0.02f;
                 
                 if (new_glim > 0.5f)
                 {
                     new_glim = 1.0f;
                     glim_mod = 0;
                 }
             }
             else
             {
                 new_glim -= pFramerate->m_speed_factor * 0.02f;
                 
                 if (new_glim < 0.0f)
                 {
                     new_glim = 0.0f;
                     glim_mod = 1;
                 }
             }
             
             Set_Color_Combine(new_glim * 0.1f, new_glim * 0.1f, new_glim, GL_ADD);
         }
     }
     else if (m_type == TYPE_MUSHROOM_POISON)
     {
         if (m_ground_object)
         {
             counter += pFramerate->m_speed_factor * 0.7f;
             
             while (counter > 1.0f)
             {
                 cParticle_Emitter* anim = new cParticle_Emitter();
                 anim->Set_Emitter_Rect(m_col_rect.m_x + (m_col_rect.m_w * 0.3f), m_col_rect.m_y + (m_col_rect.m_h * 0.91f), Get_Random_Float(0, m_col_rect.m_w * 0.4f), 0);
                 anim->Set_Time_to_Live(1.4f, 0.4f);
                 anim->Set_Scale(0.7f, 0.2f);
                 anim->Set_Color(Color(static_cast<Uint8>(120 + rand() % 40), 190 + (rand() % 60), 0 + rand() % 10));
                 anim->Set_Blending(BLEND_ADD);
                 anim->Set_Speed(0.0f, 0.0f);
                 anim->Set_Image(pVideo->Get_Surface("animation/particles/slime_1.png"));
                 
                 pAnimation_Manager->Add(anim);
                 
                 counter--;
             }
         }
     }
 }