clean up code

This commit is contained in:
c 2022-06-20 10:33:39 +02:00
parent d1017c6b07
commit 22e7cc855e
8 changed files with 14 additions and 72 deletions

View File

@ -1,6 +1,5 @@
extends Area
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
@ -11,7 +10,6 @@ var player
# Called when the node enters the scene tree for the first time.
func _ready():
player = get_node(@"../../../Player")
#pass # Replace with function body.
func _physics_process(delta):
rotate_y(delta)
@ -20,8 +18,6 @@ func _physics_process(delta):
player.addAntiDepressant()
queue_free()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -7,7 +7,6 @@ var downForceStrength = 0
#Mania
export var max_offset = 0.3 # Maximum hor/ver shake in pixels.
export var max_roll = 0.1 # Maximum rotation in radians (use sparingly).
#export (NodePath) var target # Assign the node this camera will follow.
var trauma = 0.0 # Current shake strength.
var trauma_power = 2 # Trauma exponent. Use [2, 3].
@ -35,15 +34,12 @@ func changeDownForce(force):
downForceStrength = force
func _process(delta):
# if target:
# global_position = get_node(target).global_position
func _process(_delta):
if trauma:
shake()
if downForceStrength<0:
if(pivot.rotation.x > -1.4):
#print(pivot.rotation.x)
pivot.rotate_x(downForceStrength)
@ -52,13 +48,8 @@ func shake():
var amount = pow(trauma, trauma_power)
noise_y += 1
# Using noise
#rotation = max_roll * amount * noise.get_noise_2d(noise.seed, noise_y)
v_offset = max_offset * amount * noise.get_noise_2d(noise.seed*3, noise_y)
h_offset = max_offset * amount * noise.get_noise_2d(noise.seed*2, noise_y)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func reset():
trauma = 0

View File

@ -1,10 +1,7 @@
extends OmniLight
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Declare member variables here.
var _noise = OpenSimplexNoise.new()
@ -20,7 +17,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(_delta):
if(OS.get_ticks_msec()%100<10):
light_energy = 1 + _noise.get_noise_1d(OS.get_ticks_msec())

30
Main.gd
View File

@ -1,9 +1,7 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Declare member variables here.
var wantToQuit = false
@ -24,9 +22,6 @@ var stableTimer
var maniaTimer
var depressionTimer
#var moodStabilizerTimer
#var antiDepressantTimer
var secondsPerWeek = 10
var rng = RandomNumberGenerator.new()
@ -62,22 +57,10 @@ func _ready():
stableTimer = $Timer/StableTimer
maniaTimer = $Timer/ManiaTimer
depressionTimer = $Timer/DepressionTimer
# moodStabilizerTimer = $Collectibles/MoodStabilizer/Timer
# antiDepressantTimer = $Collectibles/AntiDepressant/Timer
#add_child(stableTimer)
#add_child(maniaTimer)
#add_child(depressionTimer)
# add_child(moodStabilizerTimer)
# add_child(antiDepressantTimer)
stableTimer.connect("timeout", self, "_on_StableTimer_timeout")
maniaTimer.connect("timeout", self, "_on_ManiaTimer_timeout")
depressionTimer.connect("timeout", self, "_on_DepressionTimer_timeout")
# moodStabilizerTimer.connect("timeout", self, "_on_MoodStabilizerTimer_timeout")
# antiDepressantTimer.connect("timeout", self, "_on_AntiDepressantTimer_timeout")
stableTimer.set_wait_time(secondsPerWeek*averageStable+rng.randf_range(-secondsPerWeek/5,+secondsPerWeek/5))
stableTimer.start()
@ -86,7 +69,7 @@ func _ready():
theEnd = $HUD/AcceptDialog
func _input(event):
func _input(_event):
if Input.is_action_pressed("click"):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
wantToQuit = false
@ -220,7 +203,7 @@ func _process(delta):
changeEffectsByMood()
sun.rotate_x(delta/2)
sun.rotate_x(delta/3)
hudMood.text = String(mood)
@ -231,7 +214,6 @@ func _process(delta):
func _on_StableTimer_timeout():
print("StableTimer_timeout")
#mood = -1
p0 = 0
p1 = -1
t = 0
@ -242,7 +224,6 @@ func _on_StableTimer_timeout():
func _on_ManiaTimer_timeout():
print("ManiaTimer_timeout")
#mood = 0
p0 = 1
p1 = 0
t = 0
@ -252,7 +233,6 @@ func _on_ManiaTimer_timeout():
func _on_DepressionTimer_timeout():
print("DepressionTimer_timeout")
#mood = +1
p0 = -1
p1 = +1
t = 0
@ -272,14 +252,12 @@ func takingpill():
takingPill = false
func smoothMood(deltaTime: float):
#print(p0," ",p1)
t += deltaTime
if(t>1):
t=1
if(t<-1):
t=-1
mood = p0 * (1 - t) + p1 * t
#print(mood)
func showEnd():
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=38 format=2]
[gd_scene load_steps=39 format=2]
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource path="res://Camera.gd" type="Script" id=2]
@ -32,10 +32,13 @@ albedo_color = Color( 1, 0.890196, 0, 1 )
[sub_resource type="CapsuleMesh" id=9]
[sub_resource type="SpatialMaterial" id=10]
albedo_color = Color( 0.0784314, 1, 0, 1 )
albedo_color = Color( 0.905882, 0.0509804, 0.956863, 1 )
[sub_resource type="CapsuleShape" id=8]
[sub_resource type="SpatialMaterial" id=30]
albedo_color = Color( 0, 1, 0, 1 )
[sub_resource type="CubeMesh" id=4]
[sub_resource type="BoxShape" id=5]
@ -199,7 +202,7 @@ script = ExtResource( 9 )
[node name="MeshInstance" type="MeshInstance" parent="Collectibles/UnlimitedMeds"]
mesh = SubResource( 9 )
skeleton = NodePath("")
material/0 = SubResource( 10 )
material/0 = SubResource( 30 )
[node name="CollisionShape" type="CollisionShape" parent="Collectibles/UnlimitedMeds"]
shape = SubResource( 8 )

View File

@ -10,7 +10,6 @@ var player
# Called when the node enters the scene tree for the first time.
func _ready():
player = get_node(@"../../../Player")
#pass # Replace with function body.
func _physics_process(delta):
rotate_y(delta)

View File

@ -1,9 +1,7 @@
extends KinematicBody
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Declare member variables here.
var MAX_SPEED = 7
var ACCEL = 3.5
@ -91,12 +89,6 @@ func _physics_process(delta):
vel = move_and_slide(vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
func _input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
rotation_helper.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
@ -138,19 +130,6 @@ func _ready():
rotation_helper = $CameraPivot
hud = get_node(@"../HUD")
#pass # Replace with function body.
# 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 addMoodStabilizer():
moodStabilizer = moodStabilizer + 1

View File

@ -12,7 +12,6 @@ var main
func _ready():
player = get_node(@"../../Player")
main = get_node(@"../../")
pass # Replace with function body.
func _physics_process(delta):
rotate_y(delta)