游戏开发中的打砖块反弹(godot)
当碰到挡板
area.direction = Vector2(_ball_dir, randf() * 2 - 1).normalized()
当碰到天花板或者地板
area.direction = (area.direction + Vector2(0, _bounce_direction)).normalized()
完整源码:
Pong with GDScript - Godot Asset Library (godotengine.org)