launcher selection list WIP, Player controller :D

This commit is contained in:
Holly Stubbs 2025-02-03 02:12:15 +00:00
parent 0dea1e57bf
commit bef423c5a7
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
9 changed files with 154 additions and 44 deletions

View file

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://0k0j6ct7kxtt"]
[ext_resource type="Script" path="res://src/SelectionList.gd" id="1_bao2f"]
[node name="SelectionList" type="Control"]
custom_minimum_size = Vector2(100, 20)
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_bao2f")

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://dc8jcyubx5hv7"] [gd_scene load_steps=6 format=3 uid="uid://dc8jcyubx5hv7"]
[ext_resource type="Script" path="res://src/Launcher.gd" id="1_cf26g"] [ext_resource type="Script" path="res://src/Launcher.gd" id="1_cf26g"]
[ext_resource type="Texture2D" uid="uid://d3sh54nbyqqiu" path="res://GFX/menu/launcher.jpg" id="2_6ldjf"] [ext_resource type="Texture2D" uid="uid://d3sh54nbyqqiu" path="res://GFX/menu/launcher.jpg" id="2_6ldjf"]
[ext_resource type="PackedScene" uid="uid://0k0j6ct7kxtt" path="res://scenes/gui/SelectionList.tscn" id="3_1mhbm"]
[ext_resource type="PackedScene" uid="uid://5ktmpg8aurb7" path="res://scenes/gui/Button.tscn" id="3_nah2s"] [ext_resource type="PackedScene" uid="uid://5ktmpg8aurb7" path="res://scenes/gui/Button.tscn" id="3_nah2s"]
[ext_resource type="FontFile" uid="uid://xe31montgcoo" path="res://GFX/font/cour/Courier New.ttf" id="4_8vkjh"] [ext_resource type="FontFile" uid="uid://xe31montgcoo" path="res://GFX/font/cour/Courier New.ttf" id="4_8vkjh"]
@ -15,6 +16,7 @@ grow_vertical = 2
script = ExtResource("1_cf26g") script = ExtResource("1_cf26g")
[node name="BG" type="TextureRect" parent="."] [node name="BG" type="TextureRect" parent="."]
texture_filter = 1
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -23,6 +25,14 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("2_6ldjf") texture = ExtResource("2_6ldjf")
[node name="SelectionList" parent="." instance=ExtResource("3_1mhbm")]
layout_mode = 1
offset_left = 20.0
offset_top = 197.0
offset_right = 450.0
offset_bottom = 335.0
selectionList = ["1920x1080", "1680x1050", "1440x900", "1280x800", "1280x720", "1152x864", "1024x768", "800x600", "720x576", "720x480", "640x480"]
[node name="Launch" parent="." instance=ExtResource("3_nah2s")] [node name="Launch" parent="." instance=ExtResource("3_nah2s")]
custom_minimum_size = Vector2(100, 30) custom_minimum_size = Vector2(100, 30)
offset_left = 520.0 offset_left = 520.0

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://bw0tk6ml7gayq"] [gd_scene load_steps=7 format=3 uid="uid://bw0tk6ml7gayq"]
[ext_resource type="Script" path="res://src/DynamicMap.gd" id="1_mytgt"] [ext_resource type="Script" path="res://src/DynamicMap.gd" id="1_mytgt"]
[ext_resource type="Script" path="res://src/TempDebugCamera.gd" id="2_co6fy"] [ext_resource type="Script" path="res://src/TempDebugCamera.gd" id="2_co6fy"]
[ext_resource type="PackedScene" uid="uid://dm33ofcbh8sht" path="res://scenes/world/Player.tscn" id="3_58gow"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tvhkv"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tvhkv"]
sky_top_color = Color(0.483795, 0.593484, 0.746094, 1) sky_top_color = Color(0.483795, 0.593484, 0.746094, 1)
@ -22,9 +23,17 @@ script = ExtResource("1_mytgt")
environment = SubResource("Environment_d5g72") environment = SubResource("Environment_d5g72")
[node name="CameraPivot" type="Node3D" parent="."] [node name="CameraPivot" type="Node3D" parent="."]
visible = false
[node name="Camera3D" type="Camera3D" parent="CameraPivot"] [node name="Camera3D" type="Camera3D" parent="CameraPivot"]
script = ExtResource("2_co6fy") script = ExtResource("2_co6fy")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
[node name="Player" parent="." instance=ExtResource("3_58gow")]
[node name="CSGBox3D" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.97521, -1.86909, -3.06)
use_collision = true
size = Vector3(15.4238, 0.866943, 15.2599)

View file

@ -8,9 +8,19 @@ size = Vector3(1, 2, 1)
[node name="Player" type="CharacterBody3D"] [node name="Player" type="CharacterBody3D"]
script = ExtResource("1_n772d") script = ExtResource("1_n772d")
[node name="Camera" type="Camera3D" parent="."] [node name="Head" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0)
[node name="Camera" type="Camera3D" parent="Head"]
[node name="Collision" type="CollisionShape3D" parent="."] [node name="Collision" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("BoxShape3D_7hapa") shape = SubResource("BoxShape3D_7hapa")
[node name="FloorRay" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
target_position = Vector3(0, -0.1, 0)
hit_from_inside = true
[node name="FloorPick" type="RayCast3D" parent="."]
target_position = Vector3(0, -10, 0)

View file

@ -3,7 +3,7 @@ extends Node3D
var roomTemplatesRaw = Dictionary() var roomTemplatesRaw = Dictionary()
func _ready() -> void: func _ready() -> void:
#RMesh.LoadRMesh(self, "GFX\\map\\gatea_opt.rmesh") RMesh.LoadRMesh(self, "GFX\\map\\gatea_opt.rmesh")
#B3D.Load("GFX\\npcs\\106_2.b3d") #B3D.Load("GFX\\npcs\\106_2.b3d")
add_child(B3D.Load("GFX\\apache.b3d")) add_child(B3D.Load("GFX\\apache.b3d"))
var rooms = INI.Load("res://Data/rooms.ini") var rooms = INI.Load("res://Data/rooms.ini")
@ -172,29 +172,31 @@ func CreateMap():
# count the amount of rooms # count the amount of rooms
#For y = 1 To MapHeight - 1 #For y = 1 To MapHeight - 1
for y1 in range(1, MapHeight - 1): for y1 in range(MapHeight):
zone = GetZone(y) zone = GetZone(y)
for x1 in range(1, MapWidth - 1): for x1 in range(MapWidth):
if MapTemp[x1][y1] > 0: if MapTemp[x1][y1] > 0:
temp = min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1) temp = min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1)
temp = temp + min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1) temp = temp + min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1)
if MapTemp[x1][y1] < 255: if MapTemp[x1][y1] < 255:
MapTemp[x1][y1] = temp MapTemp[x1][y1] = temp
print(MapTemp[x1][y1])
match MapTemp[x1][y1]: match MapTemp[x1][y1]:
1: 1:
Room1Amount[zone] = Room1Amount[zone] +1 Room1Amount[zone] += 1
print("R1A ", Room1Amount[zone])
2: 2:
if min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1) == 2: if min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1) == 2:
Room2Amount[zone] = Room2Amount[zone] + 1 Room2Amount[zone] += 1
elif min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1) == 2: elif min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1) == 2:
Room2Amount[zone] = Room2Amount[zone] + 1 Room2Amount[zone] += 1
else: else:
Room2CAmount[zone] = Room2CAmount[zone] + 1 Room2CAmount[zone] += 1
3: 3:
Room3Amount[zone] = Room3Amount[zone] + 1 Room3Amount[zone] += 1
4: 4:
Room4Amount[zone] = Room4Amount[zone] + 1 Room4Amount[zone] += 1
# force more room1s (if needed) # force more room1s (if needed)
for i in range(0, 2): for i in range(0, 2):

View file

@ -52,4 +52,4 @@ func _ready():
LoadTexture("GFX/BlinkMeter.jpg") LoadTexture("GFX/BlinkMeter.jpg")
func _process(delta): func _process(delta):
FPSfactor = delta FPSfactor = delta * 1000

View file

@ -1,9 +1,15 @@
extends CharacterBody3D extends CharacterBody3D
var head: Node3D
var camera: Camera3D var camera: Camera3D
var floorRay: RayCast3D
var floorPick: RayCast3D
func _ready() -> void: func _ready() -> void:
camera = $Camera head = $Head
camera = $Head/Camera
floorRay = $FloorRay
floorPick = $FloorPick
var CurrSpeed: float var CurrSpeed: float
var CrouchState: float var CrouchState: float
@ -26,7 +32,7 @@ var PlayerFallingPickDistance: float
var NoClipSpeed: float var NoClipSpeed: float
var ForceAngle: float var ForceAngle: float
var DropSpeed: float var DropSpeed: float
var ShouldEntitiesFall: bool var ShouldEntitiesFall: bool = true
var Injuries: float var Injuries: float
@ -36,6 +42,17 @@ func _physics_process(delta: float) -> void:
var Sprint = 1.0 var Sprint = 1.0
var Speed = 0.018 var Speed = 0.018
if CurrSpeed > 0:
Stamina = min(Stamina + 0.15 * Global.FPSfactor / 1.25, 100.0)
else:
Stamina = min(Stamina + 0.15 * Global.FPSfactor * 1.25, 100.0)
if StaminaEffectTimer > 0:
StaminaEffectTimer = StaminaEffectTimer - (Global.FPSfactor / 70)
else:
if StaminaEffect != 1.0:
StaminaEffect = 1.0
if abs(CrouchState - Crouch) < 0.001: if abs(CrouchState - Crouch) < 0.001:
CrouchState = Crouch CrouchState = Crouch
else: else:
@ -43,9 +60,9 @@ func _physics_process(delta: float) -> void:
if not NoClip: if not NoClip:
if ((Input.is_action_pressed("player_backwards") or Input.is_action_pressed("player_forwards")) or (Input.is_action_pressed("player_right") or Input.is_action_pressed("player_left")) and Playable) or ForceMove > 0: if ((Input.is_action_pressed("player_backwards") or Input.is_action_pressed("player_forwards")) or (Input.is_action_pressed("player_right") or Input.is_action_pressed("player_left")) and Playable) or ForceMove > 0:
if Crouch == 0 and (Input.is_action_pressed("player_sprint")) and Stamina > 0.0 and (not IsZombie): if Crouch == 0 and Input.is_action_pressed("player_sprint") and Stamina > 0.0 and (not IsZombie):
Sprint = 2.5 Sprint = 2.5
Stamina = Stamina - Global.FPSfactor * 0.4 * StaminaEffect Stamina = Stamina - delta * 0.4 * StaminaEffect
if Stamina <= 0: if Stamina <= 0:
Stamina = -20.0 Stamina = -20.0
@ -69,9 +86,9 @@ func _physics_process(delta: float) -> void:
var shake = fmod(Shake, 360) var shake = fmod(Shake, 360)
#Local tempchn% #Local tempchn%
if not UnableToMove: if not UnableToMove:
Shake = fmod((Shake + Global.FPSfactor * min(Sprint, 1.5) * 7), 720) Shake = fmod((Shake + delta * min(Sprint, 1.5) * 7), 720)
if shake < 180 and fmod(Shake, 360) >= 180 and KillTimer >= 0: #if shake < 180 and fmod(Shake, 360) >= 180 and KillTimer >= 0:
print("step sound") #print("step sound")
#if CurrStepSFX == 0: #if CurrStepSFX == 0:
#temp = GetStepSound(Collider) #temp = GetStepSound(Collider)
# #
@ -107,7 +124,10 @@ func _physics_process(delta: float) -> void:
Sprint = 0.5 Sprint = 0.5
if Input.is_action_just_pressed("player_crouch") and Playable: if Input.is_action_just_pressed("player_crouch") and Playable:
Crouch = not Crouch if Crouch == 1:
Crouch = 0
else:
Crouch = 1
var movementSpeed = (Speed * Sprint) / (1.0 + CrouchState) var movementSpeed = (Speed * Sprint) / (1.0 + CrouchState)
@ -119,7 +139,7 @@ func _physics_process(delta: float) -> void:
#RotateEntity Collider, WrapAngle(EntityPitch(Camera)), WrapAngle(EntityYaw(Camera)), 0 #RotateEntity Collider, WrapAngle(EntityPitch(Camera)), WrapAngle(EntityYaw(Camera)), 0
camera.rotation.x = deg_to_rad(Rotation.x) camera.rotation.x = deg_to_rad(Rotation.x)
rotation.y = deg_to_rad(Rotation.y) head.rotation.y = deg_to_rad(Rotation.y)
movementSpeed = movementSpeed * NoClipSpeed movementSpeed = movementSpeed * NoClipSpeed
@ -142,33 +162,24 @@ func _physics_process(delta: float) -> void:
if not IsZombie: if not IsZombie:
if Input.is_action_pressed("player_backwards") and Playable: if Input.is_action_pressed("player_backwards") and Playable:
temp = true temp = true
angle = 180
if Input.is_action_pressed("player_left"):
angle = 135
if Input.is_action_pressed("player_right"):
angle = -135
elif Input.is_action_pressed("player_forwards") and Playable: # Or ForceMove>0 elif Input.is_action_pressed("player_forwards") and Playable: # Or ForceMove>0
temp = true temp = true
angle = 0
if Input.is_action_pressed("player_left"):
angle = 45
if Input.is_action_pressed("player_right"):
angle = -45
elif ForceMove > 0: elif ForceMove > 0:
temp = true temp = true
angle = ForceAngle angle = ForceAngle
elif Playable: elif Playable:
if Input.is_action_pressed("player_left"): if Input.is_action_pressed("player_left"):
angle = 90
temp = true temp = true
if Input.is_action_pressed("player_right"): if Input.is_action_pressed("player_right"):
angle = -90
temp = true temp = true
else: else:
temp = true temp = true
angle = ForceAngle angle = ForceAngle
angle = Utils.WrapAngle(Rotation.y + angle + 90.0) #angle = Utils.WrapAngle(Rotation.y + angle + 90.0)
var input_dir = Input.get_vector("player_left", "player_right", "player_forwards", "player_backwards")
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if temp: if temp:
CurrSpeed = Utils.CurveValue(movementSpeed, CurrSpeed, 20.0) CurrSpeed = Utils.CurveValue(movementSpeed, CurrSpeed, 20.0)
@ -179,10 +190,28 @@ func _physics_process(delta: float) -> void:
if not UnableToMove: if not UnableToMove:
#TranslateEntity Collider, Cos(angle)*CurrSpeed * FPSfactor, 0, Sin(angle)*CurrSpeed * FPSfactor, True #TranslateEntity Collider, Cos(angle)*CurrSpeed * FPSfactor, 0, Sin(angle)*CurrSpeed * FPSfactor, True
position.x += cos(angle) * CurrSpeed * 1000 * Global.FPSfactor #print(str(cos(angle) * CurrSpeed * 100000 * Global.FPSfactor), " ", str(sin(angle) * CurrSpeed * 100000 * Global.FPSfactor))
position.z += sin(angle) * CurrSpeed * 1000 * 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
#print(CurrSpeed, " ", direction.x, " ", direction.z, " ", str(movementX), " ", str(movementZ))
velocity.x = movementX
velocity.z = movementZ
var cameraRoll = max(min(sin(Shake / 2) * 2.5 * min(Injuries + 0.25, 3.0), 8.0), -8.0)
var cameraBob = (sin(Shake) / (20.0 + CrouchState * 20.0)) * 0.6
camera.rotation.x = deg_to_rad(Rotation.x)
camera.rotation.z = deg_to_rad(cameraRoll)
camera.position.y = cameraBob
head.position.y = 1.15 + 0.6 * (1 - CrouchState)
head.rotation.y = deg_to_rad(Rotation.y)
var CollidedFloor = false var CollidedFloor = false
if floorRay.is_colliding():
CollidedFloor = true
#For i = 1 To CountCollisions(Collider) #For i = 1 To CountCollisions(Collider)
#If CollisionY(Collider, i) < EntityY(Collider) - 0.25 Then CollidedFloor = True #If CollisionY(Collider, i) < EntityY(Collider) - 0.25 Then CollidedFloor = True
#Next #Next
@ -204,7 +233,8 @@ func _physics_process(delta: float) -> void:
else: else:
DropSpeed = min(max(DropSpeed - 0.006 * Global.FPSfactor, -2.0), 0.0) DropSpeed = min(max(DropSpeed - 0.006 * Global.FPSfactor, -2.0), 0.0)
if PlayerFallingPickDistance != 0: if PlayerFallingPickDistance != 0:
var pick = true#LinePick(EntityX(Collider),EntityY(Collider),EntityZ(Collider),0,-PlayerFallingPickDistance,0) floorPick.target_position.y = -PlayerFallingPickDistance
var pick = floorPick.is_colliding()#LinePick(EntityX(Collider),EntityY(Collider),EntityZ(Collider),0,-PlayerFallingPickDistance,0)
if pick: if pick:
DropSpeed = min(max(DropSpeed - 0.006 * Global.FPSfactor, -2.0), 0.0) DropSpeed = min(max(DropSpeed - 0.006 * Global.FPSfactor, -2.0), 0.0)
else: else:
@ -215,12 +245,19 @@ func _physics_process(delta: float) -> void:
if not UnableToMove and ShouldEntitiesFall: if not UnableToMove and ShouldEntitiesFall:
#TranslateEntity Collider, 0, DropSpeed * FPSfactor, 0 #TranslateEntity Collider, 0, DropSpeed * FPSfactor, 0
position.y += DropSpeed * Global.FPSfactor velocity.y += DropSpeed * Global.FPSfactor
if not UnableToMove:
move_and_slide()
ForceMove = false ForceMove = false
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
Rotation.y += event.relative.x Rotation.y -= event.relative.x / 2
Rotation.x += event.relative.y Rotation.x -= event.relative.y / 2
if Rotation.x > 70:
Rotation.x = 70
if Rotation.x < -70:
Rotation.x = -70
#event.velocity #event.velocity

33
src/SelectionList.gd Normal file
View file

@ -0,0 +1,33 @@
extends Control
@export var selectionList: Array
var options: Array
# 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")
for column in range(ceil(selectionList.size() / 6.0)):
var why = 0
for i in range(6 * column, (6 * column) + 6):
if i > selectionList.size() - 1:
continue
var option = Control.new()
option.position.x = 13 + (100 * column)
option.position.y = 10 + (20 * why)
option.size = Vector2(100, 20)
var label = Label.new()
label.text = selectionList[i]
label.add_theme_font_override("font", font)
label.add_theme_color_override("font_color", Color.BLACK)
label.add_theme_font_size_override("font_size", int(58 * Global.menuScale))
option.add_child(label)
add_child(option)
why += 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View file

@ -4,7 +4,7 @@ static func ReadString(reader:BufferStuffReader):
var length = reader.readInt() var length = reader.readInt()
return reader.readBuffer(length).get_string_from_ascii() return reader.readBuffer(length).get_string_from_ascii()
const WORLD_SCALE = 0.020 const WORLD_SCALE = 0.010
static func StripFilename(file: String): static func StripFilename(file: String):
var mi = "" var mi = ""
@ -261,7 +261,7 @@ static func LoadRMesh(parentNode: Node3D, file: String):
mat.albedo_texture = activeAlbedo mat.albedo_texture = activeAlbedo
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS if activeAlbedoHasAlpha else BaseMaterial3D.TRANSPARENCY_DISABLED mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS if activeAlbedoHasAlpha else BaseMaterial3D.TRANSPARENCY_DISABLED
meshInstance.set_surface_override_material(0, mat) meshInstance.set_surface_override_material(0, mat)
#meshInstance.create_trimesh_collision() meshInstance.create_trimesh_collision()
scene.add_child(meshInstance) scene.add_child(meshInstance)
#print("YOYOYO MARKER") #print("YOYOYO MARKER")
@ -316,7 +316,7 @@ static func LoadRMesh(parentNode: Node3D, file: String):
mat.albedo_color = Color.GREEN mat.albedo_color = Color.GREEN
meshInstance.set_surface_override_material(0, mat) meshInstance.set_surface_override_material(0, mat)
meshInstance.create_trimesh_collision() meshInstance.create_trimesh_collision()
meshInstance.visible = false meshInstance.visible = true
scene.add_child(meshInstance) scene.add_child(meshInstance)
# trigger boxes # trigger boxes