diff --git a/gears/geep.gd b/gears/geep.gd index b08f60a..fe59a81 100644 --- a/gears/geep.gd +++ b/gears/geep.gd @@ -9,51 +9,23 @@ func use_basis(): # multiplier of player's speed const speed = 2 -# how far the vehicle lifts the player off the ground -const lift = 2 -var box = null var driver = null var active = false -func init_driver(player): +func on_use(player): driver = player - if not box: - box = Vector3(driver.get_node("CollisionShape3D").shape.size) - -func mount(): + if active: + active = false + position = Vector3.ZERO + driver.message("You are no longer driving a Geep") + return active = true position = Vector3(-driver.get_node("Pivot/Container").position) - position.y += 1 - driver.message( - "Press [%s] to exit the Geep" - % Util.input_action_string("gear_use")) - driver.get_node("CameraGimbal").position.y += lift - driver.get_node("Pivot/Mesh").position.y += lift - driver.get_node("CollisionShape3D").shape.size = $GearMesh/Vehicle/CollisionShape3D.shape.size - driver.protected = true - driver.suspended = true - -func unmount(): - active = false - position = Vector3.ZERO - driver.message("") - driver.get_node("CameraGimbal").position = Vector3.ZERO - driver.get_node("Pivot/Mesh").position = Vector3.ZERO - driver.get_node("CollisionShape3D").shape.size = box - driver.protected = false - driver.suspended = false - -func on_use(player): - init_driver(player) - if active: - unmount() - else: - mount() + driver.message("You are now driving a Geep") func on_unequip(player): - init_driver(player) - unmount() + active = false func _physics_process(_delta): if not active: diff --git a/gears/geep.tscn b/gears/geep.tscn index 481e2bb..b983d7b 100644 --- a/gears/geep.tscn +++ b/gears/geep.tscn @@ -1,33 +1,30 @@ [gd_scene load_steps=10 format=3 uid="uid://d3k7b6o56ue5k"] [ext_resource type="Script" uid="uid://fljad0m3jlt0" path="res://gears/geep.gd" id="1_8skgp"] -[ext_resource type="Material" uid="uid://dpacu3e7vsks5" path="res://gears/geep_body.tres" id="2_rhiad"] -[ext_resource type="Material" uid="uid://bt5aat64e478k" path="res://gears/geep_wheel.tres" id="3_lrfuo"] -[sub_resource type="BoxShape3D" id="BoxShape3D_lrfuo"] -size = Vector3(3, 3, 6) - -[sub_resource type="BoxMesh" id="BoxMesh_rhiad"] -material = ExtResource("2_rhiad") +[sub_resource type="BoxShape3D" id="BoxShape3D_8skgp"] size = Vector3(3, 0.5, 6) -[sub_resource type="BoxMesh" id="BoxMesh_kyikt"] -material = ExtResource("2_rhiad") +[sub_resource type="BoxMesh" id="BoxMesh_rhiad"] +size = Vector3(3, 0.5, 6) + +[sub_resource type="BoxShape3D" id="BoxShape3D_lrfuo"] size = Vector3(0.5, 1.75, 6) -[sub_resource type="BoxMesh" id="BoxMesh_wm067"] -material = ExtResource("2_rhiad") +[sub_resource type="BoxMesh" id="BoxMesh_kyikt"] +size = Vector3(0.5, 1.75, 6) + +[sub_resource type="BoxShape3D" id="BoxShape3D_vjakw"] size = Vector3(3, 2, 2.5) -[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"] -material = ExtResource("2_rhiad") +[sub_resource type="BoxMesh" id="BoxMesh_wm067"] +size = Vector3(3, 2, 2.5) + +[sub_resource type="BoxShape3D" id="BoxShape3D_rhiad"] size = Vector3(3, 2, 0.5) -[sub_resource type="CylinderMesh" id="CylinderMesh_lrfuo"] -material = ExtResource("3_lrfuo") -top_radius = 1.0 -bottom_radius = 1.0 -height = 0.25 +[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"] +size = Vector3(3, 2, 0.5) [node name="Gear" type="Node3D"] rotation_edit_mode = 2 @@ -42,46 +39,44 @@ one_shot = true transform = Transform3D(1, 0, 0, 0, 1.0000001, 0, 0, 0, 1.0000001, 0, 0, 0) collision_layer = 4 -[node name="CollisionShape3D" type="CollisionShape3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0) -shape = SubResource("BoxShape3D_lrfuo") +[node name="BaseShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] +shape = SubResource("BoxShape3D_8skgp") [node name="BaseMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9997004, 0) mesh = SubResource("BoxMesh_rhiad") +[node name="LeftSideShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] +transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 1.1249999, 0) +shape = SubResource("BoxShape3D_lrfuo") + [node name="LeftSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 2.1247003, 0) +transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 1.1249999, 0) mesh = SubResource("BoxMesh_kyikt") skeleton = NodePath("") +[node name="RightSideShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] +transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 1.1249999, 0) +shape = SubResource("BoxShape3D_lrfuo") + [node name="RightSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 2.1247003, 0) +transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 1.1249999, 0) mesh = SubResource("BoxMesh_kyikt") skeleton = NodePath("") +[node name="BonnetShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.75) +shape = SubResource("BoxShape3D_vjakw") + [node name="BonnetMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, -1.75) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.75) mesh = SubResource("BoxMesh_wm067") +[node name="TailgateShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.75) +shape = SubResource("BoxShape3D_rhiad") + [node name="TailgateMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, 2.75) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.75) mesh = SubResource("BoxMesh_lrfuo") -[node name="WheelFLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, 2) -mesh = SubResource("CylinderMesh_lrfuo") - -[node name="WheelFRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, 2) -mesh = SubResource("CylinderMesh_lrfuo") - -[node name="WheelBLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, -2) -mesh = SubResource("CylinderMesh_lrfuo") - -[node name="WheelBRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, -2) -mesh = SubResource("CylinderMesh_lrfuo") - [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/main.tscn b/main.tscn index cd73495..5200292 100644 --- a/main.tscn +++ b/main.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=9 format=3 uid="uid://eiaw4xbs3suk"] +[gd_scene load_steps=10 format=3 uid="uid://eiaw4xbs3suk"] [ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"] [ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"] [ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"] [ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"] -[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"] +[ext_resource type="PackedScene" uid="uid://c117buhmmkvkt" path="res://gears/ball.tscn" id="5_7mycd"] +[ext_resource type="PackedScene" uid="uid://d3k7b6o56ue5k" path="res://gears/geep.tscn" id="6_272bh"] [sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"] size = Vector3(100, 2, 100) @@ -18,7 +19,6 @@ albedo_color = Color(0.49454, 0.79, 0.4424, 1) [node name="Main" type="Node3D"] [node name="Player" parent="." instance=ExtResource("1_ig7tw")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) [node name="Baseplate" type="StaticBody3D" parent="."] @@ -48,8 +48,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 7, 0) [node name="Killbrick" parent="." instance=ExtResource("1_h2yge")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -40, 1.5, -40) -[node name="GearPickup" parent="." instance=ExtResource("3_lquwl")] +[node name="BallPickup" parent="." instance=ExtResource("3_lquwl")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21) -[node name="Gear" parent="GearPickup" instance=ExtResource("4_7mycd")] -transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0.5, 0) +[node name="Gear" parent="BallPickup" instance=ExtResource("5_7mycd")] + +[node name="GeepPickup" parent="." instance=ExtResource("3_lquwl")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, -20) +one_shot = true + +[node name="Gear" parent="GeepPickup" instance=ExtResource("6_272bh")] diff --git a/player/player.gd b/player/player.gd index 4b712e6..ae6067b 100644 --- a/player/player.gd +++ b/player/player.gd @@ -10,8 +10,6 @@ const gear_slots = ["1", "2", "3"] var starting_gear = preload("res://gears/gear.tscn") -var dead = false -var protected = false var suspended = false var direction = Vector3.ZERO var target_velocity = Vector3.ZERO @@ -47,8 +45,6 @@ func message(string): # State functions func harm(hp): - if protected: - return assert(hp >= 0) _health -= hp make_hud() @@ -61,8 +57,7 @@ func heal(hp): func health(): return _health -func _die(): - dead = true +func die(): suspended = true visible = false $HUD.visible = false @@ -70,24 +65,18 @@ func _die(): # strip gears for gear in $Backpack.get_children(): gear.queue_free() - if has_node("Pivot/Container/Gear"): - $Pivot/Container/Gear.unequip(self) - $Pivot/Container/Gear.queue_free() + $Pivot/Container/Gear.unequip(self) + $Pivot/Container/Gear.queue_free() $RespawnTimer.start() message("Le gone") -func die(): - if protected: - return - _die() - func respawn(): position = Vector3(spawn) $CameraGimbal.reset() _health = 100 visible = true - dead = false + suspended = false # add starting gear var gear = starting_gear.instantiate() @@ -195,17 +184,16 @@ func do_movement(delta): var mx = 0 var mz = 0 - if not suspended: - if Input.is_action_pressed("move_forward"): - mz -= 1 - if Input.is_action_pressed("move_back"): - mz += 1 - if Input.is_action_pressed("move_left"): - mx -= 1 - if Input.is_action_pressed("move_right"): - mx += 1 - if Input.is_action_pressed("jump") and is_on_floor(): - target_velocity.y = jump_power + if Input.is_action_pressed("move_forward"): + mz -= 1 + if Input.is_action_pressed("move_back"): + mz += 1 + if Input.is_action_pressed("move_left"): + mx -= 1 + if Input.is_action_pressed("move_right"): + mx += 1 + if Input.is_action_pressed("jump") and is_on_floor(): + target_velocity.y = jump_power if !(mx == 0 and mz == 0): move_player(mx, mz) @@ -238,11 +226,11 @@ func _ready(): respawn() func _physics_process(delta): - if dead: - return - if health() < 1 or position.y <= -1000: - _die() + die() + + if suspended: + return # Backpack keys do_backpack_keys() diff --git a/player/player.tscn b/player/player.tscn index d87afa8..10a0f29 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -58,9 +58,7 @@ shape = SubResource("BoxShape3D_onrkg") [node name="Pivot" type="Node3D" parent="."] -[node name="Mesh" type="Node3D" parent="Pivot"] - -[node name="MeshInstance3D" type="MeshInstance3D" parent="Pivot/Mesh"] +[node name="PlayerMesh" type="MeshInstance3D" parent="Pivot"] transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, -100, 0) mesh = SubResource("ArrayMesh_sweqy") skeleton = NodePath("")