Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Jul 26, 2024
1 parent ec27c24 commit 1404575
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
14 changes: 13 additions & 1 deletion game/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 9 additions & 2 deletions game/src/level-editor/LevelEditor.tscn
Original file line number Diff line number Diff line change
@@ -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 )
Expand All @@ -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
Expand Down
33 changes: 30 additions & 3 deletions game/src/level-editor/objects-selector/ObjectsSelector.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 1404575

Please sign in to comment.