sticker system preparation

This commit is contained in:
Lucas Peter 2024-07-26 11:50:52 +02:00
parent f60105d56a
commit cf08e821bc
No known key found for this signature in database
5 changed files with 148 additions and 6 deletions

View file

@ -38,19 +38,41 @@ func _process(delta):
cursor_look()
func isSticker(selectedObject:Node):
var _isSticker:bool = false
var _tags = getTags(selectedObject)
if (_tags.size() > 0):
if (_tags.find(\"sticker\") != -1):
_isSticker = true
return _isSticker
func getTags(selectedObject:Node):
var _tags: Array
if (selectedObject.has_meta(\"tags\")):
_tags = selectedObject.get_meta(\"tags\")
return _tags
else:
printerr(\"no tags inside %\",selectedObject)
return _tags
func pointcast():
query.collide_with_areas = true
query.position = get_global_mouse_position()
CastResult = spaceState.direct_space_state.intersect_point(query)
if ( (CastResult.size() > 0) and (old_result != CastResult) ):
old_result = CastResult
if (CastResult.size()> 2):
breakpoint # should not detect multiple areas
for _result in CastResult:
if (_result.collider.input_pickable == true):
selectedSticker = _result.collider.get_parent()
if (isSticker(selectedSticker)):
print(\"selected sticker %\",selectedSticker)
if (CastResult.size() == 0):
else:
selectedSticker = null
if (CastResult.size() == 0 ):
CastResult.clear()
old_result = null
selectedSticker = null

View file

@ -5,7 +5,7 @@ extends CharacterBody2D
@export var CurrentHat: CanvasTexture
const SPEED = 1000.0
const MOUSESPEED = 10.0
func teleport(location:Transform2D , direction:float = 1):
transform = location
scale = Vector2(direction,1)
@ -25,6 +25,8 @@ func changeSkin(NewSkin:CanvasTexture,_NewHat:CanvasTexture = null):
func get_input():
var directionX = Input.get_axis("move_left", "move_right")
var directionY = Input.get_axis("move_up", "move_down")
var mouseDirectionX = Input.get_axis("mouse_left", "mouse_right")
var mouseDirectionY = Input.get_axis("mouse_up", "mouse_down")
#region Movement
## Get the input direction and handle the movement/deceleration.
if directionX :
@ -36,6 +38,8 @@ func get_input():
else:
velocity.y = move_toward(velocity.y, 0, SPEED)
#endregion
var wantedMousePosition = get_viewport().get_mouse_position()+(Vector2(mouseDirectionX,mouseDirectionY)*MOUSESPEED)
get_viewport().warp_mouse(wantedMousePosition)
#region Animation
if (directionX < 0):
$Skeleton2D/root/Hips.set_scale(Vector2(1, 1))

View file

@ -1,10 +1,12 @@
[gd_scene load_steps=9 format=3 uid="uid://wlqsvbqpcbh"]
[gd_scene load_steps=14 format=3 uid="uid://wlqsvbqpcbh"]
[ext_resource type="Texture2D" uid="uid://cacwy4tka88k1" path="res://maps/map1.tres" id="1_pt5vq"]
[ext_resource type="Texture2D" uid="uid://cxharyv0ajr37" path="res://textures/atlas/DioramaEntrance_All_01_SPRT.png" id="2_n7y5f"]
[ext_resource type="Texture2D" uid="uid://c5bd2ta3esnib" path="res://extracted/4010-A Tiny Sticker Tale review pic 1.jpg" id="3_yh2wy"]
[ext_resource type="PackedScene" uid="uid://bddcriwo55x8k" path="res://prefab/prefab_woddenbridge.tscn" id="4_okpsn"]
[ext_resource type="Texture2D" uid="uid://dx8jpmxtm2cdx" path="res://textures/pattern/Pattern_Forest.png" id="5_i137q"]
[ext_resource type="Texture2D" uid="uid://cun14l52f477p" path="res://textures/atlas/Bushes_All_01_SPRT.png" id="5_xmosd"]
[ext_resource type="PackedScene" uid="uid://domcpxdf6lqpb" path="res://prefab/prefab_bush1.tscn" id="6_3fkbm"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_js06g"]
@ -16,7 +18,21 @@ region = Rect2(252, 16, 108, 256)
atlas = ExtResource("2_n7y5f")
region = Rect2(12, 96, 216, 112)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_lfx7b"]
radius = 80.0
height = 254.0
[sub_resource type="AtlasTexture" id="AtlasTexture_rn40i"]
atlas = ExtResource("5_xmosd")
region = Rect2(736, 96, 224, 160)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_b3366"]
radius = 50.0
height = 160.0
[node name="Map1" type="Node2D"]
z_as_relative = false
y_sort_enabled = true
material = SubResource("ShaderMaterial_js06g")
[node name="Container" type="Control" parent="."]
@ -56,6 +72,8 @@ texture = ExtResource("5_i137q")
stretch_mode = 1
[node name="Floors05Sprt" type="Sprite2D" parent="."]
z_index = -1
z_as_relative = false
scale = Vector2(6, 6)
texture = ExtResource("1_pt5vq")
region_rect = Rect2(0, 0, 1024, 992)
@ -96,3 +114,40 @@ top_level = true
position = Vector2(78, -148)
scale = Vector2(6.15, 6.15)
texture = ExtResource("3_yh2wy")
[node name="Bush1" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(-2161, 1140)
Shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush6" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(-1556, 293)
Shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush7" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(712, 293)
Shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush9" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(1004, -2257)
Shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush8" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(-1616, -1651)
offset = Vector2(-137.285, -179.785)
flip_h = true
Shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush10" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(-2063, -2116)
texture = SubResource("AtlasTexture_rn40i")
offset = Vector2(-108.615, -141.38)
flip_h = true
Shape = SubResource("CapsuleShape2D_b3366")
Position = Vector2(0, -48.95)
[node name="Bush11" parent="." instance=ExtResource("6_3fkbm")]
position = Vector2(2208, 2337)
texture = SubResource("AtlasTexture_rn40i")
offset = Vector2(-108.615, -141.38)
Shape = SubResource("CapsuleShape2D_b3366")
Position = Vector2(0, -48.95)

60
prefab/prefab_bush1.tscn Normal file
View file

@ -0,0 +1,60 @@
[gd_scene load_steps=4 format=3 uid="uid://domcpxdf6lqpb"]
[ext_resource type="Texture2D" uid="uid://cun14l52f477p" path="res://textures/atlas/Bushes_All_01_SPRT.png" id="1_1wk1p"]
[sub_resource type="AtlasTexture" id="AtlasTexture_2wdar"]
atlas = ExtResource("1_1wk1p")
region = Rect2(384, 64, 288, 224)
[sub_resource type="GDScript" id="GDScript_uqtu8"]
script/source = "@tool
extends Sprite2D
@export_group(\"Collision Shape\")
@export var Shape :Shape2D:
set(new_shape):
Shape = new_shape
$Area2D/CollisionShape2D.shape = Shape
$Area2D/CollisionShape2D.queue_redraw()
@export var Position :Vector2:
set(new_position):
Position = new_position
$Area2D/CollisionShape2D.position = Position
$Area2D/CollisionShape2D.queue_redraw()
@export var Rotation :Vector2:
set(new_rotation):
Rotation = new_rotation
$Area2D/CollisionShape2D.rotation = Rotation
$Area2D/CollisionShape2D.queue_redraw()
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
"
[node name="Bush1" type="Sprite2D"]
scale = Vector2(3.80334, 3.95089)
texture = SubResource("AtlasTexture_2wdar")
centered = false
offset = Vector2(-161.055, -179.785)
script = SubResource("GDScript_uqtu8")
metadata/tags = ["sticker"]
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 3
monitoring = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(-4.46976, -71.6294)
rotation = 1.5708
[connection signal="property_list_changed" from="." to="." method="_on_property_list_changed"]

View file

@ -10,6 +10,7 @@ region = Rect2(72, 1392, 216, 272)
[node name="WoodenBridge" type="Sprite2D"]
scale = Vector2(5.71296, 5.71296)
texture = SubResource("AtlasTexture_nkyhf")
metadata/tags = ["sticker"]
[node name="BridgeNode" parent="." instance=ExtResource("2_te8ug")]
position = Vector2(1788, 788)