mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-05 10:09:47 +03:00
Code cleanup
This commit is contained in:
@@ -29,11 +29,11 @@ func _physics_process(delta):
|
||||
get_node("axes/axis_prog" + str(axis)).set_value(100*axis_value)
|
||||
get_node("axes/axis_val" + str(axis)).set_text(str(axis_value))
|
||||
# Show joypad direction indicators
|
||||
if (axis <= JOY_ANALOG_RY):
|
||||
if (abs(axis_value) < DEADZONE):
|
||||
if axis <= JOY_ANALOG_RY:
|
||||
if abs(axis_value) < DEADZONE:
|
||||
get_node("diagram/axes/" + str(axis) + "+").hide()
|
||||
get_node("diagram/axes/" + str(axis) + "-").hide()
|
||||
elif (axis_value > 0):
|
||||
elif axis_value > 0:
|
||||
get_node("diagram/axes/" + str(axis) + "+").show()
|
||||
get_node("diagram/axes/" + str(axis) + "-").hide()
|
||||
else:
|
||||
@@ -42,7 +42,7 @@ func _physics_process(delta):
|
||||
|
||||
# Loop through the buttons and highlight the ones that are pressed
|
||||
for btn in range(JOY_BUTTON_0, JOY_BUTTON_MAX):
|
||||
if (Input.is_joy_button_pressed(joy_num, btn)):
|
||||
if Input.is_joy_button_pressed(joy_num, btn):
|
||||
get_node("buttons/btn" + str(btn)).add_color_override("font_color", Color(1, 1, 1, 1))
|
||||
get_node("diagram/buttons/" + str(btn)).show()
|
||||
else:
|
||||
|
||||
@@ -19,7 +19,7 @@ func get_basis_for_arrow(p_vector):
|
||||
|
||||
# get an arbitrary vector we can use to calculate our other two vectors
|
||||
var v = Vector3(1.0, 0.0, 0.0)
|
||||
if (abs(v.dot(rotate.y)) > 0.9):
|
||||
if abs(v.dot(rotate.y)) > 0.9:
|
||||
v = Vector3(0.0, 1.0, 0.0)
|
||||
|
||||
# use our vector to get a vector perpendicular to our two vectors
|
||||
@@ -82,7 +82,7 @@ func drift_correction(p_basis, p_grav):
|
||||
var dot = p_basis.y.dot(real_up)
|
||||
|
||||
# if our dot is 1.0 we're good
|
||||
if (dot < 1.0):
|
||||
if dot < 1.0:
|
||||
# the cross between our two vectors gives us a vector perpendicular to our two vectors
|
||||
var axis = p_basis.y.cross(real_up).normalized()
|
||||
var correction = Basis(axis, acos(dot))
|
||||
@@ -138,4 +138,3 @@ func _process(delta):
|
||||
gyro_and_grav.transform.basis = drift_correction(new_basis, grav)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ func _bg_load_done():
|
||||
|
||||
|
||||
func _on_load_pressed():
|
||||
if (thread.is_active()):
|
||||
if thread.is_active():
|
||||
# Already working
|
||||
return
|
||||
print("START THREAD!")
|
||||
|
||||
@@ -96,13 +96,13 @@ func reset_tween():
|
||||
tween.interpolate_method(sprite, "set_modulate", get_node("colors/color_from/picker").get_pick_color(), get_node("colors/color_to/picker").get_pick_color(), 2, state.trans, state.eases)
|
||||
tween.interpolate_property(sprite, "modulate", get_node("colors/color_to/picker").get_pick_color(), get_node("colors/color_from/picker").get_pick_color(), 2, state.trans, state.eases, 2)
|
||||
else:
|
||||
sprite.set_modulate(Color(1,1,1,1))
|
||||
sprite.set_modulate(Color(1, 1, 1, 1))
|
||||
|
||||
if get_node("modes/scale").is_pressed():
|
||||
tween.interpolate_method(sprite, "set_scale", Vector2(0.5, 0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases)
|
||||
tween.interpolate_property(sprite, "scale", Vector2(1.5, 1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2)
|
||||
else:
|
||||
sprite.set_scale(Vector2(1,1))
|
||||
sprite.set_scale(Vector2(1, 1))
|
||||
|
||||
if get_node("modes/rotate").is_pressed():
|
||||
tween.interpolate_method(sprite, "set_rotation_degrees", 0, 360, 2, state.trans, state.eases)
|
||||
@@ -144,7 +144,7 @@ func _on_tween_step(object, key, elapsed, value):
|
||||
var tween = get_node("tween")
|
||||
var runtime = tween.get_runtime()
|
||||
|
||||
var ratio = 100*(elapsed/runtime)
|
||||
var ratio = 100 * (elapsed / runtime)
|
||||
timeline.set_value(ratio)
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ func _on_timeline_value_changed(value):
|
||||
|
||||
var tween = get_node("tween")
|
||||
var runtime = tween.get_runtime()
|
||||
tween.seek(runtime*value/100)
|
||||
tween.seek(runtime * value / 100)
|
||||
|
||||
|
||||
func on_callback(arg):
|
||||
|
||||
@@ -8,21 +8,21 @@ onready var observer = $"../Observer"
|
||||
func _physics_process(delta):
|
||||
var modetext = "Mode:\n"
|
||||
|
||||
if (OS.is_window_fullscreen()):
|
||||
if OS.is_window_fullscreen():
|
||||
modetext += "Fullscreen\n"
|
||||
else:
|
||||
modetext += "Windowed\n"
|
||||
|
||||
if (!OS.is_window_resizable()):
|
||||
if !OS.is_window_resizable():
|
||||
modetext += "FixedSize\n"
|
||||
|
||||
if (OS.is_window_minimized()):
|
||||
if OS.is_window_minimized():
|
||||
modetext += "Minimized\n"
|
||||
|
||||
if (OS.is_window_maximized()):
|
||||
if OS.is_window_maximized():
|
||||
modetext += "Maximized\n"
|
||||
|
||||
if (Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
modetext += "MouseGrab\n"
|
||||
$Label_MouseModeCaptured_KeyInfo.show()
|
||||
else:
|
||||
@@ -38,7 +38,7 @@ func _physics_process(delta):
|
||||
$Label_Screen0_Position.text = str("Screen0 Position:\n", OS.get_screen_position())
|
||||
$Label_Screen0_DPI.text = str("Screen0 DPI:\n", OS.get_screen_dpi())
|
||||
|
||||
if (OS.get_screen_count() > 1):
|
||||
if OS.get_screen_count() > 1:
|
||||
$Button_Screen0.show()
|
||||
$Button_Screen1.show()
|
||||
$Label_Screen1_Resolution.show()
|
||||
@@ -65,58 +65,58 @@ func _physics_process(delta):
|
||||
|
||||
func check_wm_api():
|
||||
var s = ""
|
||||
if (!OS.has_method("get_screen_count")):
|
||||
if !OS.has_method("get_screen_count"):
|
||||
s += " - get_screen_count()\n"
|
||||
|
||||
if (!OS.has_method("get_current_screen")):
|
||||
if !OS.has_method("get_current_screen"):
|
||||
s += " - get_current_screen()\n"
|
||||
|
||||
if (!OS.has_method("set_current_screen")):
|
||||
if !OS.has_method("set_current_screen"):
|
||||
s += " - set_current_screen()\n"
|
||||
|
||||
if (!OS.has_method("get_screen_position")):
|
||||
if !OS.has_method("get_screen_position"):
|
||||
s += " - get_screen_position()\n"
|
||||
|
||||
if (!OS.has_method("get_screen_size")):
|
||||
if !OS.has_method("get_screen_size"):
|
||||
s += " - get_screen_size()\n"
|
||||
|
||||
if (!OS.has_method("get_window_position")):
|
||||
if !OS.has_method("get_window_position"):
|
||||
s += " - get_window_position()\n"
|
||||
|
||||
if (!OS.has_method("set_window_position")):
|
||||
if !OS.has_method("set_window_position"):
|
||||
s += " - set_window_position()\n"
|
||||
|
||||
if (!OS.has_method("get_window_size")):
|
||||
if !OS.has_method("get_window_size"):
|
||||
s += " - get_window_size()\n"
|
||||
|
||||
if (!OS.has_method("set_window_size")):
|
||||
if !OS.has_method("set_window_size"):
|
||||
s += " - set_window_size()\n"
|
||||
|
||||
if (!OS.has_method("set_window_fullscreen")):
|
||||
if !OS.has_method("set_window_fullscreen"):
|
||||
s += " - set_window_fullscreen()\n"
|
||||
|
||||
if (!OS.has_method("is_window_fullscreen")):
|
||||
if !OS.has_method("is_window_fullscreen"):
|
||||
s += " - is_window_fullscreen()\n"
|
||||
|
||||
if (!OS.has_method("set_window_resizable")):
|
||||
if !OS.has_method("set_window_resizable"):
|
||||
s += " - set_window_resizable()\n"
|
||||
|
||||
if (!OS.has_method("is_window_resizable")):
|
||||
if !OS.has_method("is_window_resizable"):
|
||||
s += " - is_window_resizable()\n"
|
||||
|
||||
if (!OS.has_method("set_window_minimized")):
|
||||
if !OS.has_method("set_window_minimized"):
|
||||
s += " - set_window_minimized()\n"
|
||||
|
||||
if (!OS.has_method("is_window_minimized")):
|
||||
if !OS.has_method("is_window_minimized"):
|
||||
s += " - is_window_minimized()\n"
|
||||
|
||||
if (!OS.has_method("set_window_maximized")):
|
||||
if !OS.has_method("set_window_maximized"):
|
||||
s += " - set_window_maximized()\n"
|
||||
|
||||
if (!OS.has_method("is_window_maximized")):
|
||||
if !OS.has_method("is_window_maximized"):
|
||||
s += " - is_window_maximized()\n"
|
||||
|
||||
if (s.length() == 0):
|
||||
if s.length() == 0:
|
||||
return true
|
||||
else:
|
||||
$"ImplementationDialog/Text".text += s
|
||||
@@ -125,16 +125,16 @@ func check_wm_api():
|
||||
|
||||
|
||||
func _ready():
|
||||
if (not check_wm_api()):
|
||||
if not check_wm_api():
|
||||
set_physics_process(false)
|
||||
set_process_input(false)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if (event is InputEventMouseMotion):
|
||||
if event is InputEventMouseMotion:
|
||||
mousepos = event.position
|
||||
|
||||
if (event is InputEventKey):
|
||||
if event is InputEventKey:
|
||||
if Input.is_action_pressed("mouse_mode_visible"):
|
||||
observer.state = observer.STATE_MENU
|
||||
_on_Button_MouseModeVisible_pressed()
|
||||
@@ -164,28 +164,28 @@ func _on_Button_Screen1_pressed():
|
||||
|
||||
|
||||
func _on_Button_Fullscreen_pressed():
|
||||
if (OS.is_window_fullscreen()):
|
||||
if OS.is_window_fullscreen():
|
||||
OS.set_window_fullscreen(false)
|
||||
else:
|
||||
OS.set_window_fullscreen(true)
|
||||
|
||||
|
||||
func _on_Button_FixedSize_pressed():
|
||||
if (OS.is_window_resizable()):
|
||||
if OS.is_window_resizable():
|
||||
OS.set_window_resizable(false)
|
||||
else:
|
||||
OS.set_window_resizable(true)
|
||||
|
||||
|
||||
func _on_Button_Minimized_pressed():
|
||||
if (OS.is_window_minimized()):
|
||||
if OS.is_window_minimized():
|
||||
OS.set_window_minimized(false)
|
||||
else:
|
||||
OS.set_window_minimized(true)
|
||||
|
||||
|
||||
func _on_Button_Maximized_pressed():
|
||||
if (OS.is_window_maximized()):
|
||||
if OS.is_window_maximized():
|
||||
OS.set_window_maximized(false)
|
||||
else:
|
||||
OS.set_window_maximized(true)
|
||||
|
||||
Reference in New Issue
Block a user