More movements and functions
This commit is contained in:
parent
7a782b8921
commit
209c75ba16
|
|
@ -638,7 +638,7 @@ animations = [ {
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 146 ), SubResource( 146 ), SubResource( 147 ), SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 146 ), SubResource( 146 ), SubResource( 146 ), SubResource( 146 ) ],
|
"frames": [ SubResource( 146 ), SubResource( 146 ), SubResource( 147 ), SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 146 ), SubResource( 146 ), SubResource( 146 ), SubResource( 146 ) ],
|
||||||
"loop": true,
|
"loop": false,
|
||||||
"name": "attack-shoot",
|
"name": "attack-shoot",
|
||||||
"speed": 15.0
|
"speed": 15.0
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -723,7 +723,7 @@ animations = [ {
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ) ],
|
"frames": [ SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ) ],
|
||||||
"loop": true,
|
"loop": false,
|
||||||
"name": "roll",
|
"name": "roll",
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,17 @@ jump_1={
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
attack_1={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":77,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
attack_secondary_1={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":44,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
move_left_2={
|
move_left_2={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
|
@ -217,12 +228,6 @@ jump_2={
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":74,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":74,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
shoot_1={
|
|
||||||
"deadzone": 0.5,
|
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":77,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
shoot_2={
|
shoot_2={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ ]
|
"events": [ ]
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,53 @@ func get_movement_direction() -> float:
|
||||||
desired_movement_vector.x = Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
desired_movement_vector.x = Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
||||||
return Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
return Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
||||||
|
|
||||||
|
var _wants_jump :bool
|
||||||
func wants_jump() -> bool:
|
func wants_jump() -> bool:
|
||||||
if Input.is_action_just_pressed("jump_" + str(player_number)):
|
if Input.is_action_just_pressed("jump_" + str(player_number)):
|
||||||
desired_movement_vector.y = 1
|
desired_movement_vector.y = 1
|
||||||
|
_wants_jump = true
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
|
_wants_jump = false
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
var _wants_shoot :bool
|
||||||
|
func wants_shoot() -> bool:
|
||||||
|
if Input.is_action_just_pressed("attack_" + str(player_number)):
|
||||||
|
_wants_shoot = true
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
_wants_shoot = false
|
||||||
|
return false
|
||||||
|
|
||||||
|
var _wants_attack_secondary :bool
|
||||||
|
func wants_attack_secondary() -> bool:
|
||||||
|
if Input.is_action_just_pressed("attack_secondary_" + str(player_number)):
|
||||||
|
_wants_attack_secondary = true
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
_wants_attack_secondary = false
|
||||||
|
return false
|
||||||
|
|
||||||
|
var _wants_dash :bool
|
||||||
|
func wants_dash() -> bool:
|
||||||
|
if Input.is_action_just_pressed("dash_" + str(player_number)):
|
||||||
|
_wants_dash = true
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
_wants_dash = false
|
||||||
|
return false
|
||||||
|
|
||||||
|
var _wants_roll :bool
|
||||||
|
func wants_roll() -> bool:
|
||||||
|
if Input.is_action_just_pressed("dash_" + str(player_number)) and Input.is_action_pressed("ui_up"):
|
||||||
|
_wants_roll = true
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
_wants_roll = false
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#TODO: This is probably not a good way to do this.
|
#TODO: This is probably not a good way to do this.
|
||||||
# we want to check input once and make decisions based on
|
# we want to check input once and make decisions based on
|
||||||
|
|
@ -39,18 +79,23 @@ func wants_jump() -> bool:
|
||||||
#func _state_process_physics_input_move():
|
#func _state_process_physics_input_move():
|
||||||
# get_movement_direction()
|
# get_movement_direction()
|
||||||
|
|
||||||
|
var physics_delta
|
||||||
# Probably better to do it this way then allocating individual
|
# Probably better to do it this way then allocating individual
|
||||||
# state functions that all do the same thing.
|
# state functions that all do the same thing.
|
||||||
func process_physics_input(delta):
|
func process_physics_input(delta):
|
||||||
# call the parent, Which would call the individuals
|
# call the parent, Which would call the individuals
|
||||||
.process_physics_input(delta)
|
.process_physics_input(delta)
|
||||||
# then process movement controls
|
# then process movement controls
|
||||||
|
physics_delta = delta
|
||||||
get_movement_direction()
|
get_movement_direction()
|
||||||
wants_jump()
|
wants_jump()
|
||||||
|
wants_shoot()
|
||||||
|
wants_attack_secondary()
|
||||||
|
wants_dash()
|
||||||
|
wants_roll()
|
||||||
|
|
||||||
|
|
||||||
func _state_process_physics_idle():
|
func _state_process_physics_idle():
|
||||||
|
|
||||||
if desired_movement_vector.y == 1:
|
if desired_movement_vector.y == 1:
|
||||||
request_state_change.call_func('jump')
|
request_state_change.call_func('jump')
|
||||||
|
|
||||||
|
|
@ -62,6 +107,43 @@ func _state_process_physics_idle():
|
||||||
#return fall_state
|
#return fall_state
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
if _wants_roll == true:
|
||||||
|
request_state_change.call_func('roll')
|
||||||
|
|
||||||
|
if _wants_shoot == true:
|
||||||
|
request_state_change.call_func('attack_shoot')
|
||||||
|
|
||||||
|
if _wants_attack_secondary == true:
|
||||||
|
request_state_change.call_func('attack_sword')
|
||||||
|
|
||||||
|
func _state_process_physics_attack_shoot():
|
||||||
|
if current_state.animation_finished == true:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
#return fall_state
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
|
||||||
|
func _state_process_physics_attack_sword():
|
||||||
|
if current_state.animation_finished == true:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
#return fall_state
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
func _state_process_physics_roll():
|
||||||
|
if current_state.animation_finished == true:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
move_actor_as_desired(physics_delta, parent.transform.x.x)
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
#return fall_state
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
|
||||||
func _state_process_physics_land():
|
func _state_process_physics_land():
|
||||||
if current_state.animation_finished == true:
|
if current_state.animation_finished == true:
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('idle')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=13 format=2]
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
||||||
|
|
@ -9,6 +9,10 @@
|
||||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=7]
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=7]
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/jump.tres" type="Resource" id=8]
|
[ext_resource path="res://src/actors/players/playerE/states/jump.tres" type="Resource" id=8]
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/fall.tres" type="Resource" id=9]
|
[ext_resource path="res://src/actors/players/playerE/states/fall.tres" type="Resource" id=9]
|
||||||
|
[ext_resource path="res://src/actors/players/playerE/states/attack_sword.tres" type="Resource" id=10]
|
||||||
|
[ext_resource path="res://src/actors/players/playerE/states/attack_shoot.tres" type="Resource" id=11]
|
||||||
|
[ext_resource path="res://src/actors/players/playerE/states/land.tres" type="Resource" id=12]
|
||||||
|
[ext_resource path="res://src/actors/players/playerE/states/roll.tres" type="Resource" id=13]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=3]
|
[sub_resource type="Resource" id=3]
|
||||||
resource_name = "move"
|
resource_name = "move"
|
||||||
|
|
@ -23,20 +27,6 @@ move_modifier_move_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
animation_sequence = [ "run" ]
|
animation_sequence = [ "run" ]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=4]
|
|
||||||
resource_local_to_scene = true
|
|
||||||
resource_name = "land"
|
|
||||||
script = ExtResource( 7 )
|
|
||||||
debug_state = false
|
|
||||||
timeout_seconds = 0.0
|
|
||||||
name = "land"
|
|
||||||
move_speed = 30.0
|
|
||||||
move_acceleration = 0.0
|
|
||||||
move_speed_modifier = 0.0
|
|
||||||
move_modifier_move_acceleration = 0.0
|
|
||||||
jerk_factor = 0.0
|
|
||||||
animation_sequence = [ "land" ]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 7, 14 )
|
extents = Vector2( 7, 14 )
|
||||||
|
|
||||||
|
|
@ -46,7 +36,7 @@ actor_type = "Player"
|
||||||
|
|
||||||
[node name="Movement_StateMachine" parent="." index="0"]
|
[node name="Movement_StateMachine" parent="." index="0"]
|
||||||
starting_state_name = "idle"
|
starting_state_name = "idle"
|
||||||
states = [ ExtResource( 4 ), ExtResource( 9 ), SubResource( 3 ), ExtResource( 8 ), SubResource( 4 ) ]
|
states = [ ExtResource( 4 ), ExtResource( 9 ), SubResource( 3 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
|
||||||
17
src/actors/players/playerE/states/attack_shoot.tres
Normal file
17
src/actors/players/playerE/states/attack_shoot.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "attack_shoot"
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "attack_shoot"
|
||||||
|
move_speed = 1.36422e-12
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "attack-shoot" ]
|
||||||
17
src/actors/players/playerE/states/attack_sword.tres
Normal file
17
src/actors/players/playerE/states/attack_sword.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "attack_sword"
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "attack_sword"
|
||||||
|
move_speed = 1.36422e-12
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "attack-sword" ]
|
||||||
17
src/actors/players/playerE/states/land.tres
Normal file
17
src/actors/players/playerE/states/land.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "land"
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "land"
|
||||||
|
move_speed = 30.0
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "land" ]
|
||||||
17
src/actors/players/playerE/states/roll.tres
Normal file
17
src/actors/players/playerE/states/roll.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "roll"
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "roll"
|
||||||
|
move_speed = 150.0
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "roll" ]
|
||||||
Loading…
Reference in New Issue
Block a user