Exemplo 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;
     }
 }
Exemplo n.º 2
0
 void cWaypoint::Init(void)
 {
     m_sprite_array = ARRAY_PASSIVE;
     m_type = TYPE_OW_WAYPOINT;
     m_massive_type = MASS_PASSIVE;
     m_pos_z = 0.08f;
     m_player_range = 0;
     
     waypoint_type = WAYPOINT_NORMAL;
     m_name = "Waypoint";
     
     gcolor = Get_Random_Float(0, 100);
     glim = 1;
     
     access = 0;
     access_default = 0;
     
     direction_backward = DIR_UNDEFINED;
     direction_forward = DIR_UNDEFINED;
     
     Set_Image(pVideo->Get_Surface("world/waypoint/default_1.png"));
     
     arrow_blue_l = pVideo->Get_Surface("game/arrow/small/blue/left.png");
     arrow_blue_r = pVideo->Get_Surface("game/arrow/small/blue/right.png");
     arrow_blue_u = pVideo->Get_Surface("game/arrow/small/blue/up.png");
     arrow_blue_d = pVideo->Get_Surface("game/arrow/small/blue/down.png");
     
     arrow_white_l = pVideo->Get_Surface("game/arrow/small/white/left.png");
     arrow_white_r = pVideo->Get_Surface("game/arrow/small/white/right.png");
     arrow_white_u = pVideo->Get_Surface("game/arrow/small/white/up.png");
     arrow_white_d = pVideo->Get_Surface("game/arrow/small/white/down.png");
 }
Exemplo n.º 3
0
 void cBaseBox::Generate_Activation_Particles(void)
 {
     if (m_type == TYPE_SPINBOX || m_type == TYPE_TEXT_BOX || box_type == TYPE_GOLDPIECE)
     {
         return;
     }
     
     particle_counter_active += pFramerate->m_speed_factor;
     
     while (particle_counter_active > 0.0f)
     {
         cParticle_Emitter *anim = new cParticle_Emitter();
         anim->Set_Pos(m_pos_x + Get_Random_Float(0.0f, m_rect.m_w), m_pos_y);
         anim->Set_Pos_Z(m_pos_z - 0.000001f);
         anim->Set_Direction_Range(180, 180);
         anim->Set_Speed(3.1f, 0.5f);
         anim->Set_Scale(0.7f, 0.1f);
         
         Color color = white;
         
         if (box_type == TYPE_MUSHROOM_DEFAULT)
         {
             color = Color(static_cast<Uint8>(100 + (rand() % 100)), 20 + (rand() % 50), 10 + (rand() % 30));
         }
         else if (box_type == TYPE_FIREPLANT)
         {
             color = Color(static_cast<Uint8>(110 + (rand() % 150)), rand() % 50, rand() % 30);
         }
         else if (box_type == TYPE_MUSHROOM_BLUE)
         {
             color = Color(static_cast<Uint8>(rand() % 30), (rand() % 30), 150 + (rand() % 50));
         }
         else if (box_type == TYPE_MUSHROOM_GHOST)
         {
             color = Color(static_cast<Uint8>(100 + (rand() % 50)), 100 + (rand() % 50), 100 + (rand() % 50));
         }
         else if (box_type == TYPE_MUSHROOM_LIVE_1)
         {
             color = Color(static_cast<Uint8>(rand() % 30), 100 + (rand() % 150), rand() % 30);
         }
         else if (box_type == TYPE_JSTAR)
         {
             color = Color(static_cast<Uint8>(110 + (rand() % 150)), 80 + (rand() % 50), rand() % 20);
         }
         else if (box_type == TYPE_MUSHROOM_POISON)
         {
             color = Color(static_cast<Uint8>(50 + rand() % 50), 100 + (rand() % 150), rand() % 10);
         }
         
         anim->Set_Time_to_Live(0.3f);
         anim->Set_Color(color);
         anim->Set_Blending(BLEND_ADD);
         anim->Set_Image(pVideo->Get_Surface("animation/particles/light.png"));
         pAnimation_Manager->Add(anim);
         
         particle_counter_active--;
     }
 }
Exemplo n.º 4
0
void cFirePlant :: Update( void )
{
	if( !m_valid_update || !Is_Visible_On_Screen() )
	{
		return;
	}

	counter += pFramerate->m_speed_factor;

	if( counter > speedfactor_fps * 2.5f )
	{
		// if no direction image set
		if( m_curr_img == 0 )
		{
			Set_Image_Num( 1 + ( rand() % 2 ), 0, 0 );
		}
		// direction image is set
		else
		{
			Set_Image_Num( 0, 0, 0 );
		}

		counter = 0.0f;
	}

	// particle animation
	particle_counter += pFramerate->m_speed_factor * 0.8f;

	while( particle_counter > 1 )
	{
		cParticle_Emitter *anim = new cParticle_Emitter();
		anim->Set_Pos( m_col_rect.m_x + Get_Random_Float( 0.0f, m_col_rect.m_w ), m_col_rect.m_y + Get_Random_Float( 0.0f, m_col_rect.m_h * 0.5f ) );
		anim->Set_Pos_Z( m_pos_z + 0.000001f );
		anim->Set_Direction_Range( 180.0f, 180.0f );
		anim->Set_Scale( 0.4f, 0.1f );
		anim->Set_Time_to_Live( 0.4f );
		anim->Set_Color( Color( static_cast<Uint8>(255), 50 + ( rand() % 50 ), 0 ) );
		anim->Set_Speed( 0.2f, 0.1f );
		anim->Set_Blending( BLEND_ADD );
		
		anim->Set_Image( pVideo->Get_Surface( "animation/particles/light.png" ) );

		pAnimation_Manager->Add( anim );

		particle_counter--;
	}
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
0
void cFlyon::Init(void)
{
    m_type = TYPE_FLYON;
    m_name = "Flyon";
    m_pos_z = 0.06f;
    Set_Rotation_Affects_Rect(1);
    m_editor_pos_z = 0.089f;
    m_camera_range = 1000;
    m_can_be_on_ground = 0;
    m_can_be_ground = 0;

    m_state = STA_STAY;
    Set_Direction(DIR_UP);
    Set_Image_Dir(utf8_to_path("enemy/flyon/orange/"));
    Set_Max_Distance(200);
    Set_Speed(5.8f);

    m_kill_sound = "enemy/flyon/die.ogg";
    m_kill_points = 100;

    m_wait_time = Get_Random_Float(0.0f, 70.0f);
    m_move_back = 0;
}
Exemplo n.º 7
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--;
             }
         }
     }
 }
Exemplo n.º 8
0
void cRandom_Sound::Update(void)
{
    Update_Valid_Update();

    if (!m_valid_update) {
        return;
    }

    bool play = 0;

    if (m_continuous) {
        m_volume_update_counter -= pFramerate->m_elapsed_ticks;

        // get the sound
        cAudio_Sound* sound = pAudio->Get_Playing_Sound(m_filename);

        // if not playing
        if (!sound) {
            // play it
            play = 1;
        }
        // update volume
        else if (m_volume_update_counter <= 0.0f) {
            // volume based on maximum
            float sound_volume = m_volume_max * 0.01f;
            // apply distance modifier
            sound_volume *= Get_Distance_Volume_Mod();
            // set to mixer volume
            sound_volume *= static_cast<float>(MIX_MAX_VOLUME);
            // set volume
            pAudio->Set_Sound_Volume(static_cast<Uint8>(sound_volume), sound->m_channel);

            // update volume every 100 ms
            m_volume_update_counter = 100.0f;
        }
    }
    else {
        // subtract duration of this frame in milliseconds
        m_next_play_delay -= pFramerate->m_elapsed_ticks;

        // play it
        if (m_next_play_delay <= 0.0f) {
            play = 1;

            // set next delay
            m_next_play_delay = static_cast<float>(m_delay_min);

            if (m_delay_max > m_delay_min) {
                m_next_play_delay += Get_Random_Float(0.0f, static_cast<float>(m_delay_max - m_delay_min));
            }
        }
    }

    if (play) {
        float sound_volume = 0.0f;

        // always maximum volume
        if (m_continuous) {
            sound_volume = m_volume_max;
        }
        // set random volume
        else {
            // random
            if (m_volume_max > m_volume_min) {
                sound_volume = Get_Random_Float(m_volume_min, m_volume_max);
            }
            // static
            else {
                sound_volume = m_volume_max;
            }
        }

        sound_volume *= 0.01f;

        // adjust volume based on distance
        sound_volume *= Get_Distance_Volume_Mod();

        int loops = 0;

        if (m_continuous) {
            // unlimited
            loops = -1;
        }

        sound_volume *= static_cast<float>(MIX_MAX_VOLUME);

        // play sound
        pAudio->Play_Sound(m_filename, -1, static_cast<int>(sound_volume), loops);
    }
}