1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-25 01:04:18 +00:00
This commit is contained in:
Steffo 2023-01-07 12:03:23 +01:00
commit 5acccc0e9e
Signed by: steffo
GPG key ID: 6965406171929D01
13 changed files with 820 additions and 2 deletions

3
.gitignore vendored
View file

@ -3,3 +3,6 @@
# Steffo's random assets folder
available-assets/
# macOS shenanigans
.DS_Store

52
Utils.gd Normal file
View file

@ -0,0 +1,52 @@
extends Node
enum TERNARY {
TRUE,
FALSE,
NONE
}
static func bool_to_sign(b: bool):
return 1 if b else -1
static func map(v: float, i_start: float, i_end: float, f_start: float, f_end: float, clamped := false) -> float:
var output := remap(v, i_start, i_end, f_start, f_end)
return clamp(output, f_start, f_end) if clamped else output
static func vec3_horizontal(v: Vector3) -> Vector2:
return vec3_remove_axis(v, Vector3.AXIS_Y)
static func vec3_remove_axis(v: Vector3, axis : int = Vector3.AXIS_Y) -> Vector2:
match axis:
Vector3.AXIS_X: return Vector2(v.y, v.z)
Vector3.AXIS_Y: return Vector2(v.x, v.z)
Vector3.AXIS_Z: return Vector2(v.x, v.y)
return Vector2.ZERO
static func vec3_deg2rad(v: Vector3):
return Vector3(deg_to_rad(v.x), deg_to_rad(v.y), deg_to_rad(v.z))
static func vec2_deg2rad(v: Vector2):
return Vector2(deg_to_rad(v.x), deg_to_rad(v.y))
#static func round_vec2(v : Vector2, digits : int = 3):
# return Vector2(stepify(v.x, pow(10, -digits)), stepify(v.y, pow(10, -digits)))
static func get_global_pos(obj: Node3D) -> Vector3:
return obj.global_transform.origin
static func get_dir_vector(obj: Node3D, axis := Vector3.AXIS_Z) -> Vector3:
match axis:
Vector3.AXIS_X: return obj.transform.basis.x
Vector3.AXIS_Y: return obj.transform.basis.y
Vector3.AXIS_Z: return obj.transform.basis.z
return Vector3.ZERO
static func delete_children(node):
for n in node.get_children():
n.queue_free()
static func log_line(obj: Node, msg: String):
var time = Time.get_time_dict_from_system()
var time_str = "%02d:%02d:%02d" % [time.hour, time.minute, time.second]
print("@%s [%s]: %s" % [time_str, obj.name, msg])

29
export_presets.cfg Normal file
View file

@ -0,0 +1,29 @@
[preset.0]
name="Linux/X11"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../../Desktop/ld52/ld52_linux.x86_64"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=1
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/architecture="x86_64"

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,25 @@
[ext_resource type="Script" path="res://menu/Menu.gd" id="2_6amk3"]
[ext_resource type="Texture2D" uid="uid://bxyximtgui1ux" path="res://assets/grass_menu_tile.png" id="2_q14jx"]
[sub_resource type="GDScript" id="GDScript_25oo4"]
script/source = "extends Button
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
get_tree().change_scene_to_file(\"res://island/Island.tscn\")
"
[node name="Menu" type="Control"]
texture_filter = 1
layout_mode = 3
@ -68,6 +87,7 @@ size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_font_sizes/font_size = 0
text = "Play"
script = SubResource("GDScript_25oo4")
[node name="Authors2" type="Label" parent="Content"]
layout_mode = 2

32
player/BaseWeapon.gd Normal file
View file

@ -0,0 +1,32 @@
extends Node
class_name BaseWeapon
enum WeaponSlot {
ONE,
TWO,
THREE
}
@export_range(0,1) var MOUSE_MOVEMENT_BOB_AMOUNT := 0.5
var player: Player
var weaponSlot: WeaponSlot = WeaponSlot.ONE
var mouse_movement := Vector2.ZERO
func on_switch_in():
pass
func on_switch_out():
pass
func bob_weapon(node: Node3D, delta: float):
node.position = Vector3.ZERO.lerp(Vector3(
0,
self.mouse_movement.x*0.05,
-self.mouse_movement.y*0.05,
), delta / MOUSE_MOVEMENT_BOB_AMOUNT)
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
var vec = event.relative
self.mouse_movement = Vector2(vec.y, vec.x)

32
player/Head.gd Normal file
View file

@ -0,0 +1,32 @@
extends Node3D
var xNoise: FastNoiseLite
var yNoise: FastNoiseLite
var targetRot := Vector3.ZERO
var eventRot := Vector2.ZERO
var noiseRot := Vector3.ZERO
var noiseCount := 0
@export var noiseAmp := 10.0
@export var noiseFreq := 100.0
var mouseRot := Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
xNoise = FastNoiseLite.new()
yNoise = FastNoiseLite.new()
xNoise.seed = 0
yNoise.seed = 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _physics_process(delta: float) -> void:
pass
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
mouseRot = event.relative

64
player/OnHand.gd Normal file
View file

@ -0,0 +1,64 @@
extends Node3D
enum GUN_STATE {
ACTIVE,
SWITCHING,
INACTIVE
}
var active_weapon: BaseWeapon
signal weapon_switched(weapon: BaseWeapon)
var player: Player:
get:
return player
set(p):
player = p
self._on_player_set(p)
var weapons: Array = [
# load("res://Player/Weapons/Arm.tscn").instantiate(),
# load("res://Player/Weapons/ak47.tscn").instantiate(),
]
func _ready() -> void:
self._switch_weapon(BaseWeapon.WeaponSlot.THREE)
func _process(delta: float) -> void:
pass
func _on_player_set(player: Player) -> void:
for weapon in weapons:
weapon.player = player
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("slot1"):
_switch_weapon(BaseWeapon.WeaponSlot.ONE)
elif Input.is_action_just_pressed("slot2"):
_switch_weapon(BaseWeapon.WeaponSlot.TWO)
elif Input.is_action_just_pressed("slot3"):
_switch_weapon(BaseWeapon.WeaponSlot.THREE)
func _switch_weapon(slot: BaseWeapon.WeaponSlot):
# TODO: play anim ecc ecc
# Try to get the correct weapon per the given `slot`
for weapon in weapons:
if weapon.weaponSlot == slot:
# Remove active weapon
if active_weapon:
await active_weapon.on_switch_out()
remove_child(active_weapon)
# Add new weapon
add_child(weapon)
active_weapon = weapon
await active_weapon.on_switch_in()
emit_signal("weapon_switched", weapon)
break

300
player/Player.tscn Normal file
View file

@ -0,0 +1,300 @@
[gd_scene load_steps=17 format=3 uid="uid://dnrl0uycbw3lp"]
[ext_resource type="Script" path="res://player/player.gd" id="1_rujcr"]
[ext_resource type="Script" path="res://Player/Head.gd" id="2_fs52a"]
[ext_resource type="Script" path="res://Player/OnHand.gd" id="3_au30p"]
[ext_resource type="Shader" path="res://Player/crosshair.gdshader" id="6_r7xbu"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_berhm"]
[sub_resource type="BoxMesh" id="BoxMesh_7lbaj"]
material = SubResource("StandardMaterial3D_berhm")
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"]
metallic_specular = 0.0
[sub_resource type="CylinderMesh" id="CylinderMesh_h7ca4"]
material = SubResource("StandardMaterial3D_aqp8x")
[sub_resource type="CylinderShape3D" id="CylinderShape3D_otair"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqko1"]
bg_color = Color(0.240234, 0.240234, 0.240234, 1)
[sub_resource type="Theme" id="Theme_smyke"]
Panel/styles/panel = SubResource("StyleBoxFlat_vqko1")
[sub_resource type="GDScript" id="GDScript_iiadi"]
resource_name = "FPS_Counter"
script/source = "extends Label
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
self.text = str(round(1/delta)) + \" FPS\"
"
[sub_resource type="GDScript" id="GDScript_5d122"]
resource_name = "PointsSpawner"
script/source = "extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func spawn_points_label(text: String, offset: Vector2):
var label = Label.new()
label.text = text
label.offset_bottom = -offset.y
label.offset_left = offset.x
self.add_child(label)
var initialY = label.position.y
var tween = get_tree().create_tween()
tween.set_speed_scale(2)
tween.parallel().tween_property(label, \"position:y\", initialY - 50, 1).as_relative().from_current().set_trans(Tween.EASE_OUT)
tween.parallel().tween_property(label, \"modulate\", Color.TRANSPARENT, 1).set_trans(Tween.EASE_OUT)
tween.tween_callback(label.queue_free)
tween.play()
"
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_avmet"]
bg_color = Color(0, 0, 0, 0.647059)
[sub_resource type="GDScript" id="GDScript_7qy62"]
script/source = "extends Camera3D
@export var MainCamera: Camera3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not MainCamera:
return
if MainCamera.global_position:
self.global_position = MainCamera.global_position
if MainCamera.global_rotation:
self.global_rotation = MainCamera.global_rotation
"
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2p6rt"]
shader = ExtResource("6_r7xbu")
shader_parameter/center_enabled = false
shader_parameter/legs_enabled = true
shader_parameter/inverted = false
shader_parameter/color_id = null
shader_parameter/color_0 = null
shader_parameter/color_1 = null
shader_parameter/color_2 = null
shader_parameter/center_radius = 0.002
shader_parameter/width = 0.001
shader_parameter/len = 0.008
shader_parameter/spacing = 0.006
shader_parameter/spread = 0.902
[node name="Player" type="CharacterBody3D"]
slide_on_ceiling = false
floor_constant_speed = true
script = ExtResource("1_rujcr")
[node name="Head" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.54, 0)
script = ExtResource("2_fs52a")
[node name="Torch" type="SpotLight3D" parent="Head"]
visible = false
light_energy = 5.5
light_indirect_energy = 2.0
light_cull_mask = 4294967293
shadow_enabled = true
spot_range = 28.8
spot_angle = 23.1165
spot_angle_attenuation = 0.466516
[node name="RayCast3D" type="RayCast3D" parent="Head"]
target_position = Vector3(0, 0, -1.4)
[node name="OnHand" type="Node3D" parent="Head"]
transform = Transform3D(1, 0, 1.74846e-07, 0, 1, 0, -1.74846e-07, 0, 1, 0, 0, 0)
script = ExtResource("3_au30p")
[node name="Viewport" type="Control" parent="Head"]
texture_filter = 1
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="CameraViewportContainer" type="SubViewportContainer" parent="Head/Viewport"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="GameViewport" type="SubViewport" parent="Head/Viewport/CameraViewportContainer"]
transparent_bg = true
handle_input_locally = false
size = Vector2i(284, 160)
render_target_update_mode = 4
[node name="Camera" type="Camera3D" parent="Head/Viewport/CameraViewportContainer/GameViewport"]
transform = Transform3D(1, 0, 1.74846e-07, 0, 1, 0, -1.74846e-07, 0, 1, 0, 0.54, 0)
current = true
fov = 80.0
near = 0.001
[node name="MeshInstance3D" type="MeshInstance3D" parent="Head/Viewport/CameraViewportContainer/GameViewport/Camera"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.13668e-07, 0, -2.3659)
visible = false
layers = 3
mesh = SubResource("BoxMesh_7lbaj")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("CylinderMesh_h7ca4")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CylinderShape3D_otair")
[node name="HUD" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_smyke")
[node name="FPS_Label" type="Label" parent="HUD"]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -97.0
offset_bottom = 32.0
grow_horizontal = 0
theme_override_font_sizes/font_size = 20
text = "n/d FPS"
horizontal_alignment = 2
script = SubResource("GDScript_iiadi")
[node name="PointsSpawner" type="Control" parent="HUD"]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
script = SubResource("GDScript_5d122")
[node name="Speed_Label" type="Label" parent="HUD"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -53.0
offset_top = 36.0
offset_right = 53.0
offset_bottom = 71.0
grow_horizontal = 2
grow_vertical = 2
horizontal_alignment = 1
vertical_alignment = 1
[node name="Panel" type="Panel" parent="HUD"]
visible = false
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -276.0
offset_top = -122.0
offset_right = -40.0
offset_bottom = -40.0
grow_horizontal = 0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_avmet")
[node name="ColorRect" type="ColorRect" parent="HUD/Panel"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.745098)
[node name="BackBufferCopy2" type="BackBufferCopy" parent="HUD"]
position = Vector2(727, 447)
scale = Vector2(7.61, 4.89)
copy_mode = 2
[node name="SubViewportContainer" type="SubViewportContainer" parent="HUD"]
visible = false
show_behind_parent = true
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="SubViewport" type="SubViewport" parent="HUD/SubViewportContainer"]
transparent_bg = true
handle_input_locally = false
size = Vector2i(284, 160)
render_target_update_mode = 0
[node name="WeaponCamera" type="Camera3D" parent="HUD/SubViewportContainer/SubViewport" node_paths=PackedStringArray("MainCamera")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.581502, 0)
cull_mask = 2
near = 0.001
script = SubResource("GDScript_7qy62")
MainCamera = NodePath("../../../../Head/Viewport/CameraViewportContainer/GameViewport/Camera")
[node name="Crosshair" type="ColorRect" parent="HUD"]
material = SubResource("ShaderMaterial_2p6rt")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -5.0
offset_bottom = -5.0
grow_horizontal = 2
grow_vertical = 2
[node name="BackBufferCopy" type="BackBufferCopy" parent="HUD"]
y_sort_enabled = true
position = Vector2(721, 449)
scale = Vector2(7.21, 4.54)
[node name="GameFilter" type="ColorRect" parent="HUD"]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
metadata/_edit_layout_mode = 1
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]

14
player/PlayerInputData.gd Normal file
View file

@ -0,0 +1,14 @@
extends Object
class_name PlayerInputData
var forward: float = 0
var backwards: float = 0
var right: float = 0
var left: float = 0
var jump: bool = false
var use: bool = false
var crouch: bool = false
var horizontal: float = 0
var vertical: float = 0

42
player/crosshair.gdshader Normal file
View file

@ -0,0 +1,42 @@
shader_type canvas_item;
uniform bool center_enabled = true;
uniform bool legs_enabled = true;
uniform bool inverted = false;
uniform int color_id = 0;
uniform vec4 color_0 = vec4(0., 1, 0., 1.);
uniform vec4 color_1 = vec4(1., 0., 0., 1.);
uniform vec4 color_2 = vec4(0., 0., 1., 1.);
uniform float center_radius = .002;
uniform float width = .003;
uniform float len = .03;
uniform float spacing = .008;
uniform float spread = 1.;
void fragment(){
float a = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
vec2 UVa = vec2(UV.x / a, UV.y);
vec2 center = vec2(.5 / a, .5);
float point = step(distance(UVa, center), center_radius);
float h = step(center.x - len - spacing*spread, UVa.x) - step(center.x - spacing*spread, UVa.x);
h += step(center.x + spacing*spread, UVa.x) - step(center.x + len + spacing*spread, UVa.x);
h *= step(center.y - width, UVa.y) - step(center.y + width, UVa.y);
float v = step(center.y - len - spacing*spread, UVa.y) - step(center.y - spacing*spread, UVa.y);
v += step(center.y + spacing*spread, UVa.y) - step(center.y + len + spacing*spread, UVa.y);
v *= step(center.x - width, UVa.x) - step(center.x + width, UVa.x);
float crosshair;
crosshair = (h+v) * float(legs_enabled) + point * float(center_enabled);
if(!inverted){
COLOR = (color_0 * float(color_id == 0) + color_1 * float(color_id == 1) + color_2 * float(color_id == 2)) * crosshair;
}else{
COLOR = vec4((cos(textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb * 3.1415926534) + 1.)/2., 1.) * crosshair;
}
}

153
player/player.gd Normal file
View file

@ -0,0 +1,153 @@
extends CharacterBody3D
class_name Player
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
const MOUSE_SENSITIVITY = 2.25
const MAX_AIR_WISH_SPEED = 20
const AIR_ACCELERATE = 100 # Hu/39.97
@onready var head: Node3D = $Head
@onready var camera: Camera3D = head.get_node("Viewport/CameraViewportContainer/GameViewport/Camera")
@onready var vport: SubViewport = head.get_node("Viewport/CameraViewportContainer/GameViewport")
@onready var aim_raycast: RayCast3D = head.get_node("RayCast3D")
@onready var torch: SpotLight3D = head.get_node("Torch")
@onready var OnHand = head.get_node("OnHand")
@onready var active_weapon: BaseWeapon:
get: return OnHand.active_weapon
# DEBUG NODES
@onready var debug_speed_label = $HUD/Speed_Label
var last_frame_input_data: PlayerInputData = PlayerInputData.new()
var input_data: PlayerInputData = PlayerInputData.new()
var mouse_movement: Vector2 = Vector2.ZERO
var mouse_enabled: bool = true
var last_ground_velocity: Vector2 = Vector2.ZERO
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
# ===== UTILS =====
func _get_2d_velocity() -> Vector2:
return Vector2(velocity.x, velocity.z)
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
OnHand.player = self
# vport.size = DisplayServer.window_get_size()
vport.size = Vector2(426, 240)
# for item in OnHand.get_children():
# if item is BaseWeapon:
# item.player = self
func _process(delta):
pass
func _physics_process(delta):
last_frame_input_data = input_data
input_data = PlayerInputData.new()
if mouse_movement:
self.rotate_y(self.mouse_movement.y * -1 * delta * MOUSE_SENSITIVITY)
var x_rotation = self.mouse_movement.x * -1 * delta * MOUSE_SENSITIVITY
head.rotation.x = clamp(head.rotation.x + x_rotation, deg_to_rad(-90), deg_to_rad(90))
self.mouse_movement = Vector2.ZERO
var jumping = false
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
else:
last_ground_velocity = Vector2(velocity.x, velocity.z)
# Handle Jump
if Input.is_action_pressed("jump") and is_on_floor():
jumping = true
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("left", "right", "forward", "backwards")
var based = (transform.basis * Vector3(input_dir.x, 0, input_dir.y))
var direction = based.normalized()
if is_on_floor() and not jumping:
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
else:
_air_accelerate(direction, based.length(), AIR_ACCELERATE, delta)
# Apply camera effects
var camera_yaw := 0
var current_speed := _get_2d_velocity().length()
if is_on_floor() and current_speed > 0:
camera_yaw = -clamp(_get_2d_velocity().length() * input_dir.x, -25, 25)
else:
camera_yaw = 0
self.camera.global_transform = self.head.global_transform
# camera.rotation.z = move_toward(
# 0,
# camera_yaw,
# delta
# ) * 2.5
debug_speed_label.text = "%0.2f" % current_speed
move_and_slide()
func _air_accelerate(wish_dir: Vector3, wish_speed: float, airaccelerate: float, delta_time: float):
var addspeed: float = 0
var accelspeed: float = 0
var currentspeed: float = 0
if wish_speed > MAX_AIR_WISH_SPEED:
wish_speed = MAX_AIR_WISH_SPEED
currentspeed = velocity.dot(wish_dir)
addspeed = wish_speed - currentspeed
if addspeed <= 0:
return
accelspeed = airaccelerate * delta_time * wish_speed
if accelspeed > addspeed:
accelspeed = addspeed
velocity += accelspeed * wish_dir
func wall_running() -> bool:
if is_on_wall_only():
if Input.is_action_pressed("jump"):
var wall_normal := get_wall_normal()
var bas = transform.basis * velocity
velocity.y /= 2
return true
return false
func _input(event):
if event is InputEventKey and event.keycode == KEY_ESCAPE:
get_tree().quit()
if Input.is_action_just_pressed("toggle_torch"):
torch.visible = !torch.visible
if event is InputEventMouseMotion:
var vec = event.relative
self.mouse_movement = Vector2(vec.y / 10, vec.x / 10)

View file

@ -8,6 +8,28 @@
config_version=5
_global_script_classes=[{
"base": "Node",
"class": &"BaseWeapon",
"language": &"GDScript",
"path": "res://Player/BaseWeapon.gd"
}, {
"base": "CharacterBody3D",
"class": &"Player",
"language": &"GDScript",
"path": "res://Player/player.gd"
}, {
"base": "Object",
"class": &"PlayerInputData",
"language": &"GDScript",
"path": "res://Player/PlayerInputData.gd"
}]
_global_script_class_icons={
"BaseWeapon": "",
"Player": "",
"PlayerInputData": ""
}
[application]
config/name="LD52"
@ -20,13 +42,41 @@ config/icon="res://assets/icon.svg"
window/size/viewport_width=284
window/size/viewport_height=160
window/size/mode=2
window/stretch/mode="canvas_items"
[gui]
fonts/dynamic_fonts/use_oversampling=false
[input]
forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null)
]
}
backwards={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
]
}
left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
environment/defaults/default_clear_color=Color(0.231373, 0.490196, 0.309804, 1)