diff --git a/characters/teddy/Teddy.gd b/characters/teddy/Teddy.gd index c5aaf7e..fecac23 100644 --- a/characters/teddy/Teddy.gd +++ b/characters/teddy/Teddy.gd @@ -45,7 +45,20 @@ func _physics_process(delta): # Add the gravity. if not is_on_floor(): velocity.y -= gravity * delta - + # This variable gets set my the death scene, so we know the player needs to be respawned + if Global.playerPleaseRespawn == true: + position.x = 0 #Set player X + position.y = 1 #Set player Y + position.z = 0 #Set player Z + Global.playerPleaseRespawn = false # So we don't get stuck in a loop + Global.playerDead = false #Reset playerDead + Global.playerAlive = true #Reset playerAlive + + ## If player falls off the map, kill them! + if velocity.y < Global.playerYDeath: + Global.player_dead() + + # Handle Jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY @@ -55,7 +68,12 @@ func _physics_process(delta): var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward") var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() if Input.is_action_pressed("sprint"): - SPEED = 10.0 + if Global.fatigue > 5: + SPEED = 10.0 + if Global.fatigue < 5: + SPEED = 2.0 + elif Global.fatigue > 5: + SPEED = 5.0 if Input.is_action_just_released("sprint"): SPEED = 5.0 if direction: diff --git a/objects/Bullet/Bullet.tscn b/objects/Bullet/Bullet.tscn index 62cf739..44aabff 100644 --- a/objects/Bullet/Bullet.tscn +++ b/objects/Bullet/Bullet.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://Objects/Bullet/Bullet.gd" id="1"] [ext_resource type="PackedScene" uid="uid://pni78bumc5f5" path="res://objects/Bullet/model/Bullet.dae" id="2"] -[sub_resource type="BoxShape3D" id="BoxShape3D_chxfq"] +[sub_resource type="BoxShape3D" id="BoxShape3D_tfwph"] size = Vector3(0.40456, 0.406836, 0.393048) [node name="Bullet" type="Area3D" groups=["bullet"]] @@ -12,7 +12,7 @@ script = ExtResource("1") [node name="CollisionShape3D" type="CollisionShape3D" parent="." groups=["bullet"]] transform = Transform3D(0.957696, 0, 0, 0, 1, 0, 0, 0, 1.66763, 0, 0, -0.295843) -shape = SubResource("BoxShape3D_chxfq") +shape = SubResource("BoxShape3D_tfwph") [node name="Bullet" parent="." instance=ExtResource("2")] transform = Transform3D(0.200224, 0, 0, 0, -8.75207e-09, 0.200224, 0, -0.200224, -8.75207e-09, 0, 0, 0) diff --git a/objects/Bullet/model/Bullet.dae.import b/objects/Bullet/model/Bullet.dae.import index 77ea3a6..de2679f 100644 --- a/objects/Bullet/model/Bullet.dae.import +++ b/objects/Bullet/model/Bullet.dae.import @@ -4,12 +4,12 @@ importer="scene" importer_version=1 type="PackedScene" uid="uid://pni78bumc5f5" -path="res://.godot/imported/Bullet.dae-5bbc570d18bdc3c3b39c8ef588b2ee68.scn" +path="res://.godot/imported/Bullet.dae-6d158ce5286c9575dbf7d21142c4524e.scn" [deps] -source_file="res://objects/Bullet/model/Bullet.dae" -dest_files=["res://.godot/imported/Bullet.dae-5bbc570d18bdc3c3b39c8ef588b2ee68.scn"] +source_file="res://Objects/Bullet/model/Bullet.dae" +dest_files=["res://.godot/imported/Bullet.dae-6d158ce5286c9575dbf7d21142c4524e.scn"] [params] diff --git a/scenes/HUD.tscn b/scenes/HUD.tscn new file mode 100644 index 0000000..82d4be2 --- /dev/null +++ b/scenes/HUD.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=2 format=3 uid="uid://ytbacsuahxie"] + +[ext_resource type="Script" path="res://scripts/HUD.gd" id="1_mqiiw"] + +[node name="HUD" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_mqiiw") + +[node name="Health" type="ProgressBar" parent="."] +modulate = Color(0.890196, 0.137255, 0.0156863, 1) +layout_mode = 0 +offset_left = 20.0 +offset_top = 562.0 +offset_right = 165.0 +offset_bottom = 589.0 +value = 100.0 + +[node name="Fatigue" type="ProgressBar" parent="."] +modulate = Color(1, 1, 0, 1) +layout_mode = 0 +offset_left = 20.0 +offset_top = 602.0 +offset_right = 165.0 +offset_bottom = 629.0 +value = 100.0 diff --git a/scenes/death.tscn b/scenes/death.tscn new file mode 100644 index 0000000..48dc4a3 --- /dev/null +++ b/scenes/death.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=2 format=3 uid="uid://dt3mxjsi3yxrq"] + +[ext_resource type="Script" path="res://scripts/death.gd" id="1_we0rj"] + +[node name="death" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_we0rj") + +[node name="deathBar" type="ProgressBar" parent="."] +modulate = Color(0.894118, 0, 0.00392157, 1) +layout_mode = 0 +offset_left = 319.0 +offset_top = 295.0 +offset_right = 817.0 +offset_bottom = 367.0 + +[node name="badnewsman" type="Label" parent="."] +layout_mode = 0 +offset_left = 303.0 +offset_top = 208.0 +offset_right = 837.0 +offset_bottom = 286.0 +text = "Uhhhh I'm sorry to embarrass you but you're dead... I'm sorry to be the bearer of bad news. Maybe you'll do better in your next life huh? You'll be revived once this bar gets to 100%" +horizontal_alignment = 1 +autowrap_mode = 2 diff --git a/scenes/hostmenu.tscn b/scenes/hostmenu.tscn new file mode 100644 index 0000000..1987c50 --- /dev/null +++ b/scenes/hostmenu.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=3 uid="uid://cv5bctupikqe7"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vwth"] +bg_color = Color(0.2, 0.2, 0.2, 1) + +[node name="hostmenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Panel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -272.0 +offset_top = -156.0 +offset_right = 268.0 +offset_bottom = 134.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_8vwth") diff --git a/scenes/mainmenu.tscn b/scenes/mainmenu.tscn index f372c42..7a82143 100644 --- a/scenes/mainmenu.tscn +++ b/scenes/mainmenu.tscn @@ -13,28 +13,36 @@ script = ExtResource("1_w5lhm") [node name="Button" type="Button" parent="."] layout_mode = 0 -offset_left = 494.0 -offset_top = 196.0 -offset_right = 685.0 -offset_bottom = 259.0 +offset_left = 498.0 +offset_top = 179.0 +offset_right = 689.0 +offset_bottom = 242.0 text = "PLAY" +[node name="Button4" type="Button" parent="."] +offset_left = 498.0 +offset_top = 248.0 +offset_right = 689.0 +offset_bottom = 311.0 +text = "MULTIPLAYER" + [node name="Button2" type="Button" parent="."] layout_mode = 0 -offset_left = 496.0 -offset_top = 279.0 -offset_right = 687.0 -offset_bottom = 342.0 +offset_left = 498.0 +offset_top = 316.0 +offset_right = 689.0 +offset_bottom = 379.0 text = "SETTINGS" [node name="Button3" type="Button" parent="."] layout_mode = 0 -offset_left = 495.0 -offset_top = 358.0 -offset_right = 686.0 -offset_bottom = 421.0 +offset_left = 498.0 +offset_top = 384.0 +offset_right = 689.0 +offset_bottom = 447.0 text = "EXIT" [connection signal="pressed" from="Button" to="." method="_on_button_pressed"] +[connection signal="pressed" from="Button4" to="." method="_on_button_4_pressed"] [connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"] [connection signal="pressed" from="Button3" to="." method="_on_button_3_pressed"] diff --git a/scenes/multiplayer.tscn b/scenes/multiplayer.tscn new file mode 100644 index 0000000..48e4307 --- /dev/null +++ b/scenes/multiplayer.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=2 format=3 uid="uid://bu0htwo7n3pwa"] + +[ext_resource type="Script" path="res://scripts/multiplayer.gd" id="1_ehfu1"] + +[node name="multiplayer" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ehfu1") + +[node name="playerNameBox" type="LineEdit" parent="."] +layout_mode = 0 +offset_left = 483.0 +offset_top = 579.0 +offset_right = 650.0 +offset_bottom = 622.0 + +[node name="playerLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 360.0 +offset_top = 588.0 +offset_right = 468.0 +offset_bottom = 614.0 +text = "Player Name: " + +[node name="backButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 5.0 +offset_top = 5.0 +offset_right = 93.0 +offset_bottom = 48.0 +text = "BACK" + +[node name="ipBox" type="LineEdit" parent="."] +layout_mode = 0 +offset_left = 341.0 +offset_top = 249.0 +offset_right = 498.0 +offset_bottom = 287.0 + +[node name="joinGameLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 376.0 +offset_top = 180.0 +offset_right = 455.0 +offset_bottom = 206.0 +text = "Join Game" + +[node name="ipLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 244.0 +offset_top = 253.0 +offset_right = 334.0 +offset_bottom = 279.0 +text = "IP Address: " + +[node name="portBox" type="LineEdit" parent="."] +layout_mode = 0 +offset_left = 342.0 +offset_top = 294.0 +offset_right = 414.0 +offset_bottom = 330.0 + +[node name="portLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 291.0 +offset_top = 299.0 +offset_right = 333.0 +offset_bottom = 325.0 +text = "Port: " + +[node name="hostLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 712.0 +offset_top = 181.0 +offset_right = 798.0 +offset_bottom = 207.0 +text = "Host Game" + +[node name="hostButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 694.0 +offset_top = 245.0 +offset_right = 822.0 +offset_bottom = 282.0 +text = "HOST" + +[node name="joinButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 426.0 +offset_top = 295.0 +offset_right = 497.0 +offset_bottom = 330.0 +text = "JOIN" + +[connection signal="pressed" from="backButton" to="." method="_on_button_pressed"] diff --git a/scenes/playground.tscn b/scenes/playground.tscn index be31f35..5728e52 100644 --- a/scenes/playground.tscn +++ b/scenes/playground.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=7 format=3 uid="uid://bpq4yjx2gs3l6"] +[gd_scene load_steps=9 format=3 uid="uid://bpq4yjx2gs3l6"] +[ext_resource type="Script" path="res://scripts/maps/playground.gd" id="1_gtai1"] [ext_resource type="PackedScene" uid="uid://dp1q51kvd8uow" path="res://scenes/Teddy.tscn" id="1_p7gbl"] +[ext_resource type="PackedScene" uid="uid://ytbacsuahxie" path="res://scenes/HUD.tscn" id="2_ggrqc"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ell6n"] sky_top_color = Color(0.870588, 0.894118, 0.92549, 1) @@ -22,6 +24,11 @@ glow_enabled = true data = PackedVector3Array(1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0, -1, 1, 0, -1) [node name="Playground" type="Node3D"] +script = ExtResource("1_gtai1") + +[node name="HUD" parent="." instance=ExtResource("2_ggrqc")] +show_behind_parent = true +mouse_filter = 2 [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_fnphj") @@ -40,4 +47,4 @@ mesh = SubResource("PlaneMesh_gx0jf") shape = SubResource("ConcavePolygonShape3D_qgsp1") [node name="Teddy" parent="." instance=ExtResource("1_p7gbl")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.097358, 1.01166, 0.029713) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, 2.08165e-12) diff --git a/scripts/HUD.gd b/scripts/HUD.gd new file mode 100644 index 0000000..deca7a5 --- /dev/null +++ b/scripts/HUD.gd @@ -0,0 +1,11 @@ +extends Control + +var fatigue = Global.fatigue + +func _ready(): + pass + + +func _process(delta): + fatigue = Global.fatigue + $Fatigue.value = fatigue diff --git a/scripts/death.gd b/scripts/death.gd new file mode 100644 index 0000000..ada770d --- /dev/null +++ b/scripts/death.gd @@ -0,0 +1,17 @@ +extends Node + +var deathTimer = 0 + +func _ready(): + pass + + +func _process(delta): + Global.playerAlive = false + if deathTimer < 100: + deathTimer = deathTimer + 10 * delta + if deathTimer > 100: + deathTimer = 0 + Global.playerPleaseRespawn = true # Used so the Teddy script will know to reset variables and position of the player + self.queue_free() + $deathBar.value = deathTimer diff --git a/scripts/global.gd b/scripts/global.gd index 6156ece..f3be7e8 100644 --- a/scripts/global.gd +++ b/scripts/global.gd @@ -3,3 +3,30 @@ extends Node var mouseSensitivity = 0.01 # Unless otherwise changed by user in settings var playingGame = false var menuOpen = false +var fatigue = 100 +var playerHealth = 100 +var playerDead = false +var playerAlive = true +var playerPleaseRespawn = false +var playerYDeath = -20 +var deathShield = 0 + +func _process(delta): + if Input.is_action_pressed("sprint"): + if fatigue > 0: + fatigue = fatigue - 10 * delta + elif not Input.is_action_pressed("sprint"): + if fatigue < 100: + fatigue = fatigue + 2 * delta + if playerAlive: + deathShield = deathShield - 10 * delta # Make player not killable until the value falls below 0 + +func player_dead(): + playerDead = true + if deathShield <= 0: + deathShield = 50 + if playerAlive: + print("Player be deaddddd brooooooo") + var scene_trs =load("res://scenes/death.tscn") + var scene=scene_trs.instantiate() + add_child(scene) diff --git a/scripts/mainmenu.gd b/scripts/mainmenu.gd index 4bf24c4..005d30d 100644 --- a/scripts/mainmenu.gd +++ b/scripts/mainmenu.gd @@ -5,6 +5,7 @@ extends Control func _ready(): if Global.playingGame == true: $Button.text = "RESUME" + $Button4.text = "MAIN MENU" func _process(delta): @@ -26,3 +27,12 @@ func _on_button_2_pressed(): func _on_button_3_pressed(): get_tree().quit() + + +func _on_button_4_pressed(): + if Global.playingGame == false: + get_tree().change_scene_to_file("res://scenes/multiplayer.tscn") + if Global.playingGame == true: + Global.playingGame = false + Global.menuOpen = false + get_tree().change_scene_to_file("res://scenes/mainmenu.tscn") diff --git a/scripts/maps/playground.gd b/scripts/maps/playground.gd new file mode 100644 index 0000000..cadb72b --- /dev/null +++ b/scripts/maps/playground.gd @@ -0,0 +1,10 @@ +extends Node + + +func _ready(): + Global.playerHealth = 100 + Global.fatigue = 100 + + +func _process(delta): + pass diff --git a/scripts/multiplayer.gd b/scripts/multiplayer.gd new file mode 100644 index 0000000..58505e6 --- /dev/null +++ b/scripts/multiplayer.gd @@ -0,0 +1,13 @@ +extends Node + + +func _ready(): + pass + + +func _process(delta): + pass + + +func _on_button_pressed(): + get_tree().change_scene_to_file("res://scenes/mainmenu.tscn")