From 17716f198bf6b3e4d39d48d0394192a5cb640499 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 11 May 2024 14:52:36 +0200 Subject: initial commit --- .gitattributes | 2 + .gitignore | 2 + Assets/wooden_bench/32x32/bench-backless-white.png | Bin 0 -> 983 bytes .../32x32/bench-backless-white.png.import | 34 ++++++++++++++ Assets/wooden_bench/32x32/bench-backless-wood.png | Bin 0 -> 983 bytes .../32x32/bench-backless-wood.png.import | 34 ++++++++++++++ Assets/wooden_bench/32x32/bench-white.png | Bin 0 -> 771 bytes Assets/wooden_bench/32x32/bench-white.png.import | 34 ++++++++++++++ Assets/wooden_bench/32x32/bench-wood.png | Bin 0 -> 906 bytes Assets/wooden_bench/32x32/bench-wood.png.import | 34 ++++++++++++++ Assets/wooden_bench/palette-bench_white.png | Bin 0 -> 378 bytes Assets/wooden_bench/palette-bench_white.png.import | 34 ++++++++++++++ Assets/wooden_bench/palette-bench_wooden.png | Bin 0 -> 421 bytes .../wooden_bench/palette-bench_wooden.png.import | 34 ++++++++++++++ Objects/BuilderObject.gd | 50 +++++++++++++++++++++ Objects/BuilderObject.tscn | 28 ++++++++++++ Start.tscn | 27 +++++++++++ Tray.gd | 15 +++++++ Tray.tscn | 24 ++++++++++ TrayItem.gd | 18 ++++++++ TrayItem.tscn | 15 +++++++ icon.svg | 1 + icon.svg.import | 37 +++++++++++++++ project.godot | 29 ++++++++++++ 24 files changed, 452 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Assets/wooden_bench/32x32/bench-backless-white.png create mode 100644 Assets/wooden_bench/32x32/bench-backless-white.png.import create mode 100644 Assets/wooden_bench/32x32/bench-backless-wood.png create mode 100644 Assets/wooden_bench/32x32/bench-backless-wood.png.import create mode 100644 Assets/wooden_bench/32x32/bench-white.png create mode 100644 Assets/wooden_bench/32x32/bench-white.png.import create mode 100644 Assets/wooden_bench/32x32/bench-wood.png create mode 100644 Assets/wooden_bench/32x32/bench-wood.png.import create mode 100644 Assets/wooden_bench/palette-bench_white.png create mode 100644 Assets/wooden_bench/palette-bench_white.png.import create mode 100644 Assets/wooden_bench/palette-bench_wooden.png create mode 100644 Assets/wooden_bench/palette-bench_wooden.png.import create mode 100644 Objects/BuilderObject.gd create mode 100644 Objects/BuilderObject.tscn create mode 100644 Start.tscn create mode 100644 Tray.gd create mode 100644 Tray.tscn create mode 100644 TrayItem.gd create mode 100644 TrayItem.tscn create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot 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 new file mode 100644 index 0000000..c0b71e5 Binary files /dev/null and b/Assets/wooden_bench/32x32/bench-backless-white.png differ 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 new file mode 100644 index 0000000..d8cfa94 Binary files /dev/null and b/Assets/wooden_bench/32x32/bench-backless-wood.png differ 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 new file mode 100644 index 0000000..0b1fba5 Binary files /dev/null and b/Assets/wooden_bench/32x32/bench-white.png differ 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 new file mode 100644 index 0000000..c8510df Binary files /dev/null and b/Assets/wooden_bench/32x32/bench-wood.png differ 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 new file mode 100644 index 0000000..4a1d9ea Binary files /dev/null and b/Assets/wooden_bench/palette-bench_white.png differ 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 new file mode 100644 index 0000000..55249d4 Binary files /dev/null and b/Assets/wooden_bench/palette-bench_wooden.png differ 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 diff --git a/Tray.gd b/Tray.gd new file mode 100644 index 0000000..136cf55 --- /dev/null +++ b/Tray.gd @@ -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 @@ + 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" -- cgit v1.2.3