Exemple #1
0
void cSpinBox :: Stop( void )
{
	// already stopped spinning
	if( !m_spin )
	{
		return;
	}

	// disabled image
	if( !m_useable_count )
	{
		Set_Image_Num( 0 );
	}
	// default image
	else
	{
		Set_Image_Num( 1 );
	}
	// reset
	m_spin = 0;
	Update_Valid_Update();
	m_spin_counter = 0.0f;

	// back to a massive box
	m_massive_type = MASS_MASSIVE;
	// disable animation
	Set_Animation( 0 );
	Reset_Animation();
}
Exemple #2
0
void cFlyon::Set_Moving_State(Moving_state new_state)
{
    if (new_state == m_state) {
        return;
    }

    if (new_state == STA_STAY) {
        m_velx = 0.0f;
        m_vely = 0.0f;

        m_move_back = 0;

        Set_Image_Num(0);
        Reset_Animation();
        Set_Animation(0);
    }
    else if (new_state == STA_FLY) {
        m_velx = m_dest_velx;
        m_vely = m_dest_vely;
        m_move_back = 0;
        Set_Animation(1);
    }

    m_state = new_state;
}
Exemple #3
0
void cFlyon::Set_Image_Dir(fs::path dir)
{
    if (dir.empty()) {
        return;
    }

    // if not image directory
    if (!File_Exists(pResource_Manager->Get_Game_Pixmaps_Directory() / dir / utf8_to_path("closed_1.settings")) && !File_Exists(pResource_Manager->Get_Game_Pixmaps_Directory() / dir / utf8_to_path("closed_1.png"))) {
        std::cerr   << "Warning: Flyon image files not found; does the flyon directory "
                    << path_to_utf8(dir) << " exist?" << std::endl;
        return;
    }

    m_img_dir = dir;

    // clear images
    Clear_Images();
    // set images
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("closed_1.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("closed_2.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("open_1.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("open_2.png")));
    // set start image
    Set_Image_Num(0, 1);

    Set_Animation(1);
    Set_Animation_Image_Range(0, 3);
    Set_Time_All(130, 1);
    Reset_Animation();
}
Exemple #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();
}
Exemple #5
0
 void cMoon::Init(void)
 {
     m_type = TYPE_MOON;
     m_can_be_on_ground = 0;
     
     Add_Image(pVideo->Get_Surface("game/items/moon_1.png"), 4800);
     Add_Image(pVideo->Get_Surface("game/items/moon_2.png"), 150);
     
     Set_Image_Num(0, 1);
     Set_Animation(1);
     Set_Animation_Image_Range(0, 1);
     Reset_Animation();
     
     m_name = "Moon (3-UP)";
 }
Exemple #6
0
void cBonusBox::Set_Useable_Count(int count, bool new_startcount /* = 0 */)
{
    cBaseBox::Set_Useable_Count(count, new_startcount);

    // disable
    if (!m_useable_count) {
        Reset_Animation();
        Set_Animation(0);
        Set_Image_Num(0);
    }
    // enable
    else {
        Set_Animation(1);
    }

    Update_Valid_Update();
}
Exemple #7
0
void cSpinBox :: Activate( void )
{
	// already spinning
	if( m_spin )
	{
		return;
	}

	m_spin = 1;
	Update_Valid_Update();
	// passive box for spinning
	m_massive_type = MASS_PASSIVE;

	m_spin_counter = 0.0f;
	// enable animation
	Set_Animation( 1 );
	Reset_Animation();
}
Exemple #8
0
void cEato::Set_Image_Dir(std::string dir)
{
    if (dir.empty())
    {
        return;
    }

    if (dir.find(DATA_DIR "/" GAME_PIXMAPS_DIR "/") == 0)
    {
        dir.erase(0, strlen(DATA_DIR "/" GAME_PIXMAPS_DIR "/"));
    }

    if (*(dir.end() - 1) != '/')
    {
        dir.insert(dir.length(), "/");
    }

    if (!File_Exists(DATA_DIR "/" GAME_PIXMAPS_DIR "/" + dir + "1.png") && !File_Exists(DATA_DIR "/" GAME_PIXMAPS_DIR "/" + dir + "1.settings"))
    {
        printf("Warning : Eato image dir does not exist %s\n", dir.c_str());
        return;
    }

    m_img_dir = dir;

    Clear_Images();

    Add_Image(pVideo->Get_Surface(m_img_dir + "1.png"));
    Add_Image(pVideo->Get_Surface(m_img_dir + "2.png"));
    Add_Image(pVideo->Get_Surface(m_img_dir + "3.png"));
    Add_Image(pVideo->Get_Surface(m_img_dir + "2.png"));

    Set_Image_Num(0, 1);

    Set_Animation(1);
    Set_Animation_Image_Range(0, 3);
    Set_Time_All(180, 1);
    Reset_Animation();

    Create_Name();
}
Exemple #9
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();
	}
}
Exemple #10
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();
}
Exemple #11
0
 void cBaseBox::Set_Animation_Type(const std::string& new_anim_type)
 {
     if (anim_type.compare(new_anim_type) == 0)
     {
         return;
     }
     
     Clear_Images();
     anim_type = new_anim_type;
     
     if (anim_type.compare("Bonus") == 0)
     {
         Add_Image(pVideo->Get_Surface("game/box/brown1_1.png"));
         
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/1.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/2.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/3.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/4.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/5.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/bonus/6.png"));
         
         Set_Animation(1);
         Set_Animation_Image_Range(1, 6);
         Set_Time_All(90, 1);
     }
     else if (anim_type.compare("Default") == 0)
     {
         Add_Image(pVideo->Get_Surface("game/box/brown1_1.png"));
         
         Add_Image(pVideo->Get_Surface("game/box/yellow/default.png"));
         
         Set_Animation(0);
         Set_Animation_Image_Range(1, 1);
     }
     else if (anim_type.compare("Power") == 0)
     {
         Add_Image(pVideo->Get_Surface("game/box/brown1_1.png"));
         
         Add_Image(pVideo->Get_Surface("game/box/yellow/power_1.png"));
         
         Set_Animation(0);
         Set_Animation_Image_Range(1, 1);
     }
     else if (anim_type.compare("Spin") == 0)
     {
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/disabled.png"));
         
         Add_Image(pVideo->Get_Surface("game/box/yellow/default.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/1.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/2.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/3.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/4.png"));
         Add_Image(pVideo->Get_Surface("game/box/yellow/spin/5.png"));
         
         Set_Animation(0);
         Set_Animation_Image_Range(1, 6);
         Set_Time_All(80, 1);
     }
     else
     {
         printf("Warning : Unknown Box Animation Type %s\n", anim_type.c_str());
         Set_Animation_Type("Bonus");
     }
     
     Reset_Animation();
     
     Set_Image_Num(m_anim_img_start, 1, 0);
 }