diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-05-11 14:52:36 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-05-11 14:52:36 +0200 |
commit | 17716f198bf6b3e4d39d48d0394192a5cb640499 (patch) | |
tree | 78cf4c98483ad22e4ac137702f307a4478153857 |
initial commit
24 files changed, 452 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/Assets/wooden_bench/32x32/bench-backless-white.png b/Assets/wooden_bench/32x32/bench-backless-white.png Binary files differnew file mode 100644 index 0000000..c0b71e5 --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-backless-white.png diff --git a/Assets/wooden_bench/32x32/bench-backless-white.png.import b/Assets/wooden_bench/32x32/bench-backless-white.png.import new file mode 100644 index 0000000..af03c60 --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-backless-white.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://gt4feb7psdyv" +path="res://.godot/imported/bench-backless-white.png-7828f2f8a24eb03578b1498796570789.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/32x32/bench-backless-white.png" +dest_files=["res://.godot/imported/bench-backless-white.png-7828f2f8a24eb03578b1498796570789.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 diff --git a/Assets/wooden_bench/32x32/bench-backless-wood.png b/Assets/wooden_bench/32x32/bench-backless-wood.png Binary files differnew file mode 100644 index 0000000..d8cfa94 --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-backless-wood.png diff --git a/Assets/wooden_bench/32x32/bench-backless-wood.png.import b/Assets/wooden_bench/32x32/bench-backless-wood.png.import new file mode 100644 index 0000000..32c3c75 --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-backless-wood.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dain32mv4qnq8" +path="res://.godot/imported/bench-backless-wood.png-ded23c5bb0e206da5134f81eec17a209.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/32x32/bench-backless-wood.png" +dest_files=["res://.godot/imported/bench-backless-wood.png-ded23c5bb0e206da5134f81eec17a209.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 diff --git a/Assets/wooden_bench/32x32/bench-white.png b/Assets/wooden_bench/32x32/bench-white.png Binary files differnew file mode 100644 index 0000000..0b1fba5 --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-white.png diff --git a/Assets/wooden_bench/32x32/bench-white.png.import b/Assets/wooden_bench/32x32/bench-white.png.import new file mode 100644 index 0000000..1a3b57b --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-white.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://shv6du17iha7" +path="res://.godot/imported/bench-white.png-167d7ca004f9027b77939dbef06f87c2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/32x32/bench-white.png" +dest_files=["res://.godot/imported/bench-white.png-167d7ca004f9027b77939dbef06f87c2.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 diff --git a/Assets/wooden_bench/32x32/bench-wood.png b/Assets/wooden_bench/32x32/bench-wood.png Binary files differnew file mode 100644 index 0000000..c8510df --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-wood.png diff --git a/Assets/wooden_bench/32x32/bench-wood.png.import b/Assets/wooden_bench/32x32/bench-wood.png.import new file mode 100644 index 0000000..1624d8b --- /dev/null +++ b/Assets/wooden_bench/32x32/bench-wood.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dfjrmruj2mk0n" +path="res://.godot/imported/bench-wood.png-c9d416da08a38ab3ce335708b6eddf6c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/32x32/bench-wood.png" +dest_files=["res://.godot/imported/bench-wood.png-c9d416da08a38ab3ce335708b6eddf6c.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 diff --git a/Assets/wooden_bench/palette-bench_white.png b/Assets/wooden_bench/palette-bench_white.png Binary files differnew file mode 100644 index 0000000..4a1d9ea --- /dev/null +++ b/Assets/wooden_bench/palette-bench_white.png diff --git a/Assets/wooden_bench/palette-bench_white.png.import b/Assets/wooden_bench/palette-bench_white.png.import new file mode 100644 index 0000000..18382d4 --- /dev/null +++ b/Assets/wooden_bench/palette-bench_white.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://5uqpwf6ke8k6" +path="res://.godot/imported/palette-bench_white.png-9544d578586d3223f77ac16e4aab9499.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/palette-bench_white.png" +dest_files=["res://.godot/imported/palette-bench_white.png-9544d578586d3223f77ac16e4aab9499.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 diff --git a/Assets/wooden_bench/palette-bench_wooden.png b/Assets/wooden_bench/palette-bench_wooden.png Binary files differnew file mode 100644 index 0000000..55249d4 --- /dev/null +++ b/Assets/wooden_bench/palette-bench_wooden.png diff --git a/Assets/wooden_bench/palette-bench_wooden.png.import b/Assets/wooden_bench/palette-bench_wooden.png.import new file mode 100644 index 0000000..d645051 --- /dev/null +++ b/Assets/wooden_bench/palette-bench_wooden.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d167v65jumhqe" +path="res://.godot/imported/palette-bench_wooden.png-7e327fa50c58ce74800b73ced3e3567b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/wooden_bench/palette-bench_wooden.png" +dest_files=["res://.godot/imported/palette-bench_wooden.png-7e327fa50c58ce74800b73ced3e3567b.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 diff --git a/Objects/BuilderObject.gd b/Objects/BuilderObject.gd new file mode 100644 index 0000000..9131120 --- /dev/null +++ b/Objects/BuilderObject.gd @@ -0,0 +1,50 @@ +class_name BuilderObject +extends Node2D + + +signal collided + +var is_colliding = false +var is_dragged = false + +var mouse_offset = Vector2(0,0) +var last_position = Vector2(0,0) + + +func _process(_delta): + if $Area2D.get_overlapping_areas().size() > 0: + is_colliding = true + else: + is_colliding = false + + if is_dragged: + position = get_global_mouse_position() + mouse_offset + + if is_colliding: + modulate = Color("bb5a4b") + else: + modulate = Color("fff") + + +func _on_area_2d_input_event(_viewport, event: InputEvent, _shape_idx): + if event.is_action_pressed("drag_start"): + drag_start() + if event.is_action_released("drag_start"): + drag_end() + + +func drag_start(): + if get_viewport(): + mouse_offset = position - get_global_mouse_position() + last_position = position + + is_dragged = true + +func drag_end(): + if is_dragged and is_colliding: + if last_position != Vector2(0,0): + position = last_position + else: + queue_free() + + is_dragged = false diff --git a/Objects/BuilderObject.tscn b/Objects/BuilderObject.tscn new file mode 100644 index 0000000..ad83377 --- /dev/null +++ b/Objects/BuilderObject.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=4 format=3 uid="uid://p0ay1mp7v772"] + +[ext_resource type="Script" path="res://Objects/BuilderObject.gd" id="1_wjk1m"] +[ext_resource type="Texture2D" uid="uid://dfjrmruj2mk0n" path="res://Assets/wooden_bench/32x32/bench-wood.png" id="2_hvvj8"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vqo4b"] +size = Vector2(80, 64) + +[node name="BuilderObject" type="Node2D"] +script = ExtResource("1_wjk1m") + +[node name="Area2D" type="Area2D" parent="."] +collision_layer = 3 +collision_mask = 3 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("RectangleShape2D_vqo4b") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_hvvj8") +region_enabled = true +region_rect = Rect2(2, 13, 60, 49) + +[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] +[connection signal="area_exited" from="Area2D" to="." method="_on_area_2d_area_exited"] +[connection signal="area_shape_entered" from="Area2D" to="." method="_on_area_2d_area_shape_entered"] +[connection signal="area_shape_exited" from="Area2D" to="." method="_on_area_2d_area_shape_exited"] +[connection signal="input_event" from="Area2D" to="." method="_on_area_2d_input_event"] diff --git a/Start.tscn b/Start.tscn new file mode 100644 index 0000000..560eb9b --- /dev/null +++ b/Start.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=3 format=3 uid="uid://bdyngwtm3rowr"] + +[ext_resource type="PackedScene" uid="uid://p0ay1mp7v772" path="res://Objects/BuilderObject.tscn" id="3_skats"] +[ext_resource type="PackedScene" uid="uid://3vuctgbcjqi7" path="res://Tray.tscn" id="3_u4wpj"] + +[node name="Start" type="Node2D"] + +[node name="BuilderObject" parent="." instance=ExtResource("3_skats")] +position = Vector2(155, 109) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer"] +custom_minimum_size = Vector2(80, 0) +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -4.0 +grow_horizontal = 0 +grow_vertical = 2 +size_flags_vertical = 3 + +[node name="Tray" parent="CanvasLayer/HBoxContainer" instance=ExtResource("3_u4wpj")] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 0.1 @@ -0,0 +1,15 @@ +extends VBoxContainer + + +var TrayItemScene = preload("res://TrayItem.tscn") + + +# Called when the node enters the scene tree for the first time. +func _ready(): + for i in range(5): + add_item() + + +func add_item(): + var tray_item = TrayItemScene.instantiate() + %Items.add_child(tray_item) diff --git a/Tray.tscn b/Tray.tscn new file mode 100644 index 0000000..18f8310 --- /dev/null +++ b/Tray.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://3vuctgbcjqi7"] + +[ext_resource type="Script" path="res://Tray.gd" id="1_lo4w7"] + +[node name="Tray" type="VBoxContainer"] +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -80.0 +grow_horizontal = 0 +grow_vertical = 2 +size_flags_vertical = 3 +script = ExtResource("1_lo4w7") + +[node name="ScrollContainer" type="ScrollContainer" parent="."] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Items" type="VBoxContainer" parent="ScrollContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(80, 0) +layout_mode = 2 +size_flags_vertical = 3 diff --git a/TrayItem.gd b/TrayItem.gd new file mode 100644 index 0000000..12f7041 --- /dev/null +++ b/TrayItem.gd @@ -0,0 +1,18 @@ +class_name TrayItem +extends Control + + +@export_file("*.tscn") var object_path: String +@onready var object: BuilderObject = load(object_path).instantiate() + +var preview: BuilderObject + + +func _on_gui_input(event: InputEvent): + if event.is_action_pressed("drag_start"): + preview = object.duplicate() + preview.drag_start() + get_tree().current_scene.add_child(preview) + if event.is_action_released("drag_start"): + preview.drag_end() + preview = null diff --git a/TrayItem.tscn b/TrayItem.tscn new file mode 100644 index 0000000..af5f535 --- /dev/null +++ b/TrayItem.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=2 format=3 uid="uid://0hxby7k5m7b0"] + +[ext_resource type="Script" path="res://TrayItem.gd" id="1_kkc4o"] + +[node name="TrayItem" type="VBoxContainer"] +offset_right = 40.0 +offset_bottom = 23.0 +script = ExtResource("1_kkc4o") +object_path = "res://Objects/BuilderObject.tscn" + +[node name="Label" type="Label" parent="."] +layout_mode = 2 +text = "Bank" + +[connection signal="gui_input" from="." to="." method="_on_gui_input"] diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..3fe4f4a --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ +<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z" fill="#478cbf"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg> diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..a966c94 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://djasmoqj87h1r" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..def1ff9 --- /dev/null +++ b/project.godot @@ -0,0 +1,29 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="CityBuilder" +run/main_scene="res://Start.tscn" +config/features=PackedStringArray("4.2", "GL Compatibility") +config/icon="res://icon.svg" + +[input] + +drag_start={ +"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":1,"position":Vector2(106, 14),"global_position":Vector2(110, 55),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" |