ooppsy
This commit is contained in:
parent
cf586f6ea7
commit
1311e18f1f
3 changed files with 20 additions and 62 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="Script" path="res://objects/enemies/lashy/lashy.gd" id="1_34o54"]
|
||||
[ext_resource type="Texture2D" uid="uid://cm4cantqbhkwx" path="res://assets/textures/enemies/lashy/lashy_anchor.png" id="2_8ls3k"]
|
||||
[ext_resource type="Script" path="res://scripts/ball_snake.gd" id="3_8edxw"]
|
||||
[ext_resource type="Script" path="res://scripts/ball_snake/ball_snake.gd" id="3_8edxw"]
|
||||
[ext_resource type="Texture2D" uid="uid://gnkke4rr0wcr" path="res://assets/textures/enemies/lashy/lashy_body.png" id="4_xnkdk"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf0i64q2dw0au" path="res://assets/textures/enemies/lashy/lashy_head.png" id="5_b5g1y"]
|
||||
|
||||
|
@ -45,6 +45,7 @@ texture = ExtResource("4_xnkdk")
|
|||
target = NodePath("../HeadPivot/Head")
|
||||
segments = 2
|
||||
head_segment = false
|
||||
tail_segment = true
|
||||
auto_density = true
|
||||
pixels_per_segment = 5.0
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://bwtjfpfkykfdr"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/ball_snake.gd" id="1_7ck2q"]
|
||||
[ext_resource type="Script" path="res://scripts/ball_snake/ball_snake.gd" id="1_7ck2q"]
|
||||
[ext_resource type="Texture2D" uid="uid://cvgdwf28yr7fw" path="res://assets/textures/rotoboy/rotoboy.png" id="2_3s2uc"]
|
||||
[ext_resource type="Texture2D" uid="uid://ckfu1u3qxssrj" path="res://assets/textures/rotoboy/rotoboy_face.png" id="3_gp51k"]
|
||||
|
||||
|
@ -9,6 +9,21 @@
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8o2cr"]
|
||||
size = Vector2(48, 8)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bsslc"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RotatingPiece:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_eby5m"]
|
||||
resource_name = "spin"
|
||||
length = 5.0
|
||||
|
@ -26,21 +41,6 @@ tracks/0/keys = {
|
|||
"values": [0.0, 0.0, 12.5664]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bsslc"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RotatingPiece:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_l3464"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_bsslc"),
|
||||
|
@ -68,6 +68,7 @@ script = ExtResource("1_7ck2q")
|
|||
texture = ExtResource("2_3s2uc")
|
||||
target = NodePath("../RotatingPiece/SnakeEndLeft")
|
||||
segments = 2
|
||||
head_segment = true
|
||||
tail_segment = false
|
||||
auto_density = true
|
||||
pixels_per_segment = 6.0
|
||||
|
@ -77,6 +78,7 @@ script = ExtResource("1_7ck2q")
|
|||
texture = ExtResource("2_3s2uc")
|
||||
target = NodePath("../RotatingPiece/SnakeEndRight")
|
||||
segments = 2
|
||||
head_segment = true
|
||||
tail_segment = false
|
||||
auto_density = true
|
||||
pixels_per_segment = 6.0
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
@tool
|
||||
class_name BallSnake
|
||||
extends Node2D
|
||||
|
||||
|
||||
@export var texture: Texture2D
|
||||
@export var target: Node2D
|
||||
@export var segments: int = 1
|
||||
@export var head_segment: bool = true
|
||||
@export var tail_segment: bool = true
|
||||
@export var auto_density: bool = false:
|
||||
set(value):
|
||||
auto_density = value
|
||||
if auto_density:
|
||||
pixels_per_segment = pixels_per_segment
|
||||
@export_range(1,2,1,"or_greater") var pixels_per_segment: float = 1.0:
|
||||
set(value):
|
||||
pixels_per_segment = value
|
||||
if auto_density and target:
|
||||
segments = int(global_position.distance_to(target.global_position) / pixels_per_segment) - 1
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if auto_density:
|
||||
pixels_per_segment = pixels_per_segment
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if not target:
|
||||
return
|
||||
|
||||
if tail_segment:
|
||||
draw_texture(texture, -texture.get_size() * 0.5)
|
||||
|
||||
var end_pos = to_local(target.global_position)
|
||||
for i in segments:
|
||||
var weight = 1.0 / float(segments + 1) * float(i + 1)
|
||||
draw_texture(
|
||||
texture,
|
||||
lerp(Vector2.ZERO, end_pos, weight) - texture.get_size() * 0.5
|
||||
)
|
||||
|
||||
if head_segment:
|
||||
draw_texture(texture, end_pos - texture.get_size() * 0.5)
|
Loading…
Add table
Add a link
Reference in a new issue