Ejemplo n.º 1
0
 void cMoon::Update(void)
 {
     if (!m_valid_update || !Is_Visible_On_Screen())
     {
         return;
     }
     
     Update_Animation();
     
     particle_counter += pFramerate->m_speed_factor;
     
     if (particle_counter > 15.0f)
     {
         cParticle_Emitter* anim = new cParticle_Emitter();
         anim->Set_Pos(m_pos_x + Get_Random_Float(28.0f, 40.0f), m_pos_y + Get_Random_Float(10.0f, 30.0f));
         anim->Set_Pos_Z(m_pos_z - 0.0001f);
         anim->Set_Image(pVideo->Get_Surface("animation/particles/light.png"));
         anim->Set_Speed(0.2f, 0.2f);
         anim->Set_Scale(0.2f);
         anim->Set_Time_to_Live(0.9f);
         anim->Set_Color(Color(static_cast<Uint8>(200), 200, 0));
         anim->Set_Blending(BLEND_ADD);
         
         pAnimation_Manager->Add(anim);
         
         particle_counter = 0.0f;
     }
 }
Ejemplo n.º 2
0
void cRokko::Update(void)
{
    cEnemy::Update();

    if (!m_valid_update || !Is_In_Range())
        return;

    // if not active
    if (m_state != STA_FLY) {
        // Do not self-activate when manual triggering is enabled
        if (m_manual)
            return;
        // Do not activate if Maryo is a ghost
        else if (pLevel_Player->m_maryo_type == MARYO_GHOST)
            return;
        // if player is in front then activate
        else if (pLevel_Player->m_col_rect.Intersects(Get_Final_Distance_Rect()))
            Activate();
        // Do not activate if Maryo is not near by
        else
            return;
    }

    Update_Animation();

    // 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);
    }
}
Ejemplo n.º 3
0
void cEato::Update(void)
{
    cEnemy::Update();

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

    Update_Animation();
}
Ejemplo n.º 4
0
 void cBaseBox::Update(void)
 {
     if (box_invisible == BOX_VISIBLE || (box_invisible == BOX_GHOST && pPlayer->maryo_type == MARYO_GHOST) || useable_count != start_useable_count)
     {
         if ((m_type == TYPE_SPINBOX || useable_count != 0) && m_anim_enabled)
         {
             GL_point col_pos_temp = m_col_pos;
             
             Update_Animation();
             
             m_col_pos = col_pos_temp;
         }
     }
     
     Update_Collision();
 }
Ejemplo n.º 5
0
void cSpikeball :: Update( void )
{
	cEnemy::Update();

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

	Update_Animation();

	if( m_state == STA_STAY )
	{
		m_counter_stay += pFramerate->m_speed_factor;

		// slow down
		if( !Is_Float_Equal( m_velx, 0.0f ) )
		{
			Add_Velocity_X( -m_velx * 0.25f );

			if( m_velx < 0.3f && m_velx > -0.3f )
			{
				m_velx = 0.0f;
			}
		}

		// set turn around image
		if( m_counter_stay > 40.0f && m_curr_img != 8 )
		{
			Set_Image_Num( 8 );

			// random direction
			if( ( rand() % 2 ) == 1 )
			{
				// turn around
				m_direction = Get_Opposite_Direction( m_direction );
				Update_Rotation_Hor();
			}
		}

		// finished stay animation
		if( m_counter_stay > 60.0f )
		{
			// run
			Set_Moving_State( STA_RUN );
			//pAudio->Play_Sound( "enemy/spikeball/run.wav" );
		}
	}
	else if( m_state == STA_WALK )
	{
		m_counter_walk += pFramerate->m_speed_factor;

		// finished walking
		if( m_counter_walk > 240.0f )
		{
			// stay
			Set_Moving_State( STA_STAY );
		}
	}
	else if( m_state == STA_RUN )
	{
		m_counter_running += pFramerate->m_speed_factor;

		// finished running
		if( m_counter_running > 120.0f )
		{
			// walk
			Set_Moving_State( STA_WALK );
		}

		// running particles
		m_running_particle_counter += pFramerate->m_speed_factor * 0.5f;

		// create particles
		if( m_running_particle_counter > 1.0f )
		{
			cParticle_Emitter *anim = new cParticle_Emitter( m_sprite_manager );
			anim->Set_Emitter_Rect( m_col_rect.m_x, m_col_rect.m_y + m_col_rect.m_h - 2.0f, m_col_rect.m_w );
			anim->Set_Quota( static_cast<int>(m_running_particle_counter) );
			anim->Set_Pos_Z( m_pos_z - 0.000001f );
			anim->Set_Image( pVideo->Get_Surface( "animation/particles/smoke_black.png" ) );
			anim->Set_Time_to_Live( 0.6f );
			anim->Set_Scale( 0.2f );

			float vel;

			if( m_velx > 0.0f )
			{
				vel = m_velx;
			}
			else
			{
				vel = -m_velx;
			}

			anim->Set_Speed( vel * 0.08f, 0.1f + vel * 0.1f );

			if( m_direction == DIR_RIGHT )
			{
				anim->Set_Direction_Range( 180.0f, 90.0f );
			}
			else
			{
				anim->Set_Direction_Range( 270.0f, 90.0f );
			}

			anim->Emit();
			pActive_Animation_Manager->Add( anim );

			m_running_particle_counter -= static_cast<int>(m_running_particle_counter);
		}
	}

	if( m_state != STA_STAY )
	{
		// if turn around image
		if( m_curr_img == 8 )
		{
			m_anim_counter += pFramerate->m_elapsed_ticks;

			// back to normal animation
			if( m_anim_counter >= 200 )
			{
				Reset_Animation();
				Set_Image_Num( m_anim_img_start );
				Set_Animation( 1 );
				Update_Rotation_Hor();
			}
			// rotate the turn image
			else if( m_anim_counter >= 100 )
			{
				Update_Rotation_Hor();
			}
		}
		else
		{
			Update_Velocity();
		}
	}

	Update_Gravity();
}
Ejemplo n.º 6
0
void cFlyon::Update(void)
{
    cEnemy::Update();

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

    Update_Animation();

    // standing ( waiting )
    if (m_state == STA_STAY) {
        // if waiting time
        if (m_wait_time > 0.0f) {
            m_wait_time -= pFramerate->m_speed_factor;

            if (m_wait_time < 0.0f) {
                m_wait_time = 0.0f;
            }
        }
        // no more waiting try to jump out
        else {
            GL_rect rect1 = m_col_rect;

            if (m_direction == DIR_UP) {
                rect1.m_y -= 40.0f;
                rect1.m_h += 40.0f;
            }
            else if (m_direction == DIR_DOWN) {
                rect1.m_y += 40.0f;
                rect1.m_h -= 40.0f;
            }
            else if (m_direction == DIR_LEFT) {
                rect1.m_x -= 35.0f;
                rect1.m_w += 35.0f;
            }
            else if (m_direction == DIR_RIGHT) {
                rect1.m_x += 35.0f;
                rect1.m_w += 35.0f;
            }

            // if player is in front: wait again
            if (pLevel_Player->m_maryo_type != MARYO_GHOST && pLevel_Player->m_col_rect.Intersects(rect1)) {
                m_wait_time = speedfactor_fps * 2;
            }
            // if not: jump out
            else {
                Set_Moving_State(STA_FLY);
            }
        }
    }
    // flying ( moving into the destination direction )
    else {
        // distance to final position
        float dist_to_final_pos = Get_End_Distance();
        // multiplier for the minimal velocity
        float vel_mod_min = (dist_to_final_pos + (m_max_distance * 0.1f)) / m_max_distance;

        // if behind max distance
        if (vel_mod_min <= 0.1f) {
            vel_mod_min = 0.1f;
        }

        /* slow down
         * with the velocity mod which is calculated from the distance to the final position
        */
        switch (m_direction) {
        case DIR_LEFT: {
            // move forward
            if (!m_move_back) {
                m_velx = m_dest_velx * vel_mod_min;
            }
            // move back
            else {
                m_velx = -m_dest_velx * vel_mod_min;
            }
            break;
        }
        case DIR_RIGHT: {
            // move forward
            if (!m_move_back) {
                m_velx = m_dest_velx * vel_mod_min;
            }
            // move back
            else {
                m_velx = -m_dest_velx * vel_mod_min;
            }
            break;
        }
        case DIR_UP: {
            // move forward
            if (!m_move_back) {
                m_vely = m_dest_vely * vel_mod_min;
            }
            // move back
            else {
                m_vely = -m_dest_vely * vel_mod_min;
            }
            break;
        }
        case DIR_DOWN: {
            // move forward
            if (!m_move_back) {
                m_vely = m_dest_vely * vel_mod_min;
            }
            // move back
            else {
                m_vely = -m_dest_vely * vel_mod_min;
            }
            break;
        }
        default: {
            break;
        }
        }

        // moving forward
        if (!m_move_back) {
            // reached final position move back
            if (dist_to_final_pos < 0.0f) {
                m_velx = -m_dest_velx * 0.01f;
                m_vely = -m_dest_vely * 0.01f;

                m_move_back = 1;
            }
        }
        // moving back
        else {
            // reached original position
            if (dist_to_final_pos > m_max_distance) {
                Set_Pos(m_start_pos_x, m_start_pos_y);
                m_wait_time = speedfactor_fps * 2;

                Set_Moving_State(STA_STAY);
            }
        }
    }
}