ball serve and reset
parent
110c7b333e
commit
3c0ff4e31c
@ -1,4 +1,20 @@
|
||||
extends RigidBody2D
|
||||
|
||||
const SPEED = 444
|
||||
var direction: Vector2
|
||||
|
||||
func _ready() -> void:
|
||||
reset()
|
||||
|
||||
func reset() -> void:
|
||||
print("Reset ball")
|
||||
position = Vector2(578, 326)
|
||||
direction = Vector2.ZERO
|
||||
|
||||
func serve() -> void:
|
||||
print("Serve!")
|
||||
print("Serve")
|
||||
direction = Vector2(randf_range(-1, 1), randf_range(-1, 1)).normalized()
|
||||
print(direction)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
position += direction * SPEED * delta
|
||||
|
||||
Loading…
Reference in New Issue