forked from funnymemellama/funnymemellama
Merge branch 'master' of ssh://play.qtechofficial.com:9940/funnymemellama/funnymemellama
This commit is contained in:
commit
ed5247cc77
4 changed files with 79 additions and 51 deletions
|
@ -60,14 +60,14 @@ func interact(other):
|
|||
|
||||
func _on_anim_finished(name):
|
||||
if _resetting:
|
||||
_sound.stop()
|
||||
_sound.stream = release_sound
|
||||
_sound.play()
|
||||
_button.material = released_material
|
||||
_resetting = false
|
||||
_triggered = false
|
||||
|
||||
if momentary and _triggered:
|
||||
_sound.stop()
|
||||
_sound.stream = release_sound
|
||||
_sound.play()
|
||||
_anim.play_backwards('trigger')
|
||||
_resetting = true
|
||||
|
||||
|
|
2
Debug.gd
2
Debug.gd
|
@ -11,7 +11,7 @@ func _process(delta):
|
|||
var v = $Player.velocity
|
||||
var hvel = sqrt(v.x ** 2 + v.z ** 2)
|
||||
var vvel = v.y
|
||||
$Speed.text = 'Speed: %6.2f, %6.2f' % [hvel, vvel]
|
||||
$Speed.text = 'Speed: %6.2f, %6.2f' % [hvel * 16, vvel * 16]
|
||||
|
||||
|
||||
func _input(event: InputEvent):
|
||||
|
|
92
Player.gd
92
Player.gd
|
@ -4,15 +4,18 @@ extends CharacterBody3D
|
|||
const QUAKE = 0.0625
|
||||
const g = -800 * QUAKE
|
||||
const MAX_SPEED = 320 * QUAKE
|
||||
const MAX_AIR_SPEED = 30 * QUAKE
|
||||
const FRICTION = 4# * QUAKE
|
||||
const STOP_SPEED = 100 * QUAKE
|
||||
const ACCEL= 10# * QUAKE
|
||||
const FORWARD_SPEED = 400 * QUAKE
|
||||
const ACCEL = 15# * QUAKE
|
||||
const AIR_ACCEL = 2# * QUAKE
|
||||
const FORWARD_SPEED = 200 * QUAKE
|
||||
const SIDE_SPEED = 350 * QUAKE
|
||||
const UP_SPEED = 270 * QUAKE
|
||||
const JUMP_SPEED = 270 * QUAKE
|
||||
|
||||
# const DEACCEL= 8
|
||||
# const MAX_SLOPE_ANGLE = 30
|
||||
# const MAX_SLOPE_ANGLE = 30https://www.youtube.com/watch?v=v3zT3Z5apaM
|
||||
|
||||
@onready
|
||||
var camera = $CSGMesh3D/Camera3D
|
||||
|
@ -27,7 +30,7 @@ func _ready():
|
|||
|
||||
func _physics_process(delta):
|
||||
# Shamelessly stolen code from quake :)
|
||||
|
||||
|
||||
var fmove = 0.0
|
||||
var smove = 0.0
|
||||
var upmove = 0.0
|
||||
|
@ -40,32 +43,31 @@ func _physics_process(delta):
|
|||
smove += -SIDE_SPEED
|
||||
if Input.is_action_pressed("move_right"):
|
||||
smove += SIDE_SPEED
|
||||
if Input.is_action_pressed("jump"):
|
||||
upmove += UP_SPEED
|
||||
#if Input.is_action_pressed("up"):
|
||||
# upmove += UP_SPEED
|
||||
if Input.is_action_pressed("run"):
|
||||
fmove *= 2.0
|
||||
smove *= 2.0
|
||||
|
||||
|
||||
var wishvel = Vector3()
|
||||
var cam_xform: Transform3D = camera.get_global_transform()
|
||||
var cam_basis: Basis = cam_xform.basis
|
||||
|
||||
|
||||
wishvel = cam_basis.z * fmove + cam_basis.x * smove
|
||||
|
||||
|
||||
if _noclip:
|
||||
wishvel.y += upmove
|
||||
# else:
|
||||
# wishvel.y = upmove
|
||||
|
||||
|
||||
var wishdir = wishvel.normalized()
|
||||
var wishspeed = wishvel.length()
|
||||
|
||||
|
||||
if wishspeed > MAX_SPEED:
|
||||
wishvel *= MAX_SPEED / wishspeed
|
||||
wishspeed = MAX_SPEED
|
||||
|
||||
if is_on_floor():
|
||||
velocity.y += upmove
|
||||
|
||||
if Input.is_action_pressed("jump") and is_on_floor():
|
||||
velocity.y += JUMP_SPEED
|
||||
|
||||
var vel = velocity
|
||||
if _noclip:
|
||||
vel = wishvel
|
||||
|
@ -73,66 +75,66 @@ func _physics_process(delta):
|
|||
vel = _apply_friction(vel, delta)
|
||||
vel = _apply_accel(vel, wishdir, wishspeed, delta)
|
||||
else:
|
||||
vel = _apply_air_accel(vel, wishvel, wishspeed, delta)
|
||||
|
||||
vel = _apply_air_accel(vel, wishvel, delta)
|
||||
|
||||
if not _noclip:
|
||||
vel.y += g * delta
|
||||
|
||||
|
||||
velocity = vel
|
||||
move_and_slide()
|
||||
|
||||
|
||||
$Ball.global_position = camera.global_position - camera.global_transform.basis.z * 2.0
|
||||
|
||||
|
||||
func _apply_friction(vel: Vector3, delta: float):
|
||||
var speed = sqrt(vel.x ** 2 + vel.z ** 2)
|
||||
if(speed == 0.0): return vel
|
||||
|
||||
|
||||
# TODO: edge detect friction?
|
||||
var friction = FRICTION
|
||||
|
||||
|
||||
var control = 0.0
|
||||
if speed < STOP_SPEED:
|
||||
control = STOP_SPEED
|
||||
else:
|
||||
control = speed
|
||||
|
||||
|
||||
var newspeed = speed - delta * control * friction
|
||||
|
||||
|
||||
if newspeed < 0.0:
|
||||
newspeed = 0.0
|
||||
|
||||
newspeed /= speed
|
||||
|
||||
else:
|
||||
newspeed /= speed
|
||||
|
||||
return vel * newspeed
|
||||
|
||||
|
||||
func _apply_accel(vel: Vector3, wishdir: Vector3, wishspeed: float, delta: float):
|
||||
var currentspeed = vel.dot(wishdir)
|
||||
var addspeed = wishspeed - currentspeed
|
||||
if addspeed <= 0.0:
|
||||
return vel
|
||||
|
||||
|
||||
var accelspeed = ACCEL * delta * wishspeed
|
||||
if accelspeed > addspeed:
|
||||
accelspeed = addspeed
|
||||
|
||||
|
||||
return vel + accelspeed * wishdir
|
||||
|
||||
func _apply_air_accel(vel: Vector3, wishvel: Vector3, wishspeed: float, delta: float):
|
||||
|
||||
func _apply_air_accel(vel: Vector3, wishvel: Vector3, delta: float):
|
||||
var wishveloc = wishvel.normalized()
|
||||
var wishspd = wishvel.length()
|
||||
|
||||
if wishspd > 30 * QUAKE:
|
||||
wishspd = 30 * QUAKE
|
||||
|
||||
|
||||
if wishspd > MAX_AIR_SPEED:
|
||||
wishspd = MAX_AIR_SPEED
|
||||
|
||||
var currentspeed = vel.dot(wishveloc)
|
||||
var addspeed = wishspd - currentspeed
|
||||
if addspeed <= 0:
|
||||
return vel
|
||||
|
||||
var accelspeed = ACCEL * wishspeed * delta
|
||||
|
||||
var accelspeed = AIR_ACCEL * wishspd * delta
|
||||
if accelspeed > addspeed:
|
||||
accelspeed = addspeed
|
||||
|
||||
|
||||
return vel + accelspeed * wishveloc
|
||||
|
||||
func _input(event):
|
||||
|
@ -142,22 +144,22 @@ func _input(event):
|
|||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
if _paused: return
|
||||
|
||||
|
||||
if event.is_action_pressed('noclip'):
|
||||
_noclip = not _noclip
|
||||
if _noclip:
|
||||
$CollisionShape3D.disabled = true
|
||||
else:
|
||||
$CollisionShape3D.disabled = false
|
||||
|
||||
|
||||
# Check for mouse motion input
|
||||
if event is InputEventMouseMotion:
|
||||
rotation.y += -event.relative.x * 0.005
|
||||
camera.rotation.x += -event.relative.y * 0.005
|
||||
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-70), deg_to_rad(70))
|
||||
|
||||
|
||||
if event.is_action_pressed("interact"):
|
||||
var space_state = get_world_3d().direct_space_state
|
||||
# use global coordinates, not local to node
|
||||
|
@ -169,4 +171,4 @@ func _input(event):
|
|||
var other: Node3D = result.collider
|
||||
if other.has_method('interact'):
|
||||
other.interact(self)
|
||||
|
||||
|
||||
|
|
30
world.tscn
30
world.tscn
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://cv8621s5oukrb"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://cv8621s5oukrb"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dyyf1q12dchhq" path="res://Player.tscn" id="2_jba6q"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://bqnoaomgwec3w" path="res://assets/maps/mapentities.obj" id="5_wn745"]
|
||||
[ext_resource type="Script" path="res://KeyOverlay.gd" id="6_crgb3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bp1fooevcl4lk" path="res://devworld.tscn" id="7_1im6f"]
|
||||
[ext_resource type="Script" path="res://Debug.gd" id="7_2k2sn"]
|
||||
[ext_resource type="Texture2D" uid="uid://dast4ubkinjb5" path="res://assets/textures/zombietextures_funny/kreb.png" id="7_f82yj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnk6bedcy6x6m" path="res://hazardcourse.tscn" id="8_t5ilw"]
|
||||
|
||||
[sub_resource type="SystemFont" id="SystemFont_4krkk"]
|
||||
|
@ -22,6 +23,10 @@ font_names = PackedStringArray("Monospace")
|
|||
[sub_resource type="LabelSettings" id="LabelSettings_f35h2"]
|
||||
font = SubResource("SystemFont_4l16k")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_4rf1u"]
|
||||
ambient_light_source = 1
|
||||
reflected_light_source = 1
|
||||
|
||||
[node name="Root" type="Node"]
|
||||
script = ExtResource("7_2k2sn")
|
||||
|
||||
|
@ -33,7 +38,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 18.9032, 0)
|
|||
light_color = Color(1, 0.862745, 0.721569, 1)
|
||||
light_energy = 16.0
|
||||
light_size = 400.0
|
||||
omni_range = 99.7884
|
||||
shadow_enabled = true
|
||||
omni_range = 181.439
|
||||
|
||||
[node name="Mapentities" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.039, 0, 0, 0, -1.70474e-09, 0.039, 0, -0.039, -1.70474e-09, 0, 0, 0)
|
||||
|
@ -61,3 +67,23 @@ offset_right = 113.0
|
|||
offset_bottom = 136.0
|
||||
text = "SPEED"
|
||||
label_settings = SubResource("LabelSettings_f35h2")
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_4rf1u")
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -5.12, 12.1948, -30.2711)
|
||||
light_energy = 500.0
|
||||
light_projector = ExtResource("7_f82yj")
|
||||
shadow_enabled = true
|
||||
spot_range = 52.48
|
||||
spot_angle = 26.8834
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="SpotLight3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, 0.0400009, 0)
|
||||
light_energy = 500.0
|
||||
light_projector = ExtResource("7_f82yj")
|
||||
light_negative = true
|
||||
shadow_enabled = true
|
||||
spot_range = 52.48
|
||||
spot_angle = 26.8834
|
||||
|
|
Loading…
Reference in a new issue