SelectionList works, make FPSfactor match game better

This commit is contained in:
Holly Stubbs 2025-02-04 10:52:15 +00:00
parent 69575fdcc4
commit 9f75f9c63d
7 changed files with 89 additions and 20 deletions

View file

@ -7,6 +7,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 100.0
offset_bottom = 20.0
mouse_filter = 2
script = ExtResource("1_2f5i4")
[node name="ColorRect" type="ColorRect" parent="."]

View file

@ -7,6 +7,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 100.0
offset_bottom = 20.0
mouse_filter = 2
script = ExtResource("1_s8wxs")
[node name="ColorRect" type="ColorRect" parent="."]

View file

@ -9,8 +9,8 @@ layout_mode = 3
anchors_preset = 0
script = ExtResource("1_bao2f")
[node name="Selection" parent="." instance=ExtResource("2_v4kkt")]
color = Color(0, 0, 0, 1)
[node name="Hover" parent="." instance=ExtResource("2_v4kkt")]
color = Color(0.392157, 0.392157, 0.392157, 1)
[node name="Selection" parent="." instance=ExtResource("2_v4kkt")]
color = Color(0, 0, 0, 1)

View file

@ -59,6 +59,24 @@ func _ready():
LoadTexture("GFX/BlinkMeter.jpg")
func getMsec():
return Time.get_ticks_msec()
var CurTime = 0
var ElapsedTime = 0
var PrevTime = 0
func _process(delta):
FPSfactor = delta * 1000
#FPSfactor = delta * 1000
#FPSfactor = max(min(delta * 70, 5.0), 0.2)
#print(max(min(delta * 70, 5.0), 0.2))
CurTime = getMsec()
ElapsedTime = (CurTime - PrevTime) / 1000.0
PrevTime = CurTime
FPSfactor = max(min(ElapsedTime * 70, 5.0), 0.2)
if Engine.time_scale == 0:
FPSfactor = 0
#print(FPSfactor)

View file

@ -3,11 +3,14 @@ extends Control
func _ready() -> void:
DisplayServer.window_set_title("SCP - Containment Breach Launcher")
$Launch.connect("clicked", launch)
$Exit.connect("clicked", exit)
func launch():
get_tree().change_scene_to_file("res://scenes/screens/GameStartup.tscn")
func exit():
get_tree().quit.call_deferred()
$SelectionList.connect("selection_changed", func(resolutionRaw: String):
var resSplit = resolutionRaw.split("x")
Main.options.get("options")["width"] = resSplit[0]
Main.options.get("options")["height"] = resSplit[1]
)
$Launch.connect("clicked", func():
get_tree().change_scene_to_file("res://scenes/screens/GameStartup.tscn")
)
$Exit.connect("clicked", func():
get_tree().quit.call_deferred()
)

View file

@ -85,7 +85,6 @@ func _process(delta: float) -> void:
for i in range(barAmount, 20):
blinkBar.get_child(i).visible = false
func _physics_process(delta: float) -> void:
var Sprint = 1.0
var Speed = 0.018
@ -191,14 +190,14 @@ func _physics_process(delta: float) -> void:
movementSpeed = movementSpeed * NoClipSpeed
if Input.is_action_pressed("player_backwards"):
position.z += -movementSpeed * Global.FPSfactor
position.z += -movementSpeed * delta
if Input.is_action_pressed("player_forwards"):
position.z += movementSpeed * Global.FPSfactor
position.z += movementSpeed * delta
if Input.is_action_pressed("player_left"):
position.x += -movementSpeed * Global.FPSfactor
position.x += -movementSpeed * delta
if Input.is_action_pressed("ui_right"):
position.x += movementSpeed * Global.FPSfactor
position.x += movementSpeed * delta
else:
movementSpeed = movementSpeed / max((Injuries + 3.0) / 3.0, 1.0)
if Injuries > 0.5:
@ -240,8 +239,8 @@ func _physics_process(delta: float) -> void:
#print(str(cos(angle) * CurrSpeed * 100000 * Global.FPSfactor), " ", str(sin(angle) * CurrSpeed * 100000 * Global.FPSfactor))
#position.x += cos(angle) * CurrSpeed * 100000 * Global.FPSfactor
#position.z += sin(angle) * CurrSpeed * 100000 * Global.FPSfactor
var movementX = (direction.x * CurrSpeed) * 40 * Global.FPSfactor
var movementZ = (direction.z * CurrSpeed) * 40 * Global.FPSfactor
var movementX = (direction.x * CurrSpeed) * 160 * Global.FPSfactor
var movementZ = (direction.z * CurrSpeed) * 160 * Global.FPSfactor
#print(CurrSpeed, " ", direction.x, " ", direction.z, " ", str(movementX), " ", str(movementZ))
velocity.x = movementX
velocity.z = movementZ

View file

@ -1,12 +1,16 @@
extends Control
class_name SelectionList
@export var selectionList: Array
var options: Array
var selection: OutlineRect
var hover: OutlineRect
var selectedOption: Variant
var selectedIndex: int
signal selection_changed
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var font = load("res://GFX/font/cour/Courier New.ttf")
@ -34,3 +38,46 @@ func _ready() -> void:
option.add_child(label)
add_child(option)
why += 1
selection.position.x = 10
selection.position.y = 10
selectedOption = selectionList[selectedIndex]
selection_changed.emit.call_deferred(selectedOption)
var mousePos = Vector2i()
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
mousePos.x = event.position.x
mousePos.y = event.position.y
updateSelection(false)
if event is InputEventMouseButton:
if event.button_index == 1 and event.pressed:
updateSelection(true)
func updateSelection(pressed: bool):
var col = ((mousePos.x + 10) / 100)
var row = ((mousePos.y + 10) / 20) - 1
var index = row + col * 6
if index > selectionList.size() - 1 or row > 5 or col > 3 or row < 0 or col < 0:
hover.visible = false
return
if mousePos.x >= 10 + (100 * col) and mousePos.x < 10 + (100 * col) + 100 and mousePos.y >= 10 + (20 * row) and mousePos.y < 10 + (20 * row) + 20:
if pressed:
selectedIndex = index
selectedOption = selectionList[index]
selection.position.x = 10 + (100 * col)
selection.position.y = 10 + (20 * row)
selection_changed.emit(selectedOption)
hover.visible = true
else:
hover.visible = false
hover.position.x = 10 + (100 * col)
hover.position.y = 10 + (20 * row)
if mousePos.x == 0 and mousePos.y == 0:
selection.position.x = 10 + (100 * col)
selection.position.y = 10 + (20 * row)