diff --git a/gears/ball.gd b/gears/ball.gd index 67ecd55..fc30219 100644 --- a/gears/ball.gd +++ b/gears/ball.gd @@ -2,6 +2,8 @@ class_name Ball extends "gear.gd" func gear_name(): return "Ball" +func gear_id(): + return 1 func continuous(): return false diff --git a/gears/gear.gd b/gears/gear.gd index 80eeb2e..af79744 100644 --- a/gears/gear.gd +++ b/gears/gear.gd @@ -1,47 +1,43 @@ @icon("./gear.png") class_name Gear extends Node3D +var idle_basis = Basis( + Vector3(1, 0, 0), + Vector3(0, 1, 0), + Vector3(0, 0, 1)) +var use_basis = Basis( + Vector3(1, 0, 0), + Vector3(0, 0, -1), + Vector3(0, 1, 0)) +var pickup_basis = idle_basis + func gear_name(): return "Gear" +func gear_id(): + return 0 func model_file(): return "hammer.glb" func continuous(): return false -func idle_basis(): - return Basis( - Vector3(1, 0, 0), - Vector3(0, 1, 0), - Vector3(0, 0, 1)) -func use_basis(): - return Basis( - Vector3(1, 0, 0), - Vector3(0, 0, -1), - Vector3(0, 1, 0)) -func pickup_basis(): - return idle_basis() +# this can be redefined to make a custom +# gear mesh, e.g. a SphereMesh func use(player): - basis = use_basis() + basis = use_basis $Timer.start() on_use(player) -func unequip(player): - on_unequip(player) - func on_use(_player): pass -func on_unequip(_player): - pass - func on_ready(): pass func _on_timer_timeout(): - basis = idle_basis() + basis = idle_basis func _ready(): - basis = idle_basis() + basis = idle_basis if get_parent() is GearPickup: - basis = pickup_basis() + basis = pickup_basis on_ready() diff --git a/gears/geep.gd b/gears/geep.gd deleted file mode 100644 index fe59a81..0000000 --- a/gears/geep.gd +++ /dev/null @@ -1,34 +0,0 @@ -class_name Geep extends "gear.gd" - -func gear_name(): - return "Geep" -func continuous(): - return false -func use_basis(): - return idle_basis() - -# multiplier of player's speed -const speed = 2 - -var driver = null -var active = false - -func on_use(player): - driver = player - 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) - driver.message("You are now driving a Geep") - -func on_unequip(player): - active = false - -func _physics_process(_delta): - if not active: - return - - driver.move_player(0, -speed) diff --git a/gears/geep.tscn b/gears/geep.tscn deleted file mode 100644 index b983d7b..0000000 --- a/gears/geep.tscn +++ /dev/null @@ -1,82 +0,0 @@ -[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"] - -[sub_resource type="BoxShape3D" id="BoxShape3D_8skgp"] -size = Vector3(3, 0.5, 6) - -[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_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_wm067"] -size = Vector3(3, 2, 2.5) - -[sub_resource type="BoxShape3D" id="BoxShape3D_rhiad"] -size = Vector3(3, 2, 0.5) - -[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"] -size = Vector3(3, 2, 0.5) - -[node name="Gear" type="Node3D"] -rotation_edit_mode = 2 -script = ExtResource("1_8skgp") - -[node name="Timer" type="Timer" parent="."] -one_shot = true - -[node name="GearMesh" type="Node3D" parent="."] - -[node name="Vehicle" type="StaticBody3D" parent="GearMesh"] -transform = Transform3D(1, 0, 0, 0, 1.0000001, 0, 0, 0, 1.0000001, 0, 0, 0) -collision_layer = 4 - -[node name="BaseShape" type="CollisionShape3D" parent="GearMesh/Vehicle"] -shape = SubResource("BoxShape3D_8skgp") - -[node name="BaseMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"] -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, 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, 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, -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, 2.75) -mesh = SubResource("BoxMesh_lrfuo") - -[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/main.tscn b/main.tscn index 5200292..ae10ae9 100644 --- a/main.tscn +++ b/main.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://eiaw4xbs3suk"] +[gd_scene load_steps=9 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://c117buhmmkvkt" path="res://gears/ball.tscn" id="5_7mycd"] -[ext_resource type="PackedScene" uid="uid://d3k7b6o56ue5k" path="res://gears/geep.tscn" id="6_272bh"] +[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"] [sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"] size = Vector3(100, 2, 100) @@ -48,13 +47,8 @@ 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="BallPickup" parent="." instance=ExtResource("3_lquwl")] +[node name="GearPickup" parent="." instance=ExtResource("3_lquwl")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21) -[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")] +[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) diff --git a/player/player.gd b/player/player.gd index ae6067b..48f08e0 100644 --- a/player/player.gd +++ b/player/player.gd @@ -8,7 +8,7 @@ const gear_slots = ["1", "2", "3"] @onready var spawn = Vector3(position) -var starting_gear = preload("res://gears/gear.tscn") +var starting_gear = preload("res://gears/ball.tscn") var suspended = false var direction = Vector3.ZERO @@ -65,7 +65,6 @@ func die(): # strip gears for gear in $Backpack.get_children(): gear.queue_free() - $Pivot/Container/Gear.unequip(self) $Pivot/Container/Gear.queue_free() $RespawnTimer.start() @@ -104,7 +103,6 @@ func use_backpack_slot(n): # place current gear in first free slot var slot = find_free_slot() if slot: - old.unequip(self) old.name = slot old.reparent($Backpack, false) get_node(gear_node).reparent($Pivot/Container, false) @@ -113,8 +111,7 @@ func use_backpack_slot(n): return # couldn't find a free slot, so replace # the new slot with the current gear - get_node(gear_node).reparent($Pivot/Container, false) - old.unequip(self) + get_node(gear_node).reparent($Pivot/Container, false) old.reparent($Backpack, false) old.name = n get_node("Pivot/Container/" + n).name = "Gear" @@ -138,7 +135,6 @@ func equip(gear: Gear): # place current gear in first free slot var slot = find_free_slot() if slot: - old.unequip(self) old.name = slot old.reparent($Backpack, false) new_gear = gear.duplicate()