Updated camera script and started on Plans

pull/1/head
DAMO238 2020-03-19 15:57:31 +00:00
parent 7ab9f07fde
commit 052353b8ac
4 changed files with 54 additions and 8 deletions

View File

@ -1,16 +1,30 @@
extends Camera extends Camera
const TRANSLATION_SPEED : float = 0.1
const ROTATION_SPEED : float = 0.025
func _physics_process(delta : float) -> void: func _physics_process(delta : float) -> void:
if Input.is_action_pressed("camera_forward"): if Input.is_action_pressed("camera_forward"):
translate(Vector3(0, 0, 1)) translate(TRANSLATION_SPEED * Vector3(0, 0, -1))
if Input.is_action_pressed("camera_backward"): if Input.is_action_pressed("camera_backward"):
translate(Vector3(0, 0, -1)) translate(TRANSLATION_SPEED * Vector3(0, 0, 1))
if Input.is_action_pressed("camera_strafe_up"): if Input.is_action_pressed("camera_strafe_up"):
translate(Vector3(0, 1, 0)) translate(TRANSLATION_SPEED * Vector3(0, 1, 0))
if Input.is_action_pressed("camera_strafe_down"): if Input.is_action_pressed("camera_strafe_down"):
translate(Vector3(0, -1, 0)) translate(TRANSLATION_SPEED * Vector3(0, -1, 0))
if Input.is_action_pressed("camera_strafe_right"): if Input.is_action_pressed("camera_strafe_right"):
translate(Vector3(1, 0, 0)) translate(TRANSLATION_SPEED * Vector3(1, 0, 0))
if Input.is_action_pressed("camera_strafe_left"): if Input.is_action_pressed("camera_strafe_left"):
translate(Vector3(-1, 0, 0)) translate(TRANSLATION_SPEED * Vector3(-1, 0, 0))
if Input.is_action_pressed("camera_pitch_down"):
rotate_object_local(Vector3(1,0,0), -ROTATION_SPEED)
if Input.is_action_pressed("camera_pitch_up"):
rotate_object_local(Vector3(1,0,0), ROTATION_SPEED)
if Input.is_action_pressed("camera_roll_left"):
rotate_object_local(Vector3(0,0,1), ROTATION_SPEED)
if Input.is_action_pressed("camera_roll_right"):
rotate_object_local(Vector3(0,0,1), -ROTATION_SPEED)
if Input.is_action_pressed("camera_yaw_left"):
rotate_object_local(Vector3(0,1,0), ROTATION_SPEED)
if Input.is_action_pressed("camera_yaw_right"):
rotate_object_local(Vector3(0,1,0), -ROTATION_SPEED)

18
Scripts/Plan.gd Normal file
View File

@ -0,0 +1,18 @@
class_name Plan
const TURN_TIME : float = 5.0
var elements = [] # All elements of the plan thus far
var current_elements = [] # All elements of the next 5 seconds
func sanity_check() -> bool:
# Returns true if sane and false if insane
var total_time : float = 0.0
for current_element in current_elements:
var element : PlanElement = (current_element as PlanElement)
total_time += elemet.time
if !element.sanity_check():
return false
if total_time > TURN_TIME:
return false
return true

3
Scripts/PlanElement.gd Normal file
View File

@ -0,0 +1,3 @@
class_name PlanElement
var time = 0.0

View File

@ -8,9 +8,20 @@
config_version=4 config_version=4
_global_script_classes=[ ] _global_script_classes=[ {
"base": "Reference",
"class": "Plan",
"language": "GDScript",
"path": "res://Scripts/Plan.gd"
}, {
"base": "Reference",
"class": "PlanElement",
"language": "GDScript",
"path": "res://Scripts/PlanElement.gd"
} ]
_global_script_class_icons={ _global_script_class_icons={
"Plan": "",
"PlanElement": ""
} }
[application] [application]