Exemplo n.º 1
0
void cRokko::Update_Normal_Dying(void)
{
    if (m_vely < m_gravity_max) {
        Add_Velocity_Y_Max(1.5f, m_gravity_max);
    }

    if (m_dying_counter >= 5.0f && m_curr_img < 3)
        Set_Image_Num(3);
    else if (m_dying_counter >= 10.0f && m_curr_img == 3)
        Set_Image_Num(4);
    else if (m_dying_counter >= 15.0f && m_curr_img == 4)
        Set_Image_Num(5);

    Move(m_velx, m_vely);

    if (m_rot_z - m_start_rot_z < 90) {
        Add_Rotation_Z(pFramerate->m_speed_factor);
    }

    // generate smoke
    m_smoke_counter += pFramerate->m_speed_factor * 4;
    if (m_smoke_counter >= 2.0f) {
        Generate_Smoke(static_cast<int>(m_smoke_counter));
        Generate_Sparks(static_cast<int>(m_smoke_counter * 0.5f));
        m_smoke_counter -= static_cast<int>(m_smoke_counter);
    }

    // below ground
    if (m_col_rect.m_y - 200.0f > pActive_Camera->m_limit_rect.m_y + game_res_h) {
        m_rot_z = 0.0f;
        m_massive_type = MASS_PASSIVE;
        Set_Active(0);
        m_velx = 0.0f;
    }
}
Exemplo n.º 2
0
void cAnimated_Sprite :: Update_Animation( void )
{
	// if not valid
	if( !m_anim_enabled || m_anim_img_end == 0 )
	{
		return;
	}

	m_anim_counter += pFramerate->m_elapsed_ticks;

	// out of range
	if( m_curr_img < 0 || m_curr_img >= static_cast<int>(m_images.size()) )
	{
		Set_Image_Num( m_anim_img_start );
		return;
	}

	cAnimation_Surface image = m_images[m_curr_img];

	if( static_cast<Uint32>(m_anim_counter * m_anim_mod) >= image.m_time )
	{
		if( m_curr_img >= m_anim_img_end )
		{
			Set_Image_Num( m_anim_img_start );
		}
		else
		{
			Set_Image_Num( m_curr_img + 1 );
		}
		
		m_anim_counter = static_cast<Uint32>(m_anim_counter * m_anim_mod) - image.m_time;
	}
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
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.º 7
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)";
 }
Exemplo n.º 8
0
 void cFirePlant::Init(void)
 {
     m_type = TYPE_FIREPLANT;
     m_can_be_on_ground = 0;
     
     Add_Image(pVideo->Get_Surface("game/items/fireplant.png"));
     Add_Image(pVideo->Get_Surface("game/items/fireplant_left.png"));
     Add_Image(pVideo->Get_Surface("game/items/fireplant_right.png"));
     
     Set_Image_Num(0, 1, 0);
     
     m_name = "Fireplant";
     
     particle_counter = 0.0f;
 }
Exemplo n.º 9
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();
}
Exemplo n.º 10
0
void cMushroom :: Set_Type( SpriteType ntype )
{
	// already set
	if( m_type == ntype )
	{
		return;
	}

	Set_Color_Combine( 0, 0, 0, 0 );
	Clear_Images();

	if( ntype == TYPE_MUSHROOM_DEFAULT )
	{
		Add_Image( pVideo->Get_Surface( "game/items/mushroom_red.png" ) );
		m_name = _("Mushroom Red");
	}
	else if( ntype == TYPE_MUSHROOM_LIVE_1 )
	{
		Add_Image( pVideo->Get_Surface( "game/items/mushroom_green.png" ) );
		m_name = _("Mushroom 1-UP");
	}
	else if( ntype == TYPE_MUSHROOM_POISON )
	{
		Add_Image( pVideo->Get_Surface( "game/items/mushroom_poison.png" ) );
		m_name = _("Mushroom Poison");
	}
	else if( ntype == TYPE_MUSHROOM_BLUE )
	{
		Add_Image( pVideo->Get_Surface( "game/items/mushroom_blue.png" ) );
		m_name = _("Mushroom Blue");
	}
	else if( ntype == TYPE_MUSHROOM_GHOST )
	{
		Add_Image( pVideo->Get_Surface( "game/items/mushroom_ghost.png" ) );
		m_name = _("Mushroom Ghost");
	}
	else
	{
		printf( "Warning Unknown Mushroom type : %d\n", ntype );
		return;
	}
	
	m_type = ntype;
	
	Set_Image_Num( 0, 1, 0 );
}
Exemplo n.º 11
0
void cSpikeball :: Set_Color( const DefaultColor &col )
{
	// already set
	if( m_color_type == col )
	{
		return;
	}

	// clear old images
	Clear_Images();

	m_color_type = col;
	std::string filename_dir;

	if( m_color_type == COL_GREY )
	{
		filename_dir = "grey";

		m_kill_points = 400;
		m_fire_resistant = 1;
		m_ice_resistance = 1.0f;
		m_can_be_hit_from_shell = 0;
	}
	else
	{
		printf( "Error : Unknown Spikeball Color %d\n", m_color_type );
		return;
	}

	Update_Velocity_Max();

	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_1.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_2.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_3.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_4.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_5.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_6.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_7.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/walk_8.png" ) );
	Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/turn.png" ) );
	//Add_Image( pVideo->Get_Surface( "enemy/spikeball/" + filename_dir + "/dead.png" ) );

	Set_Image_Num( 0, 1 );
	Create_Name();
}
Exemplo n.º 12
0
 void cStaticEnemy::Set_Static_Image(const std::string& filename)
 {
     if (filename.empty())
     {
         return;
     }
     
     Clear_Images();
     
     m_img_filename = filename;
     
     if (m_img_filename.find(DATA_DIR "/" GAME_PIXMAPS_DIR "/") == 0)
     {
         m_img_filename.erase(0, strlen(DATA_DIR "/" GAME_PIXMAPS_DIR "/"));
     }
     
     Add_Image(pVideo->Get_Surface(filename));
     Set_Image_Num(0, 1);
     Create_Name();
 }
Exemplo n.º 13
0
void cRokko :: Set_Direction( const ObjectDirection dir )
{
	// already set
	if( m_start_direction == dir )
	{
		return;
	}

	// clear old images
	Clear_Images();

	cEnemy::Set_Direction( dir, 1 );
	m_name = "Rokko ";
	m_name += _(Get_Direction_Name(m_start_direction).c_str());

	Add_Image( pVideo->Get_Surface( "enemy/rokko/r.png" ) );

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

	Update_Distance_rect();
	Set_Image_Num( 0, 1 );
}
Exemplo n.º 14
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();
}
Exemplo n.º 15
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);
}
Exemplo n.º 16
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();
	}
}
Exemplo n.º 17
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 );
	}
}
Exemplo n.º 18
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);
 }
Exemplo n.º 19
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();
}