first work

This commit is contained in:
2024-03-07 22:17:10 +01:00
parent af7ecc10e3
commit f83f6989b4
10 changed files with 146 additions and 72 deletions
+21
View File
@@ -0,0 +1,21 @@
extends RigidBody2D
const SPEED = 300.00
func _ready():
randomize()
global_position = Vector2(640, 360)
var x_direction = pow(-1, randi() % 2)
var y_direction = pow(-1, randi() % 2)
await get_tree().create_timer(1.0).timeout
linear_velocity = Vector2(x_direction, y_direction) * SPEED
func _process(delta):
pass
+27
View File
@@ -0,0 +1,27 @@
[gd_scene load_steps=4 format=3 uid="uid://dmsd30hc2ob1w"]
[ext_resource type="Script" path="res://scenes/playground/ball/Ball.gd" id="1_vsr7q"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_h7mi1"]
friction = 0.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bdxrg"]
size = Vector2(32, 32)
[node name="Ball" type="RigidBody2D"]
mass = 0.01
physics_material_override = SubResource("PhysicsMaterial_h7mi1")
gravity_scale = 1.66533e-16
can_sleep = false
lock_rotation = true
freeze_mode = 1
linear_damp_mode = 1
script = ExtResource("1_vsr7q")
[node name="ColorRect" type="ColorRect" parent="."]
offset_right = 40.0
offset_bottom = 40.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(20, 20)
shape = SubResource("RectangleShape2D_bdxrg")