From c469ff91edca01c5b8a73b9a9b009ca35bda1ff6 Mon Sep 17 00:00:00 2001 From: cflip Date: Fri, 23 Sep 2022 09:53:59 -0600 Subject: Implement simple basketball physics --- Sprite.gd | 6 ++++++ basketball.tscn | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprite.gd b/Sprite.gd index c55df61..1e879c8 100644 --- a/Sprite.gd +++ b/Sprite.gd @@ -1,6 +1,9 @@ extends Sprite +export var gravity = 15 + var angular_speed = PI +var velocity = Vector2(500, -800) # Called when the node enters the scene tree for the first time. func _ready(): @@ -8,5 +11,8 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + position += velocity * delta rotation += angular_speed * delta + velocity.y += gravity + diff --git a/basketball.tscn b/basketball.tscn index 5c746ea..2c8edf4 100644 --- a/basketball.tscn +++ b/basketball.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://Sprite.gd" type="Script" id=2] [node name="Sprite" type="Sprite"] -position = Vector2( 520, 287 ) +position = Vector2( 114, 478 ) scale = Vector2( 5, 5 ) texture = ExtResource( 1 ) script = ExtResource( 2 ) -- cgit v1.2.3