Esempio n. 1
0
void cRokko::Set_Direction(const ObjectDirection dir, bool new_start_direction /* = true */)
{
    // already set
    if (m_start_direction == dir) {
        return;
    }

    // clear old images
    //Clear_Images();

    cEnemy::Set_Direction(dir, new_start_direction);

    if (m_direction == DIR_LEFT) {
        Set_Rotation(0.0f, 0.0f, 0.0f, 1);
    }
    else if (m_direction == DIR_RIGHT) {
        Set_Rotation(0.0f, 180.0f, 0.0f, 1);
    }
    else if (m_direction == DIR_UP) {
        Set_Rotation(0.0f, 0.0f, 90.0f, 1);
    }
    else if (m_direction == DIR_DOWN) {
        Set_Rotation(0.0f, 0.0f, 270.0f, 1);
    }
    else {
        printf("Warning: Unknown Rokko direction %s\n", Get_Direction_Name(dir).c_str());
    }

    Update_Rotation_Hor();
    Update_Distance_rect();
    //Set_Image_Num( 0, 1 );
}
Esempio n. 2
0
void cSpikeball :: Set_Direction( const ObjectDirection dir )
{
	// already set
	if( m_start_direction == dir )
	{
		return;
	}

	cEnemy::Set_Direction( dir, 1 );

	Update_Rotation_Hor( 1 );
	Create_Name();
}
Esempio n. 3
0
void cSpikeball :: Turn_Around( ObjectDirection col_dir /* = DIR_UNDEFINED */ )
{
	cEnemy::Turn_Around( col_dir );

	if( col_dir == DIR_LEFT || col_dir == DIR_RIGHT )
	{
		if( m_state == STA_WALK || m_state == STA_RUN )
		{
			m_velx *= 0.5f;
		}

		// set turn around image
		Set_Image_Num( 8 );
		Set_Animation( 0 );
		Reset_Animation();
	}
	// only update rotation if no turn around image
	else
	{
		Update_Rotation_Hor();
	}
}
Esempio n. 4
0
void cSpikeball :: Set_Moving_State( Moving_state new_state )
{
	if( new_state == m_state )
	{
		return;
	}

	if( new_state == STA_STAY )
	{
		m_counter_walk = 0.0f;
		Set_Animation( 0 );
	}
	else if( new_state == STA_WALK )
	{
		m_counter_running = 0.0f;
		m_counter_walk = Get_Random_Float( 0.0f, 80.0f );

		Set_Animation( 1 );
		Set_Animation_Image_Range( 0, 7 );
		Set_Time_All( 130, 1 );
		Reset_Animation();
	}
	else if( new_state == STA_RUN )
	{
		m_counter_stay = 0.0f;

		Set_Animation( 1 );
		Set_Animation_Image_Range( 0, 7 );
		Set_Time_All( 60, 1 );
		Reset_Animation();
	}

	m_state = new_state;

	Update_Velocity_Max();
	// if in the first part of the turn around animation
	Update_Rotation_Hor();
}
Esempio 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();
}
Esempio n. 6
0
void cSpikeball :: Load_From_Savegame( cSave_Level_Object *save_object )
{
	cEnemy::Load_From_Savegame( save_object );

	Update_Rotation_Hor();
}