initial commit
This commit is contained in:
commit
79951d8075
22 changed files with 729 additions and 0 deletions
4
.editorconfig
Normal file
4
.editorconfig
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Normalize EOL for all files that Git considers text files.
|
||||||
|
* text=auto eol=lf
|
||||||
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Godot 4
|
||||||
|
.godot/
|
||||||
|
/android/
|
||||||
|
*.import
|
||||||
|
*.uid
|
||||||
|
|
||||||
|
# Emacs
|
||||||
|
*~
|
||||||
|
*.~undo-tree~
|
||||||
36
gears/ball.gd
Normal file
36
gears/ball.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
class_name Ball extends "gear.gd"
|
||||||
|
|
||||||
|
func gear_name():
|
||||||
|
return "Ball"
|
||||||
|
func gear_id():
|
||||||
|
return 1
|
||||||
|
func continuous():
|
||||||
|
return false
|
||||||
|
|
||||||
|
func make_ball(player):
|
||||||
|
var ball = RigidBody3D.new()
|
||||||
|
var cs = CollisionShape3D.new()
|
||||||
|
cs.shape = SphereShape3D.new()
|
||||||
|
ball.name = "Ball"
|
||||||
|
ball.mass = 4
|
||||||
|
ball.position = Vector3.ZERO
|
||||||
|
ball.global_transform = Transform3D(
|
||||||
|
player.get_node("Pivot/Container").global_transform)
|
||||||
|
|
||||||
|
ball.set_collision_layer_value(1, false)
|
||||||
|
ball.set_collision_layer_value(3, true)
|
||||||
|
ball.set_collision_mask_value(3, true)
|
||||||
|
|
||||||
|
var mesh = $GearMesh.duplicate()
|
||||||
|
mesh.position = Vector3.ZERO
|
||||||
|
ball.add_child(mesh)
|
||||||
|
ball.add_child(cs)
|
||||||
|
|
||||||
|
return ball
|
||||||
|
|
||||||
|
func on_use(player):
|
||||||
|
var ball = make_ball(player)
|
||||||
|
var impulse = player.get_node("CameraGimbal").basis.z * -64
|
||||||
|
impulse.y = 4
|
||||||
|
ball.apply_central_impulse(impulse)
|
||||||
|
player.add_sibling(ball)
|
||||||
22
gears/ball.tscn
Normal file
22
gears/ball.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://c117buhmmkvkt"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://s3273etto01h" path="res://gears/ball.gd" id="1_1ps3n"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1ps3n"]
|
||||||
|
albedo_color = Color(1, 0.5647059, 0.5647059, 1)
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_g55y5"]
|
||||||
|
material = SubResource("StandardMaterial3D_1ps3n")
|
||||||
|
|
||||||
|
[node name="Gear" type="Node3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0, 0)
|
||||||
|
rotation_edit_mode = 2
|
||||||
|
script = ExtResource("1_1ps3n")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="GearMesh" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("SphereMesh_g55y5")
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
43
gears/gear.gd
Normal file
43
gears/gear.gd
Normal file
|
|
@ -0,0 +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
|
||||||
|
|
||||||
|
# this can be redefined to make a custom
|
||||||
|
# gear mesh, e.g. a SphereMesh
|
||||||
|
func use(player):
|
||||||
|
basis = use_basis
|
||||||
|
$Timer.start()
|
||||||
|
on_use(player)
|
||||||
|
|
||||||
|
func on_use(_player):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func on_ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
basis = idle_basis
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
basis = idle_basis
|
||||||
|
if get_parent() is GearPickup:
|
||||||
|
basis = pickup_basis
|
||||||
|
on_ready()
|
||||||
BIN
gears/gear.png
Normal file
BIN
gears/gear.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
17
gears/gear.tscn
Normal file
17
gears/gear.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bafl8q0r61xrg"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dc83u0v4s15yc" path="res://gears/gear.gd" id="1_0lgiy"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://btkm0yadpycun" path="res://models/hammer.glb" id="2_i4ub2"]
|
||||||
|
|
||||||
|
[node name="Gear" type="Node3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0, 0)
|
||||||
|
rotation_edit_mode = 2
|
||||||
|
script = ExtResource("1_0lgiy")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="GearMesh" parent="." instance=ExtResource("2_i4ub2")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
13
gears/gear_pickup.gd
Normal file
13
gears/gear_pickup.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class_name GearPickup extends Area3D
|
||||||
|
|
||||||
|
@export var one_shot = false
|
||||||
|
|
||||||
|
func _on_body_entered(body):
|
||||||
|
if body is not Player:
|
||||||
|
return
|
||||||
|
var taken = body.equip($Gear)
|
||||||
|
if taken and one_shot:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
assert($Gear is Gear, "GearPickup instantiated without child Gear!")
|
||||||
16
gears/gear_pickup.tscn
Normal file
16
gears/gear_pickup.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://of6tq8gpjxtu"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dc84ngcaxqd0c" path="res://gears/gear_pickup.gd" id="1_46ram"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_eqvx5"]
|
||||||
|
size = Vector3(1.5, 1.5, 1.5)
|
||||||
|
|
||||||
|
[node name="GearPickup" type="Area3D"]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_46ram")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("BoxShape3D_eqvx5")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
1
icon.svg
Normal file
1
icon.svg
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 995 B |
54
main.tscn
Normal file
54
main.tscn
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
[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://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
|
||||||
|
size = Vector3(100, 2, 100)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_ig7tw"]
|
||||||
|
size = Vector3(100, 2, 100)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ig7tw"]
|
||||||
|
albedo_color = Color(0.49454, 0.79, 0.4424, 1)
|
||||||
|
|
||||||
|
[node name="Main" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource("1_ig7tw")]
|
||||||
|
|
||||||
|
[node name="Baseplate" type="StaticBody3D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Baseplate"]
|
||||||
|
shape = SubResource("BoxShape3D_7dm0k")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Baseplate"]
|
||||||
|
mesh = SubResource("BoxMesh_ig7tw")
|
||||||
|
surface_material_override/0 = SubResource("StandardMaterial3D_ig7tw")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
|
transform = Transform3D(0.7071068, -0.49999994, 0.49999994, 0, 0.7071067, 0.7071067, -0.7071068, -0.49999994, 0.49999994, 50, 50, 50)
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="radiohead cube" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 3, 0)
|
||||||
|
|
||||||
|
[node name="radiohead cube2" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 3, 0)
|
||||||
|
|
||||||
|
[node name="radiohead cube3" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 3, 4)
|
||||||
|
|
||||||
|
[node name="radiohead cube4" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
|
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")]
|
||||||
|
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)
|
||||||
BIN
models/hammer.glb
Normal file
BIN
models/hammer.glb
Normal file
Binary file not shown.
BIN
models/player.glb
Normal file
BIN
models/player.glb
Normal file
Binary file not shown.
34
player/camera_gimbal.gd
Normal file
34
player/camera_gimbal.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
class_name CameraGimbal extends Node3D
|
||||||
|
|
||||||
|
@export var rotation_speed = (PI / 180) * 120
|
||||||
|
|
||||||
|
func reset():
|
||||||
|
basis = Basis()
|
||||||
|
$InnerGimbal.basis = Basis()
|
||||||
|
|
||||||
|
func rotate_camera_y(y, delta):
|
||||||
|
rotate_object_local(Vector3.UP, y * rotation_speed * delta)
|
||||||
|
func rotate_camera_x(x, delta):
|
||||||
|
$InnerGimbal.rotate_object_local(
|
||||||
|
Vector3.RIGHT, x * rotation_speed * delta)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
# rotate outer gimbal around y axis
|
||||||
|
var y = 0
|
||||||
|
if Input.is_action_pressed("cam_left"):
|
||||||
|
y += 1
|
||||||
|
if Input.is_action_pressed("cam_right"):
|
||||||
|
y -= 1
|
||||||
|
rotate_camera_y(y, delta)
|
||||||
|
|
||||||
|
# rotate inner gimbal around x axis
|
||||||
|
var x = 0
|
||||||
|
if Input.is_action_pressed("cam_up"):
|
||||||
|
x -= 1
|
||||||
|
if Input.is_action_pressed("cam_down"):
|
||||||
|
x += 1
|
||||||
|
rotate_camera_x(x, delta)
|
||||||
|
|
||||||
|
# reset gimbals
|
||||||
|
if Input.is_action_pressed("cam_reset"):
|
||||||
|
reset()
|
||||||
218
player/player.gd
Normal file
218
player/player.gd
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
class_name Player extends CharacterBody3D
|
||||||
|
|
||||||
|
@export var walk_speed = 12
|
||||||
|
@export var jump_power = 32
|
||||||
|
@export var fall_speed = 86
|
||||||
|
|
||||||
|
var health = 100
|
||||||
|
var suspended = false
|
||||||
|
var spawn = Vector3.ZERO
|
||||||
|
var direction = Vector3.ZERO
|
||||||
|
var target_velocity = Vector3.ZERO
|
||||||
|
var initial_gear = null
|
||||||
|
var gear_slots = ["1", "2", "3"]
|
||||||
|
|
||||||
|
func resize_ui():
|
||||||
|
var bpui_h = 200
|
||||||
|
var size = get_viewport().get_visible_rect().size
|
||||||
|
$Message.size.x = size.x
|
||||||
|
$BackpackUI.size.x = size.x
|
||||||
|
$BackpackUI.size.y = bpui_h
|
||||||
|
$BackpackUI.position.x = 0
|
||||||
|
$BackpackUI.position.y = size.y - bpui_h
|
||||||
|
|
||||||
|
func make_backpack_ui():
|
||||||
|
var text = "Holding " + $Pivot/Container/Gear.gear_name()
|
||||||
|
for node in $Backpack.get_children():
|
||||||
|
if not node is Gear:
|
||||||
|
continue
|
||||||
|
text += "\n%s (%s)" % [node.gear_name(), node.name]
|
||||||
|
$BackpackUI.text = text
|
||||||
|
|
||||||
|
func message(string):
|
||||||
|
$Message.text = string
|
||||||
|
$Message.visible = true
|
||||||
|
$Message/VanishTimer.start()
|
||||||
|
|
||||||
|
func die():
|
||||||
|
suspended = true
|
||||||
|
visible = false
|
||||||
|
$BackpackUI.visible = false
|
||||||
|
$RespawnTimer.start()
|
||||||
|
message("Le gone")
|
||||||
|
|
||||||
|
func respawn():
|
||||||
|
position = Vector3(spawn)
|
||||||
|
$CameraGimbal.reset()
|
||||||
|
health = 100
|
||||||
|
visible = true
|
||||||
|
suspended = false
|
||||||
|
$BackpackUI.visible = true
|
||||||
|
|
||||||
|
# Backpack functions
|
||||||
|
|
||||||
|
func find_free_slot():
|
||||||
|
for slot in gear_slots:
|
||||||
|
if not has_node("Backpack/" + slot):
|
||||||
|
return slot
|
||||||
|
return null
|
||||||
|
|
||||||
|
func use_backpack_slot(n):
|
||||||
|
assert(gear_slots.has(n))
|
||||||
|
var gear_node = "Backpack/" + n
|
||||||
|
var old = $Pivot/Container/Gear
|
||||||
|
# check if gear is at slot
|
||||||
|
if not has_node(gear_node):
|
||||||
|
message("Gear not found")
|
||||||
|
return
|
||||||
|
# place current gear in first free slot
|
||||||
|
var slot = find_free_slot()
|
||||||
|
if slot:
|
||||||
|
old.name = slot
|
||||||
|
old.reparent($Backpack, false)
|
||||||
|
get_node(gear_node).reparent($Pivot/Container, false)
|
||||||
|
get_node("Pivot/Container/" + n).name = "Gear"
|
||||||
|
make_backpack_ui()
|
||||||
|
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.reparent($Backpack, false)
|
||||||
|
old.name = n
|
||||||
|
get_node("Pivot/Container/" + n).name = "Gear"
|
||||||
|
make_backpack_ui()
|
||||||
|
return
|
||||||
|
|
||||||
|
func equip(gear: Gear):
|
||||||
|
var gear_name = gear.gear_name()
|
||||||
|
# do we have the gear equipped?
|
||||||
|
if gear_name == $Pivot/Container/Gear.gear_name():
|
||||||
|
return false
|
||||||
|
# do we have the gear in our backpack?
|
||||||
|
for item in $Backpack.get_children():
|
||||||
|
if item.gear_name() == gear_name:
|
||||||
|
use_backpack_slot(item.name)
|
||||||
|
return false
|
||||||
|
# we do not have the gear, so set aside
|
||||||
|
# the current gear and equip the new one
|
||||||
|
var old = $Pivot/Container/Gear
|
||||||
|
var new_gear: Gear
|
||||||
|
# place current gear in first free slot
|
||||||
|
var slot = find_free_slot()
|
||||||
|
if slot:
|
||||||
|
old.name = slot
|
||||||
|
old.reparent($Backpack, false)
|
||||||
|
new_gear = gear.duplicate()
|
||||||
|
new_gear.name = "Gear"
|
||||||
|
$Pivot/Container.add_child(new_gear)
|
||||||
|
make_backpack_ui()
|
||||||
|
message("You picked up a " + gear_name + "!")
|
||||||
|
return true
|
||||||
|
# if no slots are free
|
||||||
|
message("Backpack full")
|
||||||
|
return false
|
||||||
|
|
||||||
|
# Player movement and engine callbacks
|
||||||
|
|
||||||
|
func move_player(x, z):
|
||||||
|
var camera_basis = $CameraGimbal.get_global_transform().basis
|
||||||
|
|
||||||
|
# rotate player
|
||||||
|
get_global_transform().basis = Basis($CameraGimbal.basis)
|
||||||
|
var z_basis = -camera_basis.z
|
||||||
|
if z == 1:
|
||||||
|
z_basis = -z_basis
|
||||||
|
$Pivot.basis = Basis.looking_at(z_basis.normalized())
|
||||||
|
$CollisionShape3D.basis = $Pivot.basis
|
||||||
|
# apply camera direction to movement direction
|
||||||
|
if z != 0:
|
||||||
|
# adding the value to the existing direction
|
||||||
|
# variable lets the user press multiple keys
|
||||||
|
# to move diagonally
|
||||||
|
direction += camera_basis.z * z
|
||||||
|
if x != 0:
|
||||||
|
direction += camera_basis.x * x
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
spawn = Vector3(position)
|
||||||
|
initial_gear = $Pivot/Container/Gear.duplicate()
|
||||||
|
get_viewport().size_changed.connect(resize_ui)
|
||||||
|
resize_ui()
|
||||||
|
make_backpack_ui()
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if suspended:
|
||||||
|
return
|
||||||
|
|
||||||
|
if health < 1 or position.y <= -1000:
|
||||||
|
die()
|
||||||
|
|
||||||
|
# UI and backpack keys
|
||||||
|
if Input.is_action_pressed("ui_backpack"):
|
||||||
|
var mesg = "Equipped: " + $Pivot/Container/Gear.gear_name() + "\nBackpack: "
|
||||||
|
for node in $Backpack.get_children():
|
||||||
|
if not node is Gear:
|
||||||
|
continue
|
||||||
|
mesg += node.name + "." + node.gear_name() + " "
|
||||||
|
message(mesg)
|
||||||
|
if Input.is_action_just_pressed("backpack_1"):
|
||||||
|
use_backpack_slot("1")
|
||||||
|
if Input.is_action_just_pressed("backpack_2"):
|
||||||
|
use_backpack_slot("2")
|
||||||
|
if Input.is_action_just_pressed("backpack_3"):
|
||||||
|
use_backpack_slot("3")
|
||||||
|
|
||||||
|
# Movement keys
|
||||||
|
var mx = 0
|
||||||
|
var mz = 0
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
target_velocity.x = direction.x * walk_speed
|
||||||
|
target_velocity.z = direction.z * walk_speed
|
||||||
|
direction = Vector3.ZERO
|
||||||
|
|
||||||
|
if not is_on_floor():
|
||||||
|
target_velocity.y = target_velocity.y - (fall_speed * delta)
|
||||||
|
velocity = target_velocity
|
||||||
|
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
# Gear uses
|
||||||
|
var gear = $Pivot/Container/Gear
|
||||||
|
assert(gear is Gear)
|
||||||
|
if gear.continuous():
|
||||||
|
if Input.is_action_pressed("gear_use"):
|
||||||
|
gear.use(self)
|
||||||
|
else:
|
||||||
|
if Input.is_action_just_pressed("gear_use"):
|
||||||
|
gear.use(self)
|
||||||
|
|
||||||
|
# Signals
|
||||||
|
|
||||||
|
func _on_vanish_timer_timeout():
|
||||||
|
$Message.visible = false
|
||||||
|
|
||||||
|
# Ensure that gears are invisible in the backpack.
|
||||||
|
# As children of a Node they will be detached from
|
||||||
|
# 3D space so if visible is true they may be visibly
|
||||||
|
# littered on the ground where the player changed
|
||||||
|
# gears.
|
||||||
|
func _on_backpack_child_entered_tree(node):
|
||||||
|
assert(node is Gear)
|
||||||
|
node.visible = false
|
||||||
|
func _on_backpack_child_exiting_tree(node):
|
||||||
|
assert(node is Gear)
|
||||||
|
node.visible = true
|
||||||
109
player/player.tscn
Normal file
109
player/player.tscn
Normal file
File diff suppressed because one or more lines are too long
100
project.godot
Normal file
100
project.godot
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Joeblox"
|
||||||
|
run/main_scene="uid://eiaw4xbs3suk"
|
||||||
|
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||||
|
config/icon="res://thebends.jpg"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_forward={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_back={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
jump={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cam_left={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cam_right={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cam_up={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cam_down={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cam_reset={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":79,"physical_keycode":0,"key_label":0,"unicode":111,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
gear_use={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_backpack={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":69,"physical_keycode":0,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
backpack_1={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":49,"physical_keycode":0,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
backpack_2={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":50,"physical_keycode":0,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
backpack_3={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":51,"physical_keycode":0,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="World"
|
||||||
|
3d_physics/layer_2="Player"
|
||||||
|
3d_physics/layer_3="Object"
|
||||||
BIN
thebends.jpg
Normal file
BIN
thebends.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
5
world/killbrick.gd
Normal file
5
world/killbrick.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Area3D
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node3D):
|
||||||
|
if body is Player:
|
||||||
|
body.health = 0
|
||||||
25
world/killbrick.tscn
Normal file
25
world/killbrick.tscn
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://qb8cbljxgnub"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://btnombvdi88t1" path="res://world/killbrick.gd" id="1_mh5je"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_qp2fc"]
|
||||||
|
size = Vector3(4, 1, 4)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xiu23"]
|
||||||
|
albedo_color = Color(0.84313726, 0.23137255, 0.23921569, 1)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_d4c1g"]
|
||||||
|
material = SubResource("StandardMaterial3D_xiu23")
|
||||||
|
size = Vector3(4, 1, 4)
|
||||||
|
|
||||||
|
[node name="Killbrick" type="Area3D"]
|
||||||
|
collision_mask = 7
|
||||||
|
script = ExtResource("1_mh5je")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("BoxShape3D_qp2fc")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("BoxMesh_d4c1g")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
21
world/radiohead_cube.tscn
Normal file
21
world/radiohead_cube.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://bcmrj6qkemrll"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dau5jd2ty4a6c" path="res://thebends.jpg" id="1_ujsvd"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_ig7tw"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_h2yge"]
|
||||||
|
albedo_texture = ExtResource("1_ujsvd")
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_0xm2m"]
|
||||||
|
material = SubResource("StandardMaterial3D_h2yge")
|
||||||
|
|
||||||
|
[node name="radiohead cube" type="StaticBody3D"]
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0)
|
||||||
|
shape = SubResource("BoxShape3D_ig7tw")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0)
|
||||||
|
mesh = SubResource("BoxMesh_0xm2m")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue