Esempio n. 1
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);
    }
}
Esempio n. 2
0
void cText_Box::Update(void)
{
    if (!m_valid_update || !Is_In_Range()) {
        return;
    }

    cBaseBox::Update();
}
Esempio n. 3
0
void cBonusBox :: Update( void )
{
	if( !m_valid_update || !Is_In_Range() )
	{
		return;
	}

	// update active items
	for( MovingSpriteList::iterator itr = m_active_items.begin(); itr != m_active_items.end(); )
	{
		cPowerUp *powerup = static_cast<cPowerUp *>(*itr);

		if( !powerup->m_active )
		{
			++itr;
			continue;
		}

		float diff = powerup->m_pos_y - (m_pos_y - powerup->m_col_rect.m_h - powerup->m_col_pos.m_y);

		// position over the box reached
		if( diff < 0.0f )
		{
			// clear animation counter
			powerup->m_counter = 0.0f;

			// set powerup default posz
			powerup->m_pos_z = 0.05f;

			// set the item on top
			powerup->Set_On_Top( this, 0 );
			// add the item to the level objects
			m_sprite_manager->Add( powerup );

			// remove from array
			itr = m_active_items.erase( itr );
			Update_Valid_Update();
		}
		// move upwards
		else
		{
			powerup->m_counter += pFramerate->m_speed_factor;
			powerup->Move( 0.0f, -1.0f - (diff * 0.1f) );

			++itr;
		}
	}

	cBaseBox::Update();
}
Esempio n. 4
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();
}
Esempio n. 5
0
void cSpinBox :: Update( void )
{
	if( !m_valid_update || !Is_In_Range() )
	{
		return;
	}

	cBaseBox::Update();

	if( m_spin )
	{
		m_spin_counter += pFramerate->m_speed_factor;

		// spinning animation finished
		if( m_curr_img == 1 )
		{
			// spinning time finished
			if( m_spin_counter > speedfactor_fps * 5 )
			{
				// reset spin counter
				m_spin_counter = 0.0f;
				// set to massive for collision check
				m_massive_type = MASS_MASSIVE;
				// collision data
				cObjectCollisionType *col_list = Collision_Check( &m_col_rect, COLLIDE_ONLY_BLOCKING );
				
				// check if spinning should continue
				bool spin_again = 0;

				// colliding with player or enemy
				if( col_list->Is_Included( TYPE_PLAYER ) || col_list->Is_Included( ARRAY_ENEMY ) )
				{
					spin_again = 1;
				}
				// colliding with an active object
				else if( col_list->Is_Included( ARRAY_ACTIVE ) )
				{
					cSprite *col_obj = col_list->Find_First( ARRAY_ACTIVE )->m_obj;
					
					// check for items
					if( col_obj->m_type == TYPE_MUSHROOM_LIVE_1 || col_obj->m_type == TYPE_MUSHROOM_DEFAULT || 
						col_obj->m_type == TYPE_MUSHROOM_POISON || col_obj->m_type == TYPE_MUSHROOM_BLUE || col_obj->m_type == TYPE_MUSHROOM_GHOST || 
						col_obj->m_type == TYPE_FIREPLANT || col_obj->m_type == TYPE_STAR || col_obj->m_type == TYPE_FALLING_GOLDPIECE )
					{
						// found blocking active object
						spin_again = 1;
					}
				}

				delete col_list;

				// continue spinning
				if( spin_again )
				{
					// spin some time again
					m_spin_counter = speedfactor_fps * 2;
					// passive for spinning
					m_massive_type = MASS_PASSIVE;
				}
				// finished spinning
				else
				{
					Stop();
				}
			}
		}
	}
}
Esempio 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);
            }
        }
    }
}