mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-24 00:24:19 +00:00
Add balumissing stuff
This commit is contained in:
parent
c861b85232
commit
6a48e49515
13 changed files with 125 additions and 54 deletions
|
@ -105,7 +105,7 @@ texture = ExtResource("1_qvgnf")
|
||||||
4:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
4:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
|
|
||||||
[sub_resource type="TileSet" id="TileSet_tr7be"]
|
[sub_resource type="TileSet" id="TileSet_tr7be"]
|
||||||
physics_layer_0/collision_layer = 2
|
physics_layer_0/collision_layer = 18
|
||||||
physics_layer_0/collision_mask = 0
|
physics_layer_0/collision_mask = 0
|
||||||
physics_layer_0/physics_material = SubResource("PhysicsMaterial_y0g3v")
|
physics_layer_0/physics_material = SubResource("PhysicsMaterial_y0g3v")
|
||||||
sources/1 = SubResource("TileSetAtlasSource_6tyce")
|
sources/1 = SubResource("TileSetAtlasSource_6tyce")
|
||||||
|
|
4
bottle/placeable_area.gd
Normal file
4
bottle/placeable_area.gd
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extends Area2D
|
||||||
|
class_name PlaceableArea
|
||||||
|
|
||||||
|
# This script itself does nothing, it's just so that [Ghost] can identify this specific area.
|
16
bottle/placeable_area.tscn
Normal file
16
bottle/placeable_area.tscn
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://4d0al27t7axe"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://bottle/placeable_area.gd" id="1_1i0ue"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rh35r"]
|
||||||
|
size = Vector2(240, 384)
|
||||||
|
|
||||||
|
[node name="PlaceableArea" type="Area2D"]
|
||||||
|
position = Vector2(136, 272)
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 0
|
||||||
|
script = ExtResource("1_1i0ue")
|
||||||
|
|
||||||
|
[node name="BottleShape" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_rh35r")
|
||||||
|
debug_color = Color(0, 0.6, 0.701961, 0)
|
9
converters/converter_placement_body.tscn
Normal file
9
converters/converter_placement_body.tscn
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bevj27e1ha8m3"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c3p0jdf7416ac" path="res://converters/full_converter_shape.tscn" id="1_qs7xk"]
|
||||||
|
|
||||||
|
[node name="ConverterPlacementBody" type="StaticBody2D"]
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
|
[node name="FullConverterShape" parent="." instance=ExtResource("1_qs7xk")]
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=21 format=3 uid="uid://ratkps4plkhl"]
|
[gd_scene load_steps=22 format=3 uid="uid://ratkps4plkhl"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://converters/converter.gd" id="1_mas6k"]
|
[ext_resource type="Script" path="res://converters/converter.gd" id="1_mas6k"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dme22vvfgme5f" path="res://entity/coin_silver/coin_silver.tscn" id="2_h5aul"]
|
[ext_resource type="PackedScene" uid="uid://dme22vvfgme5f" path="res://entity/coin_silver/coin_silver.tscn" id="2_h5aul"]
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="9_2wvgu"]
|
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="9_2wvgu"]
|
||||||
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_6hhch"]
|
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_6hhch"]
|
||||||
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_r8505"]
|
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_r8505"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_5qhgs"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_62dyi"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_62dyi"]
|
||||||
atlas = ExtResource("4_exnn7")
|
atlas = ExtResource("4_exnn7")
|
||||||
|
@ -132,6 +133,8 @@ stream = ExtResource("10_6hhch")
|
||||||
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("11_r8505")
|
stream = ExtResource("11_r8505")
|
||||||
|
|
||||||
|
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_5qhgs")]
|
||||||
|
|
||||||
[connection signal="collected" from="Collector" to="." method="_on_collector_collected"]
|
[connection signal="collected" from="Collector" to="." method="_on_collector_collected"]
|
||||||
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
|
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
|
||||||
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]
|
||||||
|
|
8
converters/full_converter_shape.tscn
Normal file
8
converters/full_converter_shape.tscn
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://c3p0jdf7416ac"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_np8fu"]
|
||||||
|
size = Vector2(32, 35)
|
||||||
|
|
||||||
|
[node name="FullConverterShape" type="CollisionShape2D"]
|
||||||
|
shape = SubResource("RectangleShape2D_np8fu")
|
||||||
|
debug_color = Color(0, 1, 1, 0)
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=23 format=3 uid="uid://c4ew8x4gch275"]
|
[gd_scene load_steps=24 format=3 uid="uid://c4ew8x4gch275"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://converters/converter.gd" id="1_f5plk"]
|
[ext_resource type="Script" path="res://converters/converter.gd" id="1_f5plk"]
|
||||||
[ext_resource type="Texture2D" uid="uid://chc8wqc1pclbk" path="res://converters/gold_to_gem/gold_converter_back.png" id="2_icys1"]
|
[ext_resource type="Texture2D" uid="uid://chc8wqc1pclbk" path="res://converters/gold_to_gem/gold_converter_back.png" id="2_icys1"]
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="9_2ugi1"]
|
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="9_2ugi1"]
|
||||||
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_f1h6i"]
|
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_f1h6i"]
|
||||||
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_ywwn2"]
|
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_ywwn2"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="13_6o73w"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wy1v3"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wy1v3"]
|
||||||
atlas = ExtResource("3_n6auo")
|
atlas = ExtResource("3_n6auo")
|
||||||
|
@ -145,6 +146,8 @@ stream = ExtResource("10_f1h6i")
|
||||||
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("11_ywwn2")
|
stream = ExtResource("11_ywwn2")
|
||||||
|
|
||||||
|
[node name="ConverterPlacementBody" parent="." instance=ExtResource("13_6o73w")]
|
||||||
|
|
||||||
[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18]
|
[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18]
|
||||||
[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18]
|
[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18]
|
||||||
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]
|
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=33 format=3 uid="uid://ddrhfhebwtq5"]
|
[gd_scene load_steps=34 format=3 uid="uid://ddrhfhebwtq5"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://converters/converter.gd" id="1_qln0a"]
|
[ext_resource type="Script" path="res://converters/converter.gd" id="1_qln0a"]
|
||||||
[ext_resource type="Texture2D" uid="uid://devcho3gaigt0" path="res://converters/item_converter/item_converter_back_1.png" id="2_136t7"]
|
[ext_resource type="Texture2D" uid="uid://devcho3gaigt0" path="res://converters/item_converter/item_converter_back_1.png" id="2_136t7"]
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://fqerky4lyps8" path="res://converters/item_converter/item_converter_front_3.png" id="9_88mk7"]
|
[ext_resource type="Texture2D" uid="uid://fqerky4lyps8" path="res://converters/item_converter/item_converter_front_3.png" id="9_88mk7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bw0jgw0jen4lg" path="res://converters/item_converter/item_converter_front_4.png" id="10_fjv52"]
|
[ext_resource type="Texture2D" uid="uid://bw0jgw0jen4lg" path="res://converters/item_converter/item_converter_front_4.png" id="10_fjv52"]
|
||||||
[ext_resource type="Texture2D" uid="uid://4tg81ksibacf" path="res://converters/item_converter/item_converter_front_5.png" id="11_cg5dk"]
|
[ext_resource type="Texture2D" uid="uid://4tg81ksibacf" path="res://converters/item_converter/item_converter_front_5.png" id="11_cg5dk"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="17_udaa3"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uqtie"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_uqtie"]
|
||||||
atlas = ExtResource("2_136t7")
|
atlas = ExtResource("2_136t7")
|
||||||
|
@ -184,6 +185,8 @@ stream = ExtResource("6_w6x4p")
|
||||||
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("7_x4ti3")
|
stream = ExtResource("7_x4ti3")
|
||||||
|
|
||||||
|
[node name="ConverterPlacementBody" parent="." instance=ExtResource("17_udaa3")]
|
||||||
|
|
||||||
[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18]
|
[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18]
|
||||||
[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18]
|
[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18]
|
||||||
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]
|
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=17 format=3 uid="uid://but1bdslxp5jl"]
|
[gd_scene load_steps=18 format=3 uid="uid://but1bdslxp5jl"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://converters/converter.gd" id="1_chhfg"]
|
[ext_resource type="Script" path="res://converters/converter.gd" id="1_chhfg"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c1fu70mb51gyd" path="res://converters/silver_to_gold/silver_converter_back.png" id="2_rpdc3"]
|
[ext_resource type="Texture2D" uid="uid://c1fu70mb51gyd" path="res://converters/silver_to_gold/silver_converter_back.png" id="2_rpdc3"]
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="9_t8y3t"]
|
[ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="9_t8y3t"]
|
||||||
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_0dr47"]
|
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_0dr47"]
|
||||||
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_ow0vy"]
|
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_ow0vy"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_37x2h"]
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_1qp6y"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_1qp6y"]
|
||||||
animations = [{
|
animations = [{
|
||||||
|
@ -118,6 +119,8 @@ stream = ExtResource("10_0dr47")
|
||||||
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("11_ow0vy")
|
stream = ExtResource("11_ow0vy")
|
||||||
|
|
||||||
|
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_37x2h")]
|
||||||
|
|
||||||
[connection signal="collected" from="Collector" to="." method="_on_collector_collected"]
|
[connection signal="collected" from="Collector" to="." method="_on_collector_collected"]
|
||||||
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
|
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
|
||||||
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=22 format=3 uid="uid://c3rxmcwa5nqng"]
|
[gd_scene load_steps=23 format=3 uid="uid://c3rxmcwa5nqng"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://game/game.gd" id="1_i3ly0"]
|
[ext_resource type="Script" path="res://game/game.gd" id="1_i3ly0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_y7o2l"]
|
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_y7o2l"]
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://taojrwr7xrp4" path="res://interface/upgrade_gold.png" id="4_i557v"]
|
[ext_resource type="Texture2D" uid="uid://taojrwr7xrp4" path="res://interface/upgrade_gold.png" id="4_i557v"]
|
||||||
[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_my6nv"]
|
[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_my6nv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ratkps4plkhl" path="res://converters/copper_to_silver/copper_converter.tscn" id="7_ipeok"]
|
[ext_resource type="PackedScene" uid="uid://ratkps4plkhl" path="res://converters/copper_to_silver/copper_converter.tscn" id="7_ipeok"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://4d0al27t7axe" path="res://bottle/placeable_area.tscn" id="7_muqgj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://but1bdslxp5jl" path="res://converters/silver_to_gold/silver_converter.tscn" id="8_0bbpi"]
|
[ext_resource type="PackedScene" uid="uid://but1bdslxp5jl" path="res://converters/silver_to_gold/silver_converter.tscn" id="8_0bbpi"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="8_a3sk0"]
|
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="8_a3sk0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c2rlx7egl7xiv" path="res://collector/universal_collector.tscn" id="9_7op48"]
|
[ext_resource type="PackedScene" uid="uid://c2rlx7egl7xiv" path="res://collector/universal_collector.tscn" id="9_7op48"]
|
||||||
|
@ -44,14 +45,7 @@ position = Vector2(90, 306)
|
||||||
|
|
||||||
[node name="Bottle" parent="." instance=ExtResource("1_y7o2l")]
|
[node name="Bottle" parent="." instance=ExtResource("1_y7o2l")]
|
||||||
|
|
||||||
[node name="PlaceableArea" type="Area2D" parent="Bottle"]
|
[node name="PlaceableArea" parent="Bottle" instance=ExtResource("7_muqgj")]
|
||||||
position = Vector2(136, 272)
|
|
||||||
collision_layer = 16
|
|
||||||
collision_mask = 0
|
|
||||||
|
|
||||||
[node name="BottleShape" type="CollisionShape2D" parent="Bottle/PlaceableArea"]
|
|
||||||
shape = SubResource("RectangleShape2D_rh35r")
|
|
||||||
debug_color = Color(0, 0.6, 0.701961, 0)
|
|
||||||
|
|
||||||
[node name="Evaluator" parent="Bottle" instance=ExtResource("6_my6nv")]
|
[node name="Evaluator" parent="Bottle" instance=ExtResource("6_my6nv")]
|
||||||
position = Vector2(136, 272)
|
position = Vector2(136, 272)
|
||||||
|
|
|
@ -1,42 +1,74 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
class_name Ghost
|
class_name Ghost
|
||||||
|
|
||||||
var is_dragging: bool
|
## Ghost previewing the instantiation of a scene.
|
||||||
var previous_position: Vector2
|
|
||||||
|
|
||||||
|
## The [CollisionShape2D] to use to check for placement checks.
|
||||||
|
##
|
||||||
|
## MUST consist of a [RectangleShape2D].
|
||||||
|
@onready var placement_shape: CollisionShape2D = $PlacementShape
|
||||||
|
|
||||||
func _input(event: InputEvent):
|
## The [Sprite2D] node previewing the scene.
|
||||||
if event is InputEventMouseButton:
|
@onready var preview_sprite: Sprite2D = $PlacementShape/PreviewSprite
|
||||||
is_dragging = event.pressed
|
|
||||||
previous_position = event.position
|
|
||||||
elif event is InputEventScreenTouch:
|
|
||||||
is_dragging = event.pressed
|
|
||||||
previous_position = event.position
|
|
||||||
|
|
||||||
if is_dragging:
|
|
||||||
if event is InputEventMouseMotion:
|
|
||||||
var delta = event.position - previous_position
|
|
||||||
move_and_check(position + delta)
|
|
||||||
previous_position = event.position
|
|
||||||
elif event is InputEventScreenDrag:
|
|
||||||
var delta = event.position - previous_position
|
|
||||||
move_and_check(position + delta)
|
|
||||||
previous_position = event.position
|
|
||||||
|
|
||||||
|
## The texture that the preview sprite should display.
|
||||||
|
@export var preview_texture: Texture2D:
|
||||||
|
get:
|
||||||
|
return preview_texture
|
||||||
|
set(value):
|
||||||
|
preview_texture = value
|
||||||
|
preview_sprite.texture = value
|
||||||
|
|
||||||
@onready var sprite: Sprite2D = $Sprite
|
## Whether the ghost can be placed at the current location of the ghost.
|
||||||
|
##
|
||||||
@export var can_place: bool:
|
## Computed by checking if [placement_shape] overlaps any entity and is inside the [PlacementArea] of the [Bottle].
|
||||||
|
var can_place: bool:
|
||||||
get:
|
get:
|
||||||
return can_place
|
return can_place
|
||||||
set(value):
|
set(value):
|
||||||
if value:
|
if value:
|
||||||
sprite.modulate = Color(1.0, 1.0, 1.0, 0.5)
|
preview_sprite.modulate = Color(1.0, 1.0, 1.0, 0.5)
|
||||||
else:
|
else:
|
||||||
sprite.modulate = Color(1.0, 0.0, 0.0, 0.5)
|
preview_sprite.modulate = Color(1.0, 0.0, 0.0, 0.5)
|
||||||
|
|
||||||
|
## The last input event of the input that's dragging the ghost around, or null if the ghost isn't being dragged.
|
||||||
|
var last_input_event: InputEvent
|
||||||
|
|
||||||
|
|
||||||
func move_and_check(destination):
|
func _input(event: InputEvent):
|
||||||
position = destination
|
# Handle mouse click
|
||||||
can_place = not has_overlapping_bodies()
|
if event is InputEventMouseButton:
|
||||||
print(can_place)
|
last_input_event = event if event.pressed else null
|
||||||
|
# Handle touch begin
|
||||||
|
elif event is InputEventScreenTouch:
|
||||||
|
last_input_event = event if event.pressed else null
|
||||||
|
|
||||||
|
# If is dragging
|
||||||
|
if last_input_event:
|
||||||
|
# Handle mouse drag
|
||||||
|
if last_input_event is InputEventMouse and event is InputEventMouse:
|
||||||
|
var delta = event.position - last_input_event.position
|
||||||
|
position += delta
|
||||||
|
last_input_event = event
|
||||||
|
# Handle touch drag
|
||||||
|
elif (last_input_event is InputEventScreenTouch or last_input_event is InputEventScreenDrag) and event is InputEventScreenDrag:
|
||||||
|
if event.index == last_input_event.index:
|
||||||
|
var delta = event.position - last_input_event.position
|
||||||
|
position += delta
|
||||||
|
last_input_event = event
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(_delta: float):
|
||||||
|
var overlapping_bodies = get_overlapping_bodies()
|
||||||
|
var no_overlapping_bodies = true
|
||||||
|
|
||||||
|
|
||||||
|
var is_enclosed_by_placeable_area = false
|
||||||
|
# DIRTY HACK: Relies on the placeable area being perfectly surrounded by solid bodies.
|
||||||
|
var overlapping_areas = get_overlapping_areas()
|
||||||
|
for area in overlapping_areas:
|
||||||
|
if not area is PlaceableArea:
|
||||||
|
continue
|
||||||
|
is_enclosed_by_placeable_area = true
|
||||||
|
can_place = no_overlapping_bodies and is_enclosed_by_placeable_area
|
||||||
|
|
|
@ -2,22 +2,18 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://interface/ghost.gd" id="1_gvls7"]
|
[ext_resource type="Script" path="res://interface/ghost.gd" id="1_gvls7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://pj3ip6vlatms" path="res://converters/copper_to_silver/copper_converter.png" id="1_lo8gj"]
|
[ext_resource type="Texture2D" uid="uid://pj3ip6vlatms" path="res://converters/copper_to_silver/copper_converter.png" id="1_lo8gj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c3p0jdf7416ac" path="res://converters/full_converter_shape.tscn" id="3_lskcf"]
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hmopu"]
|
|
||||||
size = Vector2(34, 34)
|
|
||||||
|
|
||||||
[node name="Ghost" type="Area2D"]
|
[node name="Ghost" type="Area2D"]
|
||||||
scale = Vector2(3, 3)
|
collision_layer = 0
|
||||||
collision_layer = 16
|
collision_mask = 16
|
||||||
collision_mask = 10
|
|
||||||
input_pickable = false
|
input_pickable = false
|
||||||
script = ExtResource("1_gvls7")
|
script = ExtResource("1_gvls7")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="PlacementShape" parent="." instance=ExtResource("3_lskcf")]
|
||||||
|
scale = Vector2(3, 3)
|
||||||
|
|
||||||
|
[node name="PreviewSprite" type="Sprite2D" parent="PlacementShape"]
|
||||||
modulate = Color(1, 1, 1, 0.5)
|
modulate = Color(1, 1, 1, 0.5)
|
||||||
z_index = 10
|
z_index = 10
|
||||||
texture = ExtResource("1_lo8gj")
|
texture = ExtResource("1_lo8gj")
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
|
||||||
shape = SubResource("RectangleShape2D_hmopu")
|
|
||||||
debug_color = Color(0, 0.6, 0.701961, 0)
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ window/handheld/orientation=1
|
||||||
2d_physics/layer_2="Bottle"
|
2d_physics/layer_2="Bottle"
|
||||||
2d_physics/layer_3="Entities"
|
2d_physics/layer_3="Entities"
|
||||||
2d_physics/layer_4="Converter"
|
2d_physics/layer_4="Converter"
|
||||||
2d_physics/layer_5="Ghost"
|
2d_physics/layer_5="Placement"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue