ball snake node icon
This commit is contained in:
parent
23c7cb5902
commit
cf586f6ea7
3 changed files with 143 additions and 0 deletions
46
scripts/ball_snake/ball_snake.gd
Normal file
46
scripts/ball_snake/ball_snake.gd
Normal file
|
@ -0,0 +1,46 @@
|
|||
@tool
|
||||
@icon("ball_snake.svg")
|
||||
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)
|
60
scripts/ball_snake/ball_snake.svg
Normal file
60
scripts/ball_snake/ball_snake.svg
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
|
||||
sodipodi:docname="ball_snake.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:document-units="px"
|
||||
inkscape:zoom="4.2826886"
|
||||
inkscape:cx="21.948829"
|
||||
inkscape:cy="22.882822"
|
||||
inkscape:window-width="1362"
|
||||
inkscape:window-height="768"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<circle
|
||||
style="fill:#eea5f3;fill-opacity:1;stroke:#8da5f3;stroke-width:4;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path1"
|
||||
cx="16"
|
||||
cy="48"
|
||||
r="11" />
|
||||
<circle
|
||||
style="fill:#eea5f3;fill-opacity:1;stroke:#8da5f3;stroke-width:4;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="circle1"
|
||||
cx="32"
|
||||
cy="32"
|
||||
r="11" />
|
||||
<circle
|
||||
style="fill:#eea5f3;fill-opacity:1;stroke:#8da5f3;stroke-width:4;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="circle2"
|
||||
cx="48"
|
||||
cy="16"
|
||||
r="11" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
37
scripts/ball_snake/ball_snake.svg.import
Normal file
37
scripts/ball_snake/ball_snake.svg.import
Normal file
|
@ -0,0 +1,37 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cy5okmvoymixp"
|
||||
path="res://.godot/imported/ball_snake.svg-6567e5e61b47a0f257c46421c9a9fdb0.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scripts/ball_snake/ball_snake.svg"
|
||||
dest_files=["res://.godot/imported/ball_snake.svg-6567e5e61b47a0f257c46421c9a9fdb0.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
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
Loading…
Add table
Add a link
Reference in a new issue