Exemplo n.º 1
0
void cBall :: Update( void )
{
	if( !m_valid_update )
	{
		return;
	}

	// right
	if( m_velx > 0.0f )
	{
		Set_Velocity(20,0);
		m_rot_z += pFramerate->m_speed_factor * 40;
	}
	// left
	else
	{
		Set_Velocity(-20,0);
		m_rot_z -= pFramerate->m_speed_factor * 40;
	}


	// if ball is out of Player Range
	if( !Is_In_Player_Range() )
	{
		Destroy();
	}

	// glim animation
	if( m_glim_mod )
	{
		m_glim_counter += pFramerate->m_speed_factor * 0.1f;
		//m_glim_counter += pFramerate->m_speed_factor * 0.0f;

		if( m_glim_counter > 1.0f )
		{
			m_glim_counter = 1.0f;
			//m_glim_counter = 0.0f;
			m_glim_mod = 0;
		}
	}
	else
	{
		m_glim_counter -= pFramerate->m_speed_factor * 0.1f;
		//m_glim_counter -= pFramerate->m_speed_factor * 0.0f;

		if( m_glim_counter < 0.0f )
		{
			m_glim_counter = 0.0f;
			m_glim_mod = 1;
		}
	}

	// generate fire particle animation
	m_fire_counter += pFramerate->m_speed_factor;
	while( m_fire_counter > 1 )
	{
		Generate_Particles();
		m_fire_counter -= 1;
	}
}
Exemplo n.º 2
0
void cStaticEnemy :: Update( void )
{
	cEnemy::Update();

	if( !m_valid_update || !Is_In_Player_Range() )
	{
		return;
	}

	if( m_rotation_speed )
	{
		// update rotation
		Add_Rotation_Z( m_rotation_speed * pFramerate->m_speed_factor );
	}

    if( m_path_state.m_path )
    {
		// move along path
        if( m_path_state.Path_Move( m_speed * pFramerate->m_speed_factor ) == 0 )
        {
			if( !m_path_state.m_path->m_rewind )
			{
				// if we can not move further along the path, reverse the direction
				m_path_state.Move_Toggle();
			}
        }

    	// get difference
		float diff_x = ( m_path_state.m_path->m_start_pos_x + m_path_state.pos_x ) - m_pos_x;
		float diff_y = ( m_path_state.m_path->m_start_pos_y + m_path_state.pos_y ) - m_pos_y;

		// move to position
        Set_Velocity( diff_x, diff_y );
    }
}
Exemplo n.º 3
0
 void cStaticEnemy::Update(void)
 {
     cEnemy::Update();
     
     if (!m_valid_update || !Is_In_Player_Range())
     {
         return;
     }
     
     if (m_rotation_speed)
     {
         Add_Rotation_Z(m_rotation_speed * pFramerate->m_speed_factor);
     }
     
     if (m_path_state.m_path)
     {
         if (m_path_state.Path_Move(m_speed * pFramerate->m_speed_factor) == 0)
         {
             if (!m_path_state.m_path->m_rewind)
             {
                 m_path_state.Move_Toggle();
             }
         }
         
         float diff_x = (m_path_state.m_path->m_start_pos_x + m_path_state.pos_x) - m_pos_x;
         float diff_y = (m_path_state.m_path->m_start_pos_y + m_path_state.pos_y) - m_pos_y;
         
         Set_Velocity(diff_x, diff_y);
     }
 }
Exemplo n.º 4
0
void cRokko :: Update( void )
{
	cEnemy::Update();

	if( !m_valid_update || !Is_In_Player_Range() )
	{
		return;
	}

	// if not active
	if( m_state != STA_FLY )
	{
		GL_rect final_distance = Get_Final_Distance_Rect();

		// if player is in front then activate
		if( pPlayer->maryo_type != MARYO_GHOST && pPlayer->m_col_rect.Intersects( final_distance ) )
		{
			Activate();
		}
		else
		{
			return;
		}
	}

	// generate smoke
	m_smoke_counter += pFramerate->m_speed_factor * 4.0f;
	if( m_smoke_counter >= 1.0f )
	{
		Generate_Smoke( static_cast<int>(m_smoke_counter) );
		m_smoke_counter -= static_cast<int>(m_smoke_counter);
	}
}
Exemplo n.º 5
0
void cText_Box :: Update( void )
{
	if( !m_valid_update || !Is_In_Player_Range() )
	{
		return;
	}

	cBaseBox::Update();
}
Exemplo n.º 6
0
void cEato::Update(void)
{
    cEnemy::Update();

    if (!m_valid_update || !Is_In_Player_Range())
    {
        return;
    }

    Update_Animation();
}
Exemplo n.º 7
0
void cMovingSprite :: Collide_Move( void )
{
	if( !m_valid_update || !Is_In_Player_Range() )
	{
		return;
	}

	// move and create collision data
	Col_Move( m_velx, m_vely );

	Move_With_Ground();
}
Exemplo n.º 8
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--;
             }
         }
     }
 }