Beispiel #1
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;
}
Beispiel #2
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();
}
Beispiel #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();
}
Beispiel #4
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();
}
Beispiel #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();
}
Beispiel #6
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)";
 }
Beispiel #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();
}
Beispiel #8
0
void cRokko::DownGrade(bool force /* = 0 */)
{
    Set_Animation(false); // We will update this ourselves in Update_Normal_Dying()
    Set_Dead(1);
    m_massive_type = MASS_PASSIVE;
    m_gravity_max = 26.0f;
    m_vely = 0;

    if (!force) {
        // animation
        cParticle_Emitter* anim = new cParticle_Emitter(m_sprite_manager);
        Generate_Hit_Animation(anim);

        anim->Set_Quota(8);
        anim->Set_Speed(4, 1);
        anim->Set_Scale(0.9f);
        anim->Emit();
        pActive_Animation_Manager->Add(anim);
    }
}
Beispiel #9
0
void cRokko::Init(void)
{
    m_type = TYPE_ROKKO;
    m_name = "Rokko";
    m_massive_type = MASS_PASSIVE;
    m_pos_z = 0.03f;
    m_gravity_max = 0;
    m_editor_pos_z = 0.09f;
    m_can_be_on_ground = 0;
    m_camera_range = 4000;
    Set_Rotation_Affects_Rect(1);
    Set_Active(0);

    m_fire_resistant = 1;
    m_ice_resistance = 1;
    m_can_be_hit_from_shell = 0;

    Set_Direction(DIR_LEFT);
    Set_Speed(8.5f);
    m_min_distance_front = 200;
    Set_Max_Distance_Front(1000);
    Set_Max_Distance_Sides(400);
    m_state = STA_STAY;
    m_manual = false;

    m_smoke_counter = 0;

    m_kill_sound = "enemy/rokko/hit.wav";
    m_kill_points = 250;

    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_1.png"));
    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_2.png"));
    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_3.png"));
    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_1.png"));
    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_2.png"));
    Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_3.png"));
    Set_Image_Num(0, true);
    Set_Animation(true);
    Set_Animation_Image_Range(0, 2);
    Set_Time_All(130, true);
}
Beispiel #10
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();
}
Beispiel #11
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();
	}
}
Beispiel #12
0
void cSpikeball :: DownGrade( bool force /* = 0 */ )
{
	Set_Dead( 1 );
	m_massive_type = MASS_PASSIVE;
	m_counter = 0.0f;
	m_velx = 0.0f;
	m_vely = 0.0f;
	// dead image
	Set_Image_Num( 9 );
	Set_Animation( 0 );

	// default stomp death
	if( !force )
	{
		Generate_Hit_Animation();
		Set_Scale_Directions( 1, 0, 1, 1 );
	}
	// falling death
	else
	{
		Set_Rotation_Z( 180 );
		Set_Scale_Directions( 1, 1, 1, 1 );
	}
}
Beispiel #13
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();
}
Beispiel #14
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);
 }
Beispiel #15
0
Truck::Truck(int upgrade, sf::Sprite* sprite, sf::Sprite* sprite2,sf::Sprite* sprite3,sf::Sprite* sprite4)
{
	sprite_truck.push_back(sprite);
	sprite_truck.push_back(sprite2);
	sprite_truck.push_back(sprite3);
	sprite_truck.push_back(sprite4);

	m_sprite = sprite_truck.at(0);

	if(upgrade == 1)
	{
	m_maxhp = 130 ;
	m_hp = m_maxhp;
	}
	if(upgrade == 3)
	{
	m_maxhp = 330;
	m_hp = m_maxhp;
	}
	if(upgrade == 2)
	{
	m_maxhp = 230;
	m_hp = m_maxhp;
	}

	m_truck_hp  = nullptr;


	m_position=sf::Vector2f(1280/2, 720/2);

	//Animation
	if(upgrade == 1)
	{
		Set_Animation(sprite_truck.at(0), 1);
	}
	if(upgrade == 2)
	{
		Set_Animation(sprite_truck.at(0), 2);
	}
	if(upgrade == 3)
	{
		Set_Animation(sprite_truck.at(0), 3);
	}


	//initialize
	if(upgrade == 1 || upgrade == 2)
	{
		for(int i=0; i<sprite_truck.size();i++)
		{
			sprite_truck.at(i)->setOrigin(136.0f/2.0f, 52.0f/2.0f);
			sprite_truck.at(i)->setPosition(m_position);
		}
	}
	else
	{
		for(int j=0; j<sprite_truck.size();j++)
		{
			sprite_truck.at(j)->setOrigin(142.0f/2.0f, 55.0f/2.0f);
			sprite_truck.at(j)->setPosition(m_position);
		}
	};

	for(int count=0;count<10;count++)
	{
		m_truck_hp->update(0.1f, 1);
	}
}