From 62b688f83d8b3abc2d47a5afac6b98eec93ed707 Mon Sep 17 00:00:00 2001 From: Ententerminator Date: Sun, 2 Feb 2020 11:03:21 +0100 Subject: [PATCH 1/3] 2nd try main menu push --- UI/MainMenu.gd | 19 +++++++++++++++ UI/MainMenu.tscn | 61 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 UI/MainMenu.gd diff --git a/UI/MainMenu.gd b/UI/MainMenu.gd new file mode 100644 index 0000000..89daa78 --- /dev/null +++ b/UI/MainMenu.gd @@ -0,0 +1,19 @@ +extends Control + +export(NodePath) var startPath + +var _start_button + +signal body_build() + +func _ready(): + _start_button = get_node(startPath) as Button + + +func _on_Start_pressed(): + emit_signal("body_build") + + +func _on_Exit_pressed(): + get_tree().quit() + diff --git a/UI/MainMenu.tscn b/UI/MainMenu.tscn index 9f7e149..ad2f084 100644 --- a/UI/MainMenu.tscn +++ b/UI/MainMenu.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] +[ext_resource path="res://UI/MainMenu.gd" type="Script" id=1] [ext_resource path="res://Resources/Fonts/MenuHeader.tres" type="DynamicFont" id=2] [ext_resource path="res://Resources/Fonts/MenuTextFont.tres" type="DynamicFont" id=3] [ext_resource path="res://Resources/Styles/ButtonHoverStyle.tres" type="StyleBox" id=4] @@ -9,9 +10,11 @@ [node name="MainMenu" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } +startPath = NodePath("MarginContainer2/VBoxContainer/Start") [node name="MarginContainer" type="MarginContainer" parent="."] anchor_left = 0.5 @@ -32,15 +35,17 @@ margin_bottom = 600.0 [node name="GameName" type="Label" parent="MarginContainer/VBoxContainer"] margin_right = 1024.0 -margin_bottom = 250.0 +margin_bottom = 298.0 rect_min_size = Vector2( 0, 250 ) +size_flags_horizontal = 3 +size_flags_vertical = 3 custom_fonts/font = ExtResource( 2 ) -text = "Excrements!" +text = "D-d-d-d-d-duell" align = 1 valign = 2 [node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer"] -margin_top = 254.0 +margin_top = 302.0 margin_right = 1024.0 margin_bottom = 600.0 size_flags_horizontal = 3 @@ -49,13 +54,25 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer"] -margin_left = 412.0 -margin_top = 104.0 -margin_right = 612.0 -margin_bottom = 242.0 +[node name="MarginContainer2" type="MarginContainer" parent="."] +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -100.0 +margin_top = -201.0 +margin_right = 100.0 +__meta__ = { +"_edit_use_anchors_": false +} -[node name="Start" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/VBoxContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer2"] +margin_right = 200.0 +margin_bottom = 201.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Start" type="Button" parent="MarginContainer2/VBoxContainer"] margin_right = 200.0 margin_bottom = 67.0 rect_min_size = Vector2( 200, 25 ) @@ -68,10 +85,19 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Exit" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/VBoxContainer"] +[node name="SpacerDots2" type="Control" parent="MarginContainer2/VBoxContainer"] margin_top = 71.0 margin_right = 200.0 -margin_bottom = 138.0 +margin_bottom = 91.0 +rect_min_size = Vector2( 0, 20 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Exit" type="Button" parent="MarginContainer2/VBoxContainer"] +margin_top = 95.0 +margin_right = 200.0 +margin_bottom = 162.0 rect_min_size = Vector2( 200, 25 ) custom_styles/hover = ExtResource( 4 ) custom_styles/pressed = ExtResource( 5 ) @@ -81,3 +107,14 @@ text = "Disenjoy" __meta__ = { "_edit_use_anchors_": false } + +[node name="SpacerDots" type="Control" parent="MarginContainer2/VBoxContainer"] +margin_top = 166.0 +margin_right = 200.0 +margin_bottom = 201.0 +rect_min_size = Vector2( 0, 35 ) +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="MarginContainer2/VBoxContainer/Start" to="." method="_on_Start_pressed"] +[connection signal="pressed" from="MarginContainer2/VBoxContainer/Exit" to="." method="_on_Exit_pressed"] From 508b6d1fcdb101f1786261761293a235dfce6e23 Mon Sep 17 00:00:00 2001 From: Leon Palluch Date: Sun, 2 Feb 2020 11:15:30 +0100 Subject: [PATCH 2/3] starting with main menu --- Controllers/GameStateController.gd | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Controllers/GameStateController.gd b/Controllers/GameStateController.gd index e0b7687..4b193df 100644 --- a/Controllers/GameStateController.gd +++ b/Controllers/GameStateController.gd @@ -1,12 +1,15 @@ extends Node +const _main_menu_path = "res://UI/MainMenu.tscn" const _body_build_path = "res://BodyConfig/bodyBuilderMenu.tscn" const _fighting_path = "res://Ingame/Testing.tscn" const _win_screen_path = "res://UI/WinScreen.tscn" +var _main_menu_scene var _body_build_scene var _fighting_scene var _win_screen_scene + var _bodies : Array var _body_count = 0 var _body_positions = [Vector3(0, 15, -30), Vector3(0, 15, 30), Vector3(-30, 15, 0), Vector3(30, 15, 0)] @@ -14,15 +17,17 @@ var _body_positions = [Vector3(0, 15, -30), Vector3(0, 15, 30), Vector3(-30, 15, func _ready(): InGameState.player_count = 2 - _prep_scene("body_build") - _prep_scene("fight_scene") - _prep_scene("win_screen") + _prep_scene("main_menu") - _switch_scene(_body_build_scene, "body_build") + _switch_scene(_main_menu_scene, "main_menu") func _prep_scene(scene_name) -> Node: - if scene_name == "body_build": + if scene_name == "main_menu": + _main_menu_scene = preload(_main_menu_path).instance() + _main_menu_scene.connect("body_build", self, "_switch_to_body_build") + return _main_menu_scene + elif scene_name == "body_build": _body_build_scene = preload(_body_build_path).instance() _body_build_scene.connect("start_fight", self, "_switch_to_fighting") return _body_build_scene @@ -86,3 +91,4 @@ func _switch_to_fighting(torso): func _switch_to_body_build(): _switch_scene(_body_build_scene, "body_build") + _body_build_scene.change_count_ui() From c3e127aa7c73932dbc1032aab27d40fd7f142def Mon Sep 17 00:00:00 2001 From: mathias Date: Sun, 2 Feb 2020 11:27:37 +0100 Subject: [PATCH 3/3] New gravity and impulses for the torso. --- BodyParts/BodyBase/BodyBase.gd | 10 +++++++--- BodyParts/BodyBase/BodyBase.tscn | 2 ++ BodyParts/HumanLeg.gd | 2 +- Ingame/Arena.tscn | 8 ++++---- Ingame/Testing.tscn | 2 ++ project.godot | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/BodyParts/BodyBase/BodyBase.gd b/BodyParts/BodyBase/BodyBase.gd index 691e7cd..567b71d 100644 --- a/BodyParts/BodyBase/BodyBase.gd +++ b/BodyParts/BodyBase/BodyBase.gd @@ -11,10 +11,14 @@ var current_angle : float func on_ingame(): ground = get_parent().get_node("Arena").get_node("ground") ingame = true + axis_lock_linear_x = true -# Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if ingame: - current_angle = translation.angle_to(ground.translation) - print(current_angle) + current_angle = ((-transform.basis.z).angle_to(ground.transform.basis.y)) + + var rot_vector = (-transform.basis.z).cross(ground.transform.basis.y) + + if current_angle > 0.2: + apply_torque_impulse(rot_vector * current_angle * 14) diff --git a/BodyParts/BodyBase/BodyBase.tscn b/BodyParts/BodyBase/BodyBase.tscn index 4169730..e0962fb 100644 --- a/BodyParts/BodyBase/BodyBase.tscn +++ b/BodyParts/BodyBase/BodyBase.tscn @@ -12,6 +12,8 @@ height = 1.48749 "Player", ]] transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 ) +mass = 1.5 +gravity_scale = 1.5 script = ExtResource( 1 ) [node name="TorsoCollider" type="CollisionShape" parent="."] diff --git a/BodyParts/HumanLeg.gd b/BodyParts/HumanLeg.gd index 3a0d0bf..e292d97 100644 --- a/BodyParts/HumanLeg.gd +++ b/BodyParts/HumanLeg.gd @@ -22,7 +22,7 @@ func action(): func push(body): # We multiply by 0.1 because we only want it to spin slightly, it should mostly go up var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5 - var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 5.0 + var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 10.0 base.apply_impulse(offset, direction) diff --git a/Ingame/Arena.tscn b/Ingame/Arena.tscn index 1f78ed9..941ab90 100644 --- a/Ingame/Arena.tscn +++ b/Ingame/Arena.tscn @@ -58,7 +58,7 @@ rotation_mode = 4 transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0 ) [node name="PathFollow3" type="PathFollow" parent="Path"] -transform = Transform( 0.0525302, 0, 0.998617, 0, 1, 0, -0.998619, 0, 0.0525301, 1.77306, 0, -55.9514 ) +transform = Transform( 0.0525302, 0, 0.998617, 0, 1, 0, -0.998619, 0, 0.05253, 1.77306, 0, -55.9514 ) offset = 57.5 rotation_mode = 4 @@ -66,7 +66,7 @@ rotation_mode = 4 transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0 ) [node name="PathFollow4" type="PathFollow" parent="Path"] -transform = Transform( 0.412628, 0, 0.910899, 0, 1, 0, -0.9109, 0, 0.412628, 25.6454, 0, -49.4766 ) +transform = Transform( 0.412629, 0, 0.910899, 0, 1, 0, -0.9109, 0, 0.412628, 25.6454, 0, -49.4766 ) offset = 82.37 rotation_mode = 4 @@ -106,7 +106,7 @@ rotation_mode = 4 transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0 ) [node name="PathFollow9" type="PathFollow" parent="Path"] -transform = Transform( 0.760079, -6.86382e-07, -0.64983, 7.11586e-07, 1, -2.23934e-07, 0.649831, -2.92203e-07, 0.760078, 48.2851, 2.0276e-05, 59.2494 ) +transform = Transform( 0.760079, -6.86382e-07, -0.64983, 7.11587e-07, 1, -2.23935e-07, 0.649831, -2.92203e-07, 0.760078, 48.2851, 2.0276e-05, 59.2494 ) offset = 206.72 rotation_mode = 4 @@ -170,7 +170,7 @@ rotation_mode = 4 transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0 ) [node name="PathFollow17" type="PathFollow" parent="Path"] -transform = Transform( -0.817611, 3.47972e-07, 0.57577, 4.25596e-07, 1, 0, -0.575771, 2.45046e-07, -0.817609, -57.8267, 0, -24.3573 ) +transform = Transform( -0.817611, 3.47972e-07, 0.57577, 4.25597e-07, 1, 0, -0.575771, 2.45046e-07, -0.817609, -57.8267, 0, -24.3573 ) offset = 405.68 rotation_mode = 4 diff --git a/Ingame/Testing.tscn b/Ingame/Testing.tscn index 3513bd2..f14794b 100644 --- a/Ingame/Testing.tscn +++ b/Ingame/Testing.tscn @@ -17,3 +17,5 @@ script = ExtResource( 6 ) [node name="Camera" type="Camera" parent="CameraFocus"] transform = Transform( -4.2222e-08, -0.707107, 0.707107, -1.13133e-08, 0.707107, 0.707107, -1, 2.18557e-08, -3.78552e-08, 19, 17, -2 ) + +[editable path="Arena"] diff --git a/project.godot b/project.godot index e1ed397..baa8981 100644 --- a/project.godot +++ b/project.godot @@ -9,7 +9,7 @@ config_version=4 _global_script_classes=[ { -"base": "Spatial", +"base": "RigidBody", "class": "BodyBase", "language": "GDScript", "path": "res://BodyParts/BodyBase/BodyBase.gd"