#ifndef PINGPONG_BALL_H
#define PINGPONG_BALL_H

#include <godot_cpp/classes/character_body2d.hpp>

namespace godot {

class PingPongBall : public CharacterBody2D {
    GDCLASS(PingPongBall, CharacterBody2D)

private:
    float speed = 300.0f;
    Vector2 direction = Vector2(1.0f, 0.0f);

protected:
    static void _bind_methods();

public:
    PingPongBall();
    ~PingPongBall();

    void _physics_process(double delta) override;
    void _ready() override;
    void _draw() override;

    // 重置球到屏幕中央，以随机角度发射
    void reset();

    // 属性 getter/setter
    void set_speed(float p_speed);
    float get_speed() const;

    // 信号: scored(int which) — 0=左边得分, 1=右边得分
};

}

#endif // PINGPONG_BALL_H
