mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
30 lines
577 B
C#
30 lines
577 B
C#
using Godot;
|
|
|
|
public partial class Ball : Area2D
|
|
{
|
|
private const int DefaultSpeed = 100;
|
|
|
|
public Vector2 direction = Vector2.Left;
|
|
|
|
private Vector2 _initialPos;
|
|
private double _speed = DefaultSpeed;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_initialPos = Position;
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
_speed += delta * 2;
|
|
Position += (float)(_speed * delta) * direction;
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
direction = Vector2.Left;
|
|
Position = _initialPos;
|
|
_speed = DefaultSpeed;
|
|
}
|
|
}
|