From 140457508b3e393eb93156c3b9ad8ca541d0b857 Mon Sep 17 00:00:00 2001 From: Simon Dalvai Date: Fri, 26 Jul 2024 20:17:39 +0200 Subject: [PATCH] format --- game/project.godot | 14 +++++++- game/src/level-editor/LevelEditor.tscn | 11 +++++-- .../objects-selector/ObjectsSelector.gd | 33 +++++++++++++++++-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/game/project.godot b/game/project.godot index bf09fb9..101923a 100644 --- a/game/project.godot +++ b/game/project.godot @@ -13,9 +13,21 @@ _global_script_classes=[ { "class": "Ball", "language": "GDScript", "path": "res://src/actors/ball/base-ball/Ball.gd" +}, { +"base": "Reference", +"class": "LevelConfig", +"language": "GDScript", +"path": "res://src/level-editor/level-config/level_config.gd" +}, { +"base": "Reference", +"class": "ObjectConfig", +"language": "GDScript", +"path": "res://src/level-editor/level-config/object_config.gd" } ] _global_script_class_icons={ -"Ball": "" +"Ball": "", +"LevelConfig": "", +"ObjectConfig": "" } [application] diff --git a/game/src/level-editor/LevelEditor.tscn b/game/src/level-editor/LevelEditor.tscn index b1f469f..e5ac74e 100644 --- a/game/src/level-editor/LevelEditor.tscn +++ b/game/src/level-editor/LevelEditor.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://src/levels/base-level/base-3d/Base3D.tscn" type="PackedScene" id=1] [ext_resource path="res://src/level-editor/LevelEditor.gd" type="Script" id=2] [ext_resource path="res://src/actors/ball/starter-ball/Ball.tscn" type="PackedScene" id=3] [ext_resource path="res://src/actors/bin/Bin.tscn" type="PackedScene" id=4] [ext_resource path="res://src/level-editor/objects-selector/ObjectsSelector.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/actors/star/Star.tscn" type="PackedScene" id=6] [node name="LevelEditor" type="Spatial"] script = ExtResource( 2 ) @@ -14,13 +15,19 @@ script = ExtResource( 2 ) [node name="Bin" parent="." instance=ExtResource( 4 )] [node name="Ball" parent="." instance=ExtResource( 3 )] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 16.8553, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 29.9642, 0 ) [node name="Objects" type="Spatial" parent="."] [node name="ObjectsSelector" parent="." instance=ExtResource( 5 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 18.986, 4 ) +[node name="Star1" parent="." instance=ExtResource( 6 )] +transform = Transform( 0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0.016408, 21.0489, 0 ) + +[node name="Star2" parent="." instance=ExtResource( 6 )] +transform = Transform( 0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0.016408, 10.3808, 0 ) + [node name="HUD" type="Control" parent="."] pause_mode = 2 anchor_right = 1.0 diff --git a/game/src/level-editor/objects-selector/ObjectsSelector.gd b/game/src/level-editor/objects-selector/ObjectsSelector.gd index 3a850b5..a7b5e9d 100644 --- a/game/src/level-editor/objects-selector/ObjectsSelector.gd +++ b/game/src/level-editor/objects-selector/ObjectsSelector.gd @@ -10,6 +10,9 @@ var center: Vector3 = Vector3(0, 0, 0) var camera: Camera +var is_scrolling: bool = false +var start_scroll: Vector3 + func _ready() -> void: camera = get_node("../Base/Camera") @@ -21,16 +24,14 @@ func _ready() -> void: object.translation.x += i * 8 add_child(object) - # TODO scale if abs(object.translation.x) > 0: object.scale.x = 0.5 object.scale.y = 0.5 object.scale.z = 0.5 - if object.has_method("fade_in"): object.fade_in() - + func _input(event: InputEvent) -> void: @@ -43,4 +44,30 @@ func _input(event: InputEvent) -> void: var plane: Plane = Plane(Vector3(0, 0, 10), 0) var pos: Vector3 = plane.intersects_ray(camera.project_ray_origin(mouse_position), camera.project_ray_normal(mouse_position)) # TODO scroll + + if not is_scrolling: + start_scroll = pos + is_scrolling = true + + _scroll_objects(pos) + +# else: +# start_scroll = Vector3.ZERO +# is_scrolling = false + + +func _scroll_objects(pos: Vector3) -> void: + var delta_x: float = start_scroll.x - pos.x +# print(delta_x) +# print(pos) +# print(start_scroll) + for i in objects.size(): + var object: Spatial = objects[i] + object.translation.x += delta_x + + # scale + if abs(object.translation.x) > 0: + object.scale.x = 0.5 + object.scale.y = 0.5 + object.scale.z = 0.5