1
0
Fork 0
mirror of https://github.com/tonytins/dressupzack synced 2025-05-05 13:34:48 -04:00

Compare commits

...

2 commits

Author SHA1 Message Date
Tony Bark
3097f5063a Tweaked drag and drop script
- Applied new drag & drop architecture to main game scene
2023-12-09 22:26:27 -05:00
Tony Bark
9ff5c5aae3 Advanced drag and drop system finished 2023-12-09 20:43:42 -05:00
11 changed files with 131 additions and 133 deletions

View file

@ -45,6 +45,7 @@ enabled=PackedStringArray("res://addons/SpritesheetGenerator/plugin.cfg", "res:/
folder_colors={
"res://addons/": "blue",
"res://fonts/": "teal",
"res://resources/": "orange",
"res://scenes/": "purple",
"res://scripts/": "green",
@ -52,6 +53,10 @@ folder_colors={
"res://sprites/": "yellow"
}
[filesystem]
import/blender/enabled=false
[importer_defaults]
texture={
@ -89,7 +94,6 @@ ui_pause={
click={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}

Binary file not shown.

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=30 format=3 uid="uid://detf8uwimqp3v"]
[gd_scene load_steps=28 format=3 uid="uid://detf8uwimqp3v"]
[ext_resource type="Script" path="res://scripts/character.gd" id="1_k1mtq"]
[ext_resource type="Texture2D" uid="uid://cddou4chwo8h2" path="res://sprites/character/tail/tail0.svg" id="2"]
@ -6,9 +6,7 @@
[ext_resource type="Texture2D" uid="uid://cnd3v8cerplqq" path="res://sprites/character/tail/tail1.svg" id="3"]
[ext_resource type="Texture2D" uid="uid://djv0p7rxujbd4" path="res://sprites/character/tail/tail2.svg" id="4"]
[ext_resource type="Texture2D" uid="uid://dnwdyi2d46hsm" path="res://sprites/character/eyes/eyes1.png" id="6"]
[ext_resource type="Texture2D" uid="uid://cardxswmgbmbv" path="res://sprites/clothes/owo_censor.svg" id="6_w0l5s"]
[ext_resource type="Texture2D" uid="uid://cbr37emgh11is" path="res://sprites/character/eyes/eyes2.png" id="7"]
[ext_resource type="Script" path="res://scripts/clothing.gd" id="7_58p8d"]
[ext_resource type="Texture2D" uid="uid://ceifal0sxn0r7" path="res://sprites/character/eyes/eyes3.png" id="8"]
[ext_resource type="Texture2D" uid="uid://dujbine82hf7h" path="res://sprites/character/eyes/eyes4.png" id="9"]
[ext_resource type="Texture2D" uid="uid://cbptix4hhenyv" path="res://sprites/character/eyes/eyes5.png" id="10"]
@ -133,14 +131,6 @@ position = Vector2(12, 81)
texture = ExtResource("2_p4oam")
metadata/_edit_lock_ = true
[node name="Bottom" type="TextureRect" parent="."]
offset_left = -49.0
offset_top = 116.0
offset_right = 62.0
offset_bottom = 241.0
texture = ExtResource("6_w0l5s")
script = ExtResource("7_58p8d")
[node name="Eyes" type="AnimatedSprite2D" parent="."]
position = Vector2(28.6857, -15.7785)
sprite_frames = SubResource("2")

View file

@ -15,4 +15,4 @@ position = Vector2(419, 84)
position = Vector2(296, 286)
[node name="Object" parent="." instance=ExtResource("2_cgl4f")]
position = Vector2(301, 146)
position = Vector2(169, 90)

View file

@ -1,24 +1,13 @@
[gd_scene load_steps=11 format=3 uid="uid://cvr2aries2lhr"]
[gd_scene load_steps=9 format=3 uid="uid://cvr2aries2lhr"]
[ext_resource type="Texture2D" uid="uid://33g80p0qnfw4" path="res://sprites/world/background.svg" id="1_uee2i"]
[ext_resource type="Texture2D" uid="uid://bi7ayrxnn7hex" path="res://sprites/clothes/icrazy_frame.svg" id="2_n1kmf"]
[ext_resource type="Texture2D" uid="uid://cmv58t1dfgsov" path="res://sprites/world/stand.svg" id="2_q0w7j"]
[ext_resource type="Texture2D" uid="uid://dteiup73cqn4o" path="res://sprites/clothes/lights.png" id="3_bbsyl"]
[ext_resource type="Script" path="res://scripts/gui.gd" id="4_pqv2p"]
[ext_resource type="PackedScene" uid="uid://crwoe1shep3qn" path="res://scenes/wardrobe.tscn" id="5_4le6a"]
[ext_resource type="Theme" uid="uid://b4vgui7vtqdtb" path="res://resources/Game.theme" id="5_gf1vk"]
[ext_resource type="PackedScene" uid="uid://dn152ouc7l21p" path="res://scenes/object.tscn" id="6_6t4pu"]
[ext_resource type="PackedScene" uid="uid://detf8uwimqp3v" path="res://scenes/character.tscn" id="6_tdil0"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tqrj6"]
bg_color = Color(0.0313726, 0.321569, 0.321569, 1)
corner_radius_top_left = 10
corner_radius_bottom_left = 10
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3qslg"]
corner_radius_top_left = 10
corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10
[ext_resource type="PackedScene" uid="uid://bvbelmb6rvy4f" path="res://scenes/platform.tscn" id="7_vqx6c"]
[ext_resource type="Texture2D" uid="uid://venieklgphn5" path="res://sprites/clothes/blue_camo_jeans.svg" id="8_bqcl8"]
[node name="Game" type="Node"]
@ -41,39 +30,20 @@ position = Vector2(35.118, -14.56)
texture = ExtResource("3_bbsyl")
metadata/_edit_lock_ = true
[node name="GUI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("5_gf1vk")
script = ExtResource("4_pqv2p")
metadata/_edit_lock_ = true
[node name="Panel" type="Panel" parent="GUI"]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.3975
anchor_top = 0.02
anchor_right = 1.015
anchor_bottom = 0.878
offset_right = 1.14441e-05
theme_override_styles/panel = SubResource("StyleBoxFlat_tqrj6")
metadata/_edit_use_anchors_ = true
[node name="Wardrobe" parent="GUI" instance=ExtResource("5_4le6a")]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.42625
anchor_top = 0.054
anchor_right = 0.975
anchor_bottom = 0.822
offset_bottom = 1.23978e-05
grow_horizontal = 1
grow_vertical = 1
theme_override_styles/panel = SubResource("StyleBoxFlat_3qslg")
[node name="Character" parent="." instance=ExtResource("6_tdil0")]
position = Vector2(117, 234)
metadata/_edit_lock_ = true
[node name="Bottoms" parent="." groups=["pants"] instance=ExtResource("7_vqx6c")]
position = Vector2(120, 409)
[node name="Platform" parent="." groups=["pants"] instance=ExtResource("7_vqx6c")]
position = Vector2(335, 78)
[node name="Object" parent="." instance=ExtResource("6_6t4pu")]
position = Vector2(335, 79)
group = "pants"
texture = ExtResource("8_bqcl8")
[node name="TileMap" type="TileMap" parent="."]
format = 2

View file

@ -1,22 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://dn152ouc7l21p"]
[gd_scene load_steps=3 format=3 uid="uid://dn152ouc7l21p"]
[ext_resource type="Texture2D" uid="uid://d1hpnolu3m1ho" path="res://godot.png" id="1_jjr7w"]
[ext_resource type="Script" path="res://scripts/object.gd" id="1_tyfcj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_py2o1"]
size = Vector2(59, 59)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xd2jg"]
size = Vector2(111, 125.5)
[node name="Object" type="Node2D"]
script = ExtResource("1_tyfcj")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_jjr7w")
position = Vector2(4.5, 6.5)
scale = Vector2(1.32143, 1.32292)
[node name="Area2D" type="Area2D" parent="."]
metadata/_edit_lock_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0.5, -0.5)
shape = SubResource("RectangleShape2D_py2o1")
position = Vector2(5, 7)
shape = SubResource("RectangleShape2D_xd2jg")
metadata/_edit_lock_ = true
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]

View file

@ -1,26 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://bvbelmb6rvy4f"]
[gd_scene load_steps=4 format=3 uid="uid://bvbelmb6rvy4f"]
[ext_resource type="Script" path="res://scripts/platform.gd" id="1_xgdk6"]
[ext_resource type="Texture2D" uid="uid://c52oho3nvkt45" path="res://sprites/clothes/scale.png" id="2_ic83p"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ieyrm"]
size = Vector2(62, 61)
size = Vector2(111, 126)
[node name="Platform" type="StaticBody2D"]
script = ExtResource("1_xgdk6")
[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -31.0
offset_top = -31.0
offset_right = 31.0
offset_bottom = 30.0
grow_horizontal = 2
grow_vertical = 2
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(4.5, 7)
scale = Vector2(1.32143, 1.28571)
texture = ExtResource("2_ic83p")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -0.5)
position = Vector2(4.5, 7)
shape = SubResource("RectangleShape2D_ieyrm")
metadata/_edit_lock_ = true

View file

@ -1,13 +1,9 @@
[gd_scene load_steps=9 format=3 uid="uid://crwoe1shep3qn"]
[gd_scene load_steps=3 format=3 uid="uid://crwoe1shep3qn"]
[ext_resource type="Script" path="res://scripts/clothing.gd" id="2_1si7t"]
[ext_resource type="Texture2D" uid="uid://yhyxxgdk0o4r" path="res://sprites/clothes/dj_shorts.svg" id="3_8ykbu"]
[ext_resource type="Texture2D" uid="uid://405burxtvied" path="res://sprites/clothes/sweat_pants.svg" id="3_h6yd3"]
[ext_resource type="Texture2D" uid="uid://bvh35sf1ahp1k" path="res://sprites/clothes/jeans.svg" id="4_53rvc"]
[ext_resource type="Texture2D" uid="uid://8vrl1mmcm5is" path="res://sprites/clothes/beat_up_jeans.svg" id="5_magqk"]
[ext_resource type="Texture2D" uid="uid://venieklgphn5" path="res://sprites/clothes/blue_camo_jeans.svg" id="6_dagdg"]
[ext_resource type="Texture2D" uid="uid://cf72ydh00dbjc" path="res://sprites/clothes/blue_skirt.svg" id="6_n1njc"]
[ext_resource type="Texture2D" uid="uid://cardxswmgbmbv" path="res://sprites/clothes/owo_censor.svg" id="8_noljf"]
[ext_resource type="PackedScene" uid="uid://dn152ouc7l21p" path="res://scenes/object.tscn" id="1_0jlsi"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oig6u"]
size = Vector2(111, 125.5)
[node name="Wordrobe" type="Panel"]
anchors_preset = 15
@ -28,43 +24,28 @@ size_flags_vertical = 3
columns = 4
metadata/_edit_use_anchors_ = true
[node name="SweatPants" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("3_h6yd3")
expand_mode = 3
script = ExtResource("2_1si7t")
[node name="Object" parent="Grid" instance=ExtResource("1_0jlsi")]
position = Vector2(51, 54)
texture = null
[node name="DJShorts" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("3_8ykbu")
expand_mode = 3
script = ExtResource("2_1si7t")
[node name="Bottoms" type="StaticBody2D" parent="Grid" groups=["bottoms"]]
[node name="Jeans" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("4_53rvc")
expand_mode = 3
script = ExtResource("2_1si7t")
[node name="ColorRect" type="ColorRect" parent="Grid/Bottoms"]
custom_minimum_size = Vector2(111, 125)
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -49.0
offset_top = 116.0
offset_right = 62.0
offset_bottom = 241.0
grow_horizontal = 2
grow_vertical = 2
color = Color(1, 1, 1, 0.0980392)
metadata/_edit_use_anchors_ = true
[node name="TornJeans" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("5_magqk")
script = ExtResource("2_1si7t")
[node name="CamoJeans" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("6_dagdg")
stretch_mode = 4
script = ExtResource("2_1si7t")
[node name="Skirt" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("6_n1njc")
stretch_mode = 4
script = ExtResource("2_1si7t")
[node name="OwO" type="TextureRect" parent="Grid"]
layout_mode = 2
texture = ExtResource("8_noljf")
stretch_mode = 4
script = ExtResource("2_1si7t")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Grid/Bottoms"]
position = Vector2(6, 178.25)
shape = SubResource("RectangleShape2D_oig6u")

View file

@ -1,29 +1,52 @@
# This project is licensed under the GPL-3.0 license.
# See the LICENSE file in the project root for more information.
@tool
extends Node2D
@export var group: String = "dropable"
@export var texture: Texture2D
var is_draggable = false
var is_inside_dropable = false
var body_ref
var offset: Vector2
@onready var sprite = $Sprite2D
@onready var collsion = $Area2D/CollisionShape2D
func _ready():
sprite.texture = texture
collsion.position = sprite.position
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if is_draggable:
if Input.is_action_just_pressed("click"):
offset = get_global_mouse_position() - global_position
offset = global_position - get_global_mouse_position()
Global.is_dragging = true
if Input.is_action_pressed("click"):
global_position = get_global_mouse_position() - offset
elif Input.is_action_just_released("click"):
Global.is_dragging = false
var tween = get_tree().create_tween()
if is_inside_dropable:
tween.tween_property(self, "position", body_ref.position, 0.2).set_ease(Tween.EASE_OUT)
else:
tween.tween_property(self, "global_position", body_ref.position, 0.2).set_ease(Tween.EASE_OUT)
func _on_area_2d_body_entered(body):
if body.is_in_group('dropable'):
if body.is_in_group(group):
is_inside_dropable = true
body.modulate = Color(Color.REBECCA_PURPLE, 1)
scale = Vector2(1.05, 1.05)
body_ref = body
func _on_area_2d_body_exited(body:StaticBody2D):
if body.is_in_group('dropable'):
if body.is_in_group(group):
is_inside_dropable = false
body.modulate = Color(Color.MEDIUM_PURPLE, .7)
scale = Vector2(1.05, 1.05)

BIN
sprites/clothes/scale.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c52oho3nvkt45"
path="res://.godot/imported/scale.png-cc0bf5b86379a7eb56d82f3b51afdc52.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/clothes/scale.png"
dest_files=["res://.godot/imported/scale.png-cc0bf5b86379a7eb56d82f3b51afdc52.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