controller

This commit is contained in:
Holly Stubbs 2025-02-12 04:12:31 +00:00
parent 81ef11964c
commit 423912bbde
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
2 changed files with 27 additions and 3 deletions

View file

@ -5,12 +5,14 @@ func _ready() -> void:
#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"))
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
#RMesh.LoadRMesh(self, roomInfo["mesh path"]) #RMesh.LoadRMesh(self, roomInfo["mesh path"])
#CreateMap() #CreateMap()
IntroEnabled = true IntroEnabled = true
#LoadRoomTemplates("Data\\rooms.ini") LoadRoomTemplates("Data\\rooms.ini")
#CreateMap() CreateMap()
var IntroEnabled: bool var IntroEnabled: bool
var I_Zone: MapZones = MapZones.new() var I_Zone: MapZones = MapZones.new()

View file

@ -80,8 +80,17 @@ var MenuOpen = false
const WHITE = Color(1, 1, 1) const WHITE = Color(1, 1, 1)
const IRRITATED_RED = Color(0.78431372549, 0, 0) const IRRITATED_RED = Color(0.78431372549, 0, 0)
var cameraMoveByVector = Vector2()
func _process(delta: float) -> void: func _process(delta: float) -> void:
if (abs(cameraMoveByVector.x) > 0 or abs(cameraMoveByVector.y) > 0):
Rotation.x -= rad_to_deg(cameraMoveByVector.x * 120 * delta);
Rotation.y -= rad_to_deg(cameraMoveByVector.y * 120 * delta);
if Rotation.x > 70:
Rotation.x = 70
if Rotation.x < -70:
Rotation.x = -70
if Playable: if Playable:
if Input.is_action_just_pressed("player_blink"): if Input.is_action_just_pressed("player_blink"):
BlinkTimer = 0 BlinkTimer = 0
@ -437,6 +446,7 @@ func snapDownToFloorCheck():
wasOnFloorLastFrame = is_on_floor() wasOnFloorLastFrame = is_on_floor()
snappedLastFrame = didSnap snappedLastFrame = didSnap
const CONTROLLER_DEADZONE = 0.20;
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
Rotation.y -= event.relative.x / 2 Rotation.y -= event.relative.x / 2
@ -446,3 +456,15 @@ func _input(event: InputEvent) -> void:
if Rotation.x < -70: if Rotation.x < -70:
Rotation.x = -70 Rotation.x = -70
#event.velocity #event.velocity
if event is InputEventJoypadMotion:
# LeftRight = 2, UpDown = 3
if event.axis == 2:
if abs(event.axis_value) < CONTROLLER_DEADZONE:
cameraMoveByVector.y = 0;
else:
cameraMoveByVector.y = event.axis_value / 45;
elif event.axis == 3:
if abs(event.axis_value) < CONTROLLER_DEADZONE:
cameraMoveByVector.x = 0;
else:
cameraMoveByVector.x = event.axis_value / 45;