mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-31 09:49:06 +03:00
Use StringName literals with Input methods
This commit is contained in:
@@ -12,13 +12,13 @@ func _ready():
|
||||
|
||||
func _process(delta):
|
||||
var velocity = Vector2.ZERO # The player's movement vector.
|
||||
if Input.is_action_pressed("move_right"):
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
velocity.x += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
velocity.x -= 1
|
||||
if Input.is_action_pressed("move_down"):
|
||||
if Input.is_action_pressed(&"move_down"):
|
||||
velocity.y += 1
|
||||
if Input.is_action_pressed("move_up"):
|
||||
if Input.is_action_pressed(&"move_up"):
|
||||
velocity.y -= 1
|
||||
|
||||
if velocity.length() > 0:
|
||||
|
||||
@@ -22,7 +22,7 @@ func update(_delta):
|
||||
emit_signal("finished", "idle")
|
||||
update_look_direction(input_direction)
|
||||
|
||||
if Input.is_action_pressed("run"):
|
||||
if Input.is_action_pressed(&"run"):
|
||||
speed = max_run_speed
|
||||
else:
|
||||
speed = max_walk_speed
|
||||
|
||||
@@ -30,5 +30,5 @@ func _physics_process(delta):
|
||||
move_and_slide()
|
||||
|
||||
# Check for jumping. is_on_floor() must be called after movement code.
|
||||
if is_on_floor() and Input.is_action_just_pressed("jump"):
|
||||
if is_on_floor() and Input.is_action_just_pressed(&"jump"):
|
||||
velocity.y = -JUMP_SPEED
|
||||
|
||||
@@ -62,11 +62,11 @@ func _integrate_forces(s):
|
||||
var new_siding_left = siding_left
|
||||
|
||||
# Get player input.
|
||||
var move_left = Input.is_action_pressed("move_left")
|
||||
var move_right = Input.is_action_pressed("move_right")
|
||||
var jump = Input.is_action_pressed("jump")
|
||||
var shoot = Input.is_action_pressed("shoot")
|
||||
var spawn = Input.is_action_pressed("spawn")
|
||||
var move_left = Input.is_action_pressed(&"move_left")
|
||||
var move_right = Input.is_action_pressed(&"move_right")
|
||||
var jump = Input.is_action_pressed(&"jump")
|
||||
var shoot = Input.is_action_pressed(&"shoot")
|
||||
var spawn = Input.is_action_pressed(&"spawn")
|
||||
|
||||
if spawn:
|
||||
call_deferred("_spawn_enemy_above")
|
||||
|
||||
@@ -105,7 +105,7 @@ func _ready():
|
||||
|
||||
func _process(_delta):
|
||||
if not Engine.is_editor_hint():
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
if Input.is_action_just_pressed(&"ui_accept"):
|
||||
await _reset_test(false)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func _ready():
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("restart_test"):
|
||||
if Input.is_action_just_pressed(&"restart_test"):
|
||||
if _current_test:
|
||||
_start_test(_current_test)
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ func _physics_process(_delta):
|
||||
_velocity.x = 0.0
|
||||
|
||||
# Handle horizontal controls.
|
||||
if Input.is_action_pressed("character_left"):
|
||||
if Input.is_action_pressed(&"character_left"):
|
||||
if position.x > 0.0:
|
||||
_velocity.x = -_motion_speed
|
||||
_keep_velocity = false
|
||||
_constant_velocity = Vector2.ZERO
|
||||
elif Input.is_action_pressed("character_right"):
|
||||
elif Input.is_action_pressed(&"character_right"):
|
||||
if position.x < 1024.0:
|
||||
_velocity.x = _motion_speed
|
||||
_keep_velocity = false
|
||||
@@ -40,7 +40,7 @@ func _physics_process(_delta):
|
||||
|
||||
# Handle jump controls and gravity.
|
||||
if is_on_floor():
|
||||
if not _jumping and Input.is_action_just_pressed("character_jump"):
|
||||
if not _jumping and Input.is_action_just_pressed(&"character_jump"):
|
||||
# Start jumping.
|
||||
_jumping = true
|
||||
_velocity.y = -_jump_force
|
||||
|
||||
@@ -27,12 +27,12 @@ func _physics_process(_delta):
|
||||
_velocity.x = 0.0
|
||||
|
||||
# Handle horizontal controls.
|
||||
if Input.is_action_pressed("character_left"):
|
||||
if Input.is_action_pressed(&"character_left"):
|
||||
if position.x > 0.0:
|
||||
_velocity.x = -_motion_speed
|
||||
_keep_velocity = false
|
||||
_constant_velocity = Vector2.ZERO
|
||||
elif Input.is_action_pressed("character_right"):
|
||||
elif Input.is_action_pressed(&"character_right"):
|
||||
if position.x < 1024.0:
|
||||
_velocity.x = _motion_speed
|
||||
_keep_velocity = false
|
||||
@@ -40,7 +40,7 @@ func _physics_process(_delta):
|
||||
|
||||
# Handle jump controls and gravity.
|
||||
if is_on_floor():
|
||||
if not _jumping and Input.is_action_just_pressed("character_jump"):
|
||||
if not _jumping and Input.is_action_just_pressed(&"character_jump"):
|
||||
# Start jumping.
|
||||
_jumping = true
|
||||
_velocity.y = -_jump_force
|
||||
|
||||
@@ -25,13 +25,13 @@ func _enter_tree():
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("toggle_full_screen"):
|
||||
if Input.is_action_just_pressed(&"toggle_full_screen"):
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
|
||||
if Input.is_action_just_pressed("toggle_debug_collision"):
|
||||
if Input.is_action_just_pressed(&"toggle_debug_collision"):
|
||||
var debug_collision_enabled = not _is_debug_collision_enabled()
|
||||
_set_debug_collision_enabled(debug_collision_enabled)
|
||||
if debug_collision_enabled:
|
||||
@@ -39,10 +39,10 @@ func _process(_delta):
|
||||
else:
|
||||
Log.print_log("Debug Collision OFF")
|
||||
|
||||
if Input.is_action_just_pressed("toggle_pause"):
|
||||
if Input.is_action_just_pressed(&"toggle_pause"):
|
||||
get_tree().paused = not get_tree().paused
|
||||
|
||||
if Input.is_action_just_pressed("exit"):
|
||||
if Input.is_action_just_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func _physics_process(delta):
|
||||
no_move_horizontal_time -= delta
|
||||
else:
|
||||
velocity.x = (Input.get_axis(&"move_left", &"move_right")) * speed.x
|
||||
if Input.is_action_pressed("walk"):
|
||||
if Input.is_action_pressed(&"walk"):
|
||||
velocity.x *= 0.2
|
||||
#warning-ignore:return_value_discarded
|
||||
# TODO: This information should be set to the CharacterBody properties instead of arguments: , Vector2.UP
|
||||
@@ -58,7 +58,7 @@ func _physics_process(delta):
|
||||
elif falling_slow:
|
||||
$AnimationTree["parameters/land/active"] = true
|
||||
falling_slow = false
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
if Input.is_action_just_pressed(&"jump"):
|
||||
$AnimationTree["parameters/jump/active"] = true
|
||||
velocity.y = -speed.y
|
||||
if abs(velocity.x) > 50:
|
||||
|
||||
@@ -71,7 +71,7 @@ func _ready():
|
||||
if get_tree().edited_scene_root != null:
|
||||
target.set_owner(get_tree().edited_scene_root)
|
||||
|
||||
target.name = "Target"
|
||||
target.name = &"Target"
|
||||
else:
|
||||
target = $Target
|
||||
|
||||
@@ -89,7 +89,7 @@ func _ready():
|
||||
if get_tree().edited_scene_root != null:
|
||||
middle_joint_target.set_owner(get_tree().edited_scene_root)
|
||||
|
||||
middle_joint_target.name = "MiddleJoint"
|
||||
middle_joint_target.name = &"MiddleJoint"
|
||||
else:
|
||||
middle_joint_target = get_node(^"MiddleJoint")
|
||||
|
||||
@@ -366,7 +366,7 @@ func _make_editor_sphere_at_node(node, color):
|
||||
# Add it as our child, and name it
|
||||
var indicator = MeshInstance3D.new()
|
||||
node.add_child(indicator)
|
||||
indicator.name = "(EditorOnly) Visual indicator"
|
||||
indicator.name = &"(EditorOnly) Visual indicator"
|
||||
|
||||
# We need to make a mesh for the mesh instance.
|
||||
# The code below makes a small sphere mesh
|
||||
|
||||
@@ -142,7 +142,7 @@ func _setup_for_editor():
|
||||
# add it as a child of this node, and name it.
|
||||
_editor_indicator = MeshInstance3D.new()
|
||||
add_child(_editor_indicator)
|
||||
_editor_indicator.name = "(EditorOnly) Visual indicator"
|
||||
_editor_indicator.name = &"(EditorOnly) Visual indicator"
|
||||
|
||||
# Make a sphere mesh for the MeshInstance3D
|
||||
var indicator_mesh = SphereMesh.new()
|
||||
|
||||
@@ -87,7 +87,7 @@ func process_input(delta):
|
||||
if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D):
|
||||
dir += cam_xform.basis[0]
|
||||
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
if Input.is_action_just_pressed(&"ui_cancel"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
|
||||
@@ -11,9 +11,9 @@ const DECELERATION = 4
|
||||
var velocity: Vector3
|
||||
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("exit"):
|
||||
if Input.is_action_just_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
if Input.is_action_just_pressed("reset_position"):
|
||||
if Input.is_action_just_pressed(&"reset_position"):
|
||||
position = start_position
|
||||
|
||||
var dir = Vector3()
|
||||
@@ -55,7 +55,7 @@ func _physics_process(delta):
|
||||
|
||||
# TODO: This information should be set to the CharacterBody properties instead of arguments.
|
||||
# Jumping code. is_on_floor() must come after move_and_slide().
|
||||
if is_on_floor() and Input.is_action_pressed("jump"):
|
||||
if is_on_floor() and Input.is_action_pressed(&"jump"):
|
||||
velocity.y = JUMP_SPEED
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func _ready():
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("restart_test"):
|
||||
if Input.is_action_just_pressed(&"restart_test"):
|
||||
if _current_test:
|
||||
_start_test(_current_test)
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ func _enter_tree():
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("toggle_full_screen"):
|
||||
if Input.is_action_just_pressed(&"toggle_full_screen"):
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
|
||||
if Input.is_action_just_pressed("toggle_debug_collision"):
|
||||
if Input.is_action_just_pressed(&"toggle_debug_collision"):
|
||||
var debug_collision_enabled = not _is_debug_collision_enabled()
|
||||
_set_debug_collision_enabled(debug_collision_enabled)
|
||||
if debug_collision_enabled:
|
||||
@@ -42,10 +42,10 @@ func _process(_delta):
|
||||
else:
|
||||
Log.print_log("Debug Collision OFF")
|
||||
|
||||
if Input.is_action_just_pressed("toggle_pause"):
|
||||
if Input.is_action_just_pressed(&"toggle_pause"):
|
||||
get_tree().paused = not get_tree().paused
|
||||
|
||||
if Input.is_action_just_pressed("exit"):
|
||||
if Input.is_action_just_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ func _physics_process(delta):
|
||||
dir.y = 0
|
||||
dir = dir.normalized()
|
||||
|
||||
var jump_attempt = Input.is_action_pressed("jump")
|
||||
var shoot_attempt = Input.is_action_pressed("shoot")
|
||||
var jump_attempt = Input.is_action_pressed(&"jump")
|
||||
var shoot_attempt = Input.is_action_pressed(&"shoot")
|
||||
|
||||
if is_on_floor():
|
||||
var sharp_turn = hspeed > 0.1 and rad2deg(acos(dir.dot(hdir))) > SHARP_TURN_THRESHOLD
|
||||
|
||||
@@ -5,9 +5,9 @@ extends RigidDynamicBody3D
|
||||
@onready var start_position = position
|
||||
|
||||
func _physics_process(_delta):
|
||||
if Input.is_action_just_pressed("exit"):
|
||||
if Input.is_action_just_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
if Input.is_action_just_pressed("reset_position"):
|
||||
if Input.is_action_just_pressed(&"reset_position"):
|
||||
position = start_position
|
||||
return
|
||||
|
||||
@@ -24,7 +24,7 @@ func _physics_process(_delta):
|
||||
apply_central_impulse(dir.normalized() / 10)
|
||||
|
||||
# Jumping code.
|
||||
if on_ground() and Input.is_action_pressed("jump"):
|
||||
if on_ground() and Input.is_action_pressed(&"jump"):
|
||||
apply_central_impulse(Vector3.UP)
|
||||
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ extends Control
|
||||
var town = null
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("back"):
|
||||
if Input.is_action_just_pressed(&"back"):
|
||||
_on_Back_pressed()
|
||||
|
||||
|
||||
func _load_scene(car):
|
||||
var tt = load(car).instantiate()
|
||||
tt.set_name("car")
|
||||
tt.name = &"car"
|
||||
town = load("res://town_scene.tscn").instantiate()
|
||||
town.get_node(^"InstancePos").add_child(tt)
|
||||
town.get_node(^"Back").connect(&"pressed", self._on_Back_pressed)
|
||||
|
||||
@@ -13,7 +13,7 @@ func _physics_process(delta):
|
||||
steer_target = Input.get_axis(&"turn_right", &"turn_left")
|
||||
steer_target *= STEER_LIMIT
|
||||
|
||||
if Input.is_action_pressed("accelerate"):
|
||||
if Input.is_action_pressed(&"accelerate"):
|
||||
# Increase engine force at low speeds to make the initial acceleration faster.
|
||||
var speed = linear_velocity.length()
|
||||
if speed < 5 and speed != 0:
|
||||
@@ -23,7 +23,7 @@ func _physics_process(delta):
|
||||
else:
|
||||
engine_force = 0
|
||||
|
||||
if Input.is_action_pressed("reverse"):
|
||||
if Input.is_action_pressed(&"reverse"):
|
||||
# Increase engine force at low speeds to make the initial acceleration faster.
|
||||
if fwd_mps >= -1:
|
||||
var speed = linear_velocity.length()
|
||||
|
||||
@@ -6,7 +6,7 @@ extends Label
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("debug"):
|
||||
if Input.is_action_just_pressed(&"debug"):
|
||||
visible = not visible
|
||||
|
||||
text = "Position: " + _vector_to_string_appropriate_digits(player.transform.origin)
|
||||
|
||||
@@ -9,7 +9,7 @@ extends Control
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("pause"):
|
||||
if Input.is_action_just_pressed(&"pause"):
|
||||
pause.visible = crosshair.visible
|
||||
crosshair.visible = not crosshair.visible
|
||||
options.visible = false
|
||||
|
||||
@@ -26,15 +26,15 @@ func _process(_delta):
|
||||
# Block selection.
|
||||
var ray_position = raycast.get_collision_point()
|
||||
var ray_normal = raycast.get_collision_normal()
|
||||
if Input.is_action_just_pressed("pick_block"):
|
||||
if Input.is_action_just_pressed(&"pick_block"):
|
||||
# Block picking.
|
||||
var block_global_position = Vector3i((ray_position - ray_normal / 2).floor())
|
||||
_selected_block = voxel_world.get_block_global_position(block_global_position)
|
||||
else:
|
||||
# Block prev/next keys.
|
||||
if Input.is_action_just_pressed("prev_block"):
|
||||
if Input.is_action_just_pressed(&"prev_block"):
|
||||
_selected_block -= 1
|
||||
if Input.is_action_just_pressed("next_block"):
|
||||
if Input.is_action_just_pressed(&"next_block"):
|
||||
_selected_block += 1
|
||||
_selected_block = wrapi(_selected_block, 1, 30)
|
||||
# Set the appropriate texture.
|
||||
@@ -43,8 +43,8 @@ func _process(_delta):
|
||||
|
||||
# Block breaking/placing.
|
||||
if crosshair.visible and raycast.is_colliding():
|
||||
var breaking = Input.is_action_just_pressed("break")
|
||||
var placing = Input.is_action_just_pressed("place")
|
||||
var breaking = Input.is_action_just_pressed(&"break")
|
||||
var placing = Input.is_action_just_pressed(&"place")
|
||||
# Either both buttons were pressed or neither are, so stop.
|
||||
if breaking == placing:
|
||||
return
|
||||
@@ -62,7 +62,7 @@ func _physics_process(delta):
|
||||
camera_effects.dof_blur_far_distance = Settings.fog_distance * 1.5
|
||||
camera_effects.dof_blur_far_transition = Settings.fog_distance / 8
|
||||
# Crouching.
|
||||
var crouching = Input.is_action_pressed("crouch")
|
||||
var crouching = Input.is_action_pressed(&"crouch")
|
||||
if crouching:
|
||||
head.transform.origin = Vector3(0, 1.2, 0)
|
||||
else:
|
||||
@@ -82,7 +82,7 @@ func _physics_process(delta):
|
||||
move_and_slide()
|
||||
|
||||
# Jumping, applied next frame.
|
||||
if is_on_floor() and Input.is_action_pressed("jump"):
|
||||
if is_on_floor() and Input.is_action_pressed(&"jump"):
|
||||
velocity.y = 5
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func _add_placeholder_key(container):
|
||||
var placeholder = Control.new()
|
||||
placeholder.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
placeholder.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
placeholder.name = "Placeholder"
|
||||
placeholder.name = &"Placeholder"
|
||||
container.add_child(placeholder)
|
||||
|
||||
|
||||
|
||||
@@ -113,17 +113,17 @@ func set_view_mode(view_mode_index):
|
||||
# This can be changed or removed in actual games where you only need one view mode.
|
||||
func _check_view_mode():
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_just_pressed("forty_five_mode"):
|
||||
if Input.is_action_just_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_just_pressed("isometric_mode"):
|
||||
elif Input.is_action_just_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_just_pressed("top_down_mode"):
|
||||
elif Input.is_action_just_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_just_pressed("front_side_mode"):
|
||||
elif Input.is_action_just_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_just_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_just_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_just_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_just_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ func _ready():
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_pressed("exit"):
|
||||
if Input.is_action_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
|
||||
if Input.is_action_just_pressed("view_cube_demo"):
|
||||
if Input.is_action_just_pressed(&"view_cube_demo"):
|
||||
# warning-ignore:return_value_discarded
|
||||
get_tree().change_scene("res://assets/demo_scene.tscn")
|
||||
return
|
||||
|
||||
if _is_parent_ready:
|
||||
if Input.is_action_just_pressed("reset_position"):
|
||||
if Input.is_action_just_pressed(&"reset_position"):
|
||||
transform = Transform3D.IDENTITY
|
||||
else:
|
||||
rotate_x(delta * (Input.get_axis(&"move_forward", &"move_back")))
|
||||
|
||||
@@ -10,17 +10,17 @@ extends Sprite2D
|
||||
|
||||
func _process(_delta):
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_pressed("forty_five_mode"):
|
||||
if Input.is_action_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_pressed("isometric_mode"):
|
||||
elif Input.is_action_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_pressed("top_down_mode"):
|
||||
elif Input.is_action_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_pressed("front_side_mode"):
|
||||
elif Input.is_action_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@ var isometric_controls := true
|
||||
@onready var _parent_node25d: Node25D = get_parent()
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_pressed("exit"):
|
||||
if Input.is_action_pressed(&"exit"):
|
||||
get_tree().quit()
|
||||
|
||||
if Input.is_action_just_pressed("view_cube_demo"):
|
||||
if Input.is_action_just_pressed(&"view_cube_demo"):
|
||||
#warning-ignore:return_value_discarded
|
||||
get_tree().change_scene("res://assets/cube/cube.tscn")
|
||||
return
|
||||
|
||||
if Input.is_action_just_pressed("toggle_isometric_controls"):
|
||||
if Input.is_action_just_pressed(&"toggle_isometric_controls"):
|
||||
isometric_controls = not isometric_controls
|
||||
if Input.is_action_just_pressed("reset_position"):
|
||||
if Input.is_action_just_pressed(&"reset_position"):
|
||||
transform = Transform3D(Basis(), Vector3.UP * 10)
|
||||
vertical_speed = 0
|
||||
else:
|
||||
@@ -35,11 +35,11 @@ func _horizontal_movement(delta):
|
||||
localZ = Vector3(0.70710678118, 0, 0.70710678118)
|
||||
|
||||
# Gather player input and add directional movement to a Vector3 variable.
|
||||
var movement_vec2 = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
||||
var movement_vec2 = Input.get_vector(&"move_left", &"move_right", &"move_forward", &"move_back")
|
||||
var move_dir = localX * movement_vec2.x + localZ * movement_vec2.y
|
||||
|
||||
move_dir = move_dir * delta * 600
|
||||
if Input.is_action_pressed("movement_modifier"):
|
||||
if Input.is_action_pressed(&"movement_modifier"):
|
||||
move_dir /= 2
|
||||
|
||||
#warning-ignore:return_value_discarded
|
||||
@@ -49,7 +49,7 @@ func _horizontal_movement(delta):
|
||||
# Checks Jump and applies gravity and vertical speed via move_and_collide.
|
||||
func _vertical_movement(delta):
|
||||
var localY = Vector3.UP
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
if Input.is_action_just_pressed(&"jump"):
|
||||
vertical_speed = 1.25
|
||||
vertical_speed -= delta * 5 # Gravity
|
||||
var k = move_and_collide(localY * vertical_speed)
|
||||
|
||||
@@ -30,7 +30,7 @@ func _process(delta):
|
||||
if movement:
|
||||
hframes = 6
|
||||
texture = _run
|
||||
if (Input.is_action_pressed("movement_modifier")):
|
||||
if (Input.is_action_pressed(&"movement_modifier")):
|
||||
delta /= 2
|
||||
_progress = fmod((_progress + FRAMERATE * delta), 6)
|
||||
frame = _direction * 6 + int(_progress)
|
||||
@@ -72,17 +72,17 @@ func set_view_mode(view_mode_index):
|
||||
# Change the 2D basis of the sprite to try and make it "fit" multiple view modes.
|
||||
func _sprite_basis():
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_pressed("forty_five_mode"):
|
||||
if Input.is_action_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_pressed("isometric_mode"):
|
||||
elif Input.is_action_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_pressed("top_down_mode"):
|
||||
elif Input.is_action_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_pressed("front_side_mode"):
|
||||
elif Input.is_action_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
@@ -92,25 +92,25 @@ func _check_movement() -> bool:
|
||||
var x := 0
|
||||
var z := 0
|
||||
|
||||
if Input.is_action_pressed("move_right"):
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
x += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
x -= 1
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
if Input.is_action_pressed(&"move_forward"):
|
||||
z -= 1
|
||||
if Input.is_action_pressed("move_back"):
|
||||
if Input.is_action_pressed(&"move_back"):
|
||||
z += 1
|
||||
|
||||
# Check for isometric controls and add more to movement accordingly.
|
||||
# For efficiency, only check the X axis since this X axis value isn't used anywhere else.
|
||||
if not _parent_math.isometric_controls and is_equal_approx(Node25D.SCALE * 0.86602540378, _parent_node25d.get_basis()[0].x):
|
||||
if Input.is_action_pressed("move_right"):
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
z += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
z -= 1
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
if Input.is_action_pressed(&"move_forward"):
|
||||
x += 1
|
||||
if Input.is_action_pressed("move_back"):
|
||||
if Input.is_action_pressed(&"move_back"):
|
||||
x -= 1
|
||||
|
||||
# Set the direction based on which inputs were pressed.
|
||||
|
||||
@@ -10,17 +10,17 @@ extends Sprite2D
|
||||
|
||||
func _process(_delta):
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_pressed("forty_five_mode"):
|
||||
if Input.is_action_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_pressed("isometric_mode"):
|
||||
elif Input.is_action_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_pressed("top_down_mode"):
|
||||
elif Input.is_action_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_pressed("front_side_mode"):
|
||||
elif Input.is_action_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("toggle_control_hints"):
|
||||
if Input.is_action_just_pressed(&"toggle_control_hints"):
|
||||
visible = not visible
|
||||
|
||||
@@ -68,15 +68,15 @@ func _unhandled_input(event):
|
||||
mousepos = event.position
|
||||
|
||||
if event is InputEventKey:
|
||||
if Input.is_action_pressed("mouse_mode_visible"):
|
||||
if Input.is_action_pressed(&"mouse_mode_visible"):
|
||||
observer.state = observer.STATE_MENU
|
||||
_on_Button_MouseModeVisible_pressed()
|
||||
|
||||
if Input.is_action_pressed("mouse_mode_hidden"):
|
||||
if Input.is_action_pressed(&"mouse_mode_hidden"):
|
||||
observer.state = observer.STATE_MENU
|
||||
_on_Button_MouseModeHidden_pressed()
|
||||
|
||||
if Input.is_action_pressed("mouse_mode_captured"):
|
||||
if Input.is_action_pressed(&"mouse_mode_captured"):
|
||||
_on_Button_MouseModeCaptured_pressed()
|
||||
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ extends Sprite2D
|
||||
|
||||
func _process(_delta):
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_pressed("forty_five_mode"):
|
||||
if Input.is_action_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_pressed("isometric_mode"):
|
||||
elif Input.is_action_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_pressed("top_down_mode"):
|
||||
elif Input.is_action_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_pressed("front_side_mode"):
|
||||
elif Input.is_action_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ extends Sprite2D
|
||||
|
||||
func _process(_delta):
|
||||
if not Engine.editor_hint:
|
||||
if Input.is_action_pressed("forty_five_mode"):
|
||||
if Input.is_action_pressed(&"forty_five_mode"):
|
||||
set_view_mode(0)
|
||||
elif Input.is_action_pressed("isometric_mode"):
|
||||
elif Input.is_action_pressed(&"isometric_mode"):
|
||||
set_view_mode(1)
|
||||
elif Input.is_action_pressed("top_down_mode"):
|
||||
elif Input.is_action_pressed(&"top_down_mode"):
|
||||
set_view_mode(2)
|
||||
elif Input.is_action_pressed("front_side_mode"):
|
||||
elif Input.is_action_pressed(&"front_side_mode"):
|
||||
set_view_mode(3)
|
||||
elif Input.is_action_pressed("oblique_y_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_y_mode"):
|
||||
set_view_mode(4)
|
||||
elif Input.is_action_pressed("oblique_z_mode"):
|
||||
elif Input.is_action_pressed(&"oblique_z_mode"):
|
||||
set_view_mode(5)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("toggle_control_hints"):
|
||||
if Input.is_action_just_pressed(&"toggle_control_hints"):
|
||||
visible = not visible
|
||||
|
||||
@@ -25,16 +25,16 @@ func _physics_process(_delta):
|
||||
var motion = Vector2()
|
||||
|
||||
if is_network_master():
|
||||
if Input.is_action_pressed("move_left"):
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
motion += Vector2(-1, 0)
|
||||
if Input.is_action_pressed("move_right"):
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
motion += Vector2(1, 0)
|
||||
if Input.is_action_pressed("move_up"):
|
||||
if Input.is_action_pressed(&"move_up"):
|
||||
motion += Vector2(0, -1)
|
||||
if Input.is_action_pressed("move_down"):
|
||||
if Input.is_action_pressed(&"move_down"):
|
||||
motion += Vector2(0, 1)
|
||||
|
||||
var bombing = Input.is_action_pressed("set_bomb")
|
||||
var bombing = Input.is_action_pressed(&"set_bomb")
|
||||
|
||||
if stunned:
|
||||
bombing = false
|
||||
|
||||
@@ -50,18 +50,18 @@ func _process(delta):
|
||||
# Move left pad.
|
||||
var left_pos = left_paddle.get_position()
|
||||
|
||||
if left_pos.y > 0 and Input.is_action_pressed("left_move_up"):
|
||||
if left_pos.y > 0 and Input.is_action_pressed(&"left_move_up"):
|
||||
left_pos.y += -PAD_SPEED * delta
|
||||
if left_pos.y < screen_size.y and Input.is_action_pressed("left_move_down"):
|
||||
if left_pos.y < screen_size.y and Input.is_action_pressed(&"left_move_down"):
|
||||
left_pos.y += PAD_SPEED * delta
|
||||
|
||||
left_paddle.set_position(left_pos)
|
||||
|
||||
# Move right pad.
|
||||
var right_pos = right_paddle.get_position()
|
||||
if right_pos.y > 0 and Input.is_action_pressed("right_move_up"):
|
||||
if right_pos.y > 0 and Input.is_action_pressed(&"right_move_up"):
|
||||
right_pos.y += -PAD_SPEED * delta
|
||||
if right_pos.y < screen_size.y and Input.is_action_pressed("right_move_down"):
|
||||
if right_pos.y < screen_size.y and Input.is_action_pressed(&"right_move_down"):
|
||||
right_pos.y += PAD_SPEED * delta
|
||||
|
||||
right_paddle.set_position(right_pos)
|
||||
|
||||
Reference in New Issue
Block a user