added a basic ball that properly inverts velocity when colliding with a world boundary. my balls are getting stuck on each other tho
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d2r0ip6xy3a2"]
|
||||
|
||||
[ext_resource type="Script" path="res://balls/ball.gd" id="1_ija2k"]
|
||||
|
||||
[node name="Ball" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
floor_stop_on_slope = false
|
||||
script = ExtResource("1_ija2k")
|
||||
@@ -0,0 +1,17 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed: float = 5
|
||||
const _speed_mult: float = 200
|
||||
var _direction: Vector2 = Vector2(1.0, 0.5)
|
||||
|
||||
func _physics_process(delta):
|
||||
velocity.x = speed * _speed_mult * _direction.x
|
||||
velocity.y = speed * _speed_mult * _direction.y
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func invert_x():
|
||||
_direction.x *= -1
|
||||
|
||||
func invert_y():
|
||||
_direction.y *= -1
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d2r0ip6xy3a2"]
|
||||
|
||||
[ext_resource type="Script" path="res://balls/ball.gd" id="1_ija2k"]
|
||||
|
||||
[node name="Ball" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
floor_stop_on_slope = false
|
||||
script = ExtResource("1_ija2k")
|
||||
@@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://sl3jbnopo0yh"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d2r0ip6xy3a2" path="res://balls/ball.tscn" id="1_ffml1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxi0fqy5sajh5" path="res://balls/basic/basic.webp" id="2_4dnuc"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_isusp"]
|
||||
size = Vector2(50, 50)
|
||||
|
||||
[node name="Ball" instance=ExtResource("1_ffml1")]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("RectangleShape2D_isusp")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." index="1"]
|
||||
texture = ExtResource("2_4dnuc")
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cxi0fqy5sajh5"
|
||||
path="res://.godot/imported/basic.webp-a129d05a6653f0c702726e8f6c206488.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://balls/basic/basic.webp"
|
||||
dest_files=["res://.godot/imported/basic.webp-a129d05a6653f0c702726e8f6c206488.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Reference in New Issue
Block a user