From 3d047f3a8b5c4c2f872709b4d0dc393d84bb1a93 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 24 Aug 2025 15:45:41 +0100 Subject: [PATCH] Tabs? Spaces?! WHO KNOWS! --- .gitignore | 2 ++ ball.gd | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cea0298..361b82f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # Godot 4+ specific ignores .godot/ /android/ + +# Directories .zed/ diff --git a/ball.gd b/ball.gd index 67c633f..82214d1 100644 --- a/ball.gd +++ b/ball.gd @@ -5,13 +5,15 @@ const SPEED : float = 300.0 func _ready() -> void: initialize() -func _physics_process(_delta: float) -> void: - move_and_slide() + func _physics_process(delta: float) -> void: + var collision = move_and_collide(velocity * _delta) + if collision: + velocity = velocity.bounce(collision.get_normal()) func initialize(): var extra_offset = 0.0 if randf() < 0.5 else PI var angle = extra_offset + randf_range(-PI/3.0, PI/3.0) - velocity = Vector2(cos(angle), sin(angle)).normalized() * SPEED + velocity = Vector2(cos(angle), sin(angle)).normalized() * SPEED position = get_viewport_rect().size / 2.0 func _on_screen_exited() -> void: