#pragma once #include #include #include #include static constexpr float MIN_RADIUS = 124.f; static constexpr float MAX_RADIUS = 164.f; static constexpr float FLY_SPEED = 42.f; static constexpr float WALK_SPEED = 10.f; enum class BirdState { IDLE, // 0 FLYING, // 1 WALKING, // 2 EATING, // 3 START_TO_FLY, // 4 STOP_FLYING, // 5 ATTACK // 6 }; class Bird { public: static std::vector birds; bool drawn; float altitude = 0.0f; float pos_x = 0; float pos_y = 0; Bird(float x, float y); static bool Init(SDL_Renderer*); void Update(double delta_s, const SDL_FPoint& player_pos); void Decide(const SDL_FPoint& player_pos); void pick_FlyTarget(const SDL_FPoint& player_pos); void pick_GroundTarget(const SDL_FPoint& player_pos); void Render(SDL_Renderer* renderer); void init_Landing(); void set_State(BirdState new_state, double decision_timer); void set_Position(SDL_FPoint); BirdState get_State() const; private: static std::atomic next_id; std::uint64_t id; void set_Animation(int row, int frames, double frame_time); static SDL_Texture* texture; SDL_FPoint velocity{0.f, 0.f}; SDL_FPoint target_pos{0.f, 0.f}; double state_timer = 0.0; double decision_timer = 0.0; bool is_landing = false; bool is_starting_to_fly = false; float landing_progress = 0.0f; float takeoff_progress = 0.0f; bool facing_left = true; float vertical_offset = 0.0f; float transition_timer = 0.0f; // Bird class private members float landing_start_y = 0.0f; // store Y when landing starts float landing_start_x = 0.0f; // Store X when landing starts float landing_direction = 1.0f; // Store flight direction for landing arc float landing_prev_x_offset = 0.0f; float landing_prev_y_offset = 0.0f; float takeoff_direction = 1.0f; // Store flight direction for takeoff arc float takeoff_prev_x_offset = 0.0f; float takeoff_prev_y_offset = 0.0f; bool reached_target = false; bool init_start_to_fly = false; static constexpr int tile_size = 16; BirdState state = BirdState::IDLE; SDL_FRect src_rect{}; int current_frame = 0; int frame_count = 1; bool reverse_animation = false; int frame_step = 1; double frame_duration_seconds = 200; double animation_timer = 0; };