many small changes, and few big ones
This commit is contained in:
parent
e8985f4e79
commit
a3ca623258
32 changed files with 391 additions and 247 deletions
14
reusable/aged_box/aged_box.gd
Normal file
14
reusable/aged_box/aged_box.gd
Normal file
|
@ -0,0 +1,14 @@
|
|||
extends RigidBody2D
|
||||
|
||||
@export var demolition_minmax: float = 0.1
|
||||
|
||||
func _ready() -> void:
|
||||
var p: P = $P
|
||||
for i in range(len(p.polygon)):
|
||||
p.polygon[i].x = p.polygon[i].x * randf_range(1.0-demolition_minmax, 1.0+demolition_minmax)
|
||||
p.polygon[i].y = p.polygon[i].y * randf_range(1.0-demolition_minmax, 1.0+demolition_minmax)
|
||||
p.update_polygon()
|
||||
# make visible polygon a bit bigger than collision polygon
|
||||
for i in range(len(p.polygon_2d.polygon)):
|
||||
p.polygon_2d.polygon[i].x += sign(p.polygon[i].x) # make bigger by 1 pixel
|
||||
p.polygon_2d.polygon[i].y += sign(p.polygon[i].y)
|
11
reusable/aged_box/aged_box.tscn
Normal file
11
reusable/aged_box/aged_box.tscn
Normal file
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cylmgbhvpdexh"]
|
||||
|
||||
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="1_m3p7r"]
|
||||
[ext_resource type="Script" path="res://reusable/aged_box/aged_box.gd" id="1_ul3hr"]
|
||||
|
||||
[node name="AgedBox" type="RigidBody2D"]
|
||||
script = ExtResource("1_ul3hr")
|
||||
|
||||
[node name="P" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PackedVector2Array(-8, -8, -8, 8, 8, 8, 8, -8)
|
||||
script = ExtResource("1_m3p7r")
|
Reference in a new issue