Compare commits

..

2 commits

Author SHA1 Message Date
Raxki e4f5814e44 Add game controller inputs 2024-08-29 12:54:35 -04:00
Raxki f998e7b904 Add attacks for Hiro 2024-08-29 12:54:07 -04:00
5 changed files with 838 additions and 692 deletions

View file

@ -1,28 +0,0 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,12 @@ extends CharacterBody2D
var last_dpad: Array[Vector2] = [Vector2.ZERO,Vector2.ZERO]
const FACING_ANGLE_EPSILON = 15
func _process(_delta):
if Input.is_action_pressed("melee") and $AnimationTree.get("parameters/conditions/melee") == false:
var animation_rng = randf_range(0, 1)
$AnimationTree.set("parameters/melee/blend_position", animation_rng)
$AnimationTree.set("parameters/conditions/melee", true)
func _physics_process(_delta):
get_input()
move_and_slide()
@ -28,6 +34,12 @@ func get_input():
if last_dpad[0] == Vector2.ZERO and input_direction != Vector2.ZERO:
last_dpad[0] = input_direction
if $AnimationTree.get("parameters/conditions/melee") ==true:
input_direction = Vector2.ZERO
last_dpad[0] = Vector2.ZERO
last_dpad[1] = Vector2.ZERO
velocity = input_direction * speed
if input_direction == Vector2.ZERO:
@ -38,3 +50,4 @@ func get_input():
$AnimationTree.set("parameters/walk/blend_position", last_dpad[0])
$AnimationTree.set("parameters/melee/0/blend_position", last_dpad[0])
$AnimationTree.set("parameters/melee/1/blend_position", last_dpad[0])
$AnimationTree.set("parameters/melee/2/blend_position", last_dpad[0])

View file

@ -56,22 +56,32 @@ ui_text_caret_right={
}
up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
]
}
down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":true,"script":null)
]
}
left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":true,"script":null)
]
}
melee={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
]
}

View file

@ -2,7 +2,7 @@
[ext_resource type="PackedScene" uid="uid://di21xheryhp0k" path="res://Hiro/hiro_player.tscn" id="1_c1gpq"]
[ext_resource type="PackedScene" uid="uid://b8sfype1vx5ad" path="res://Nem/nem_npc.tscn" id="1_sqt7d"]
[ext_resource type="Script" path="res://Scripts/hiro_player.gd" id="3_skjwh"]
[ext_resource type="Script" path="res://Scripts/hiro_player.gd" id="3_ckn0m"]
[ext_resource type="Texture2D" uid="uid://b40la2vyf4rn6" path="res://world/Fighting Dojo BG.png" id="4_elb6q"]
[ext_resource type="PackedScene" uid="uid://bakb5a7xe4qby" path="res://Reed/reed_player.tscn" id="6_cn8e2"]
@ -18,7 +18,7 @@ texture = ExtResource("4_elb6q")
[node name="HiroPlayer" parent="." instance=ExtResource("1_c1gpq")]
y_sort_enabled = true
position = Vector2(92, 178)
script = ExtResource("3_skjwh")
script = ExtResource("3_ckn0m")
[node name="ReedPlayer" parent="." instance=ExtResource("6_cn8e2")]
y_sort_enabled = true