Compare commits
4 Commits
ae9256f083
...
522e409dab
| Author | SHA1 | Date | |
|---|---|---|---|
| 522e409dab | |||
| 702782def7 | |||
| 1b7715746e | |||
| 27de78f02a |
|
|
@ -49,6 +49,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||||
#movement_state_machine.process_input(event)
|
#movement_state_machine.process_input(event)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
# Input based or polling input is not done in _unhandled_input
|
||||||
|
# gives us the ability to turn off polling this way
|
||||||
|
if actor_type == "Player":
|
||||||
|
movement_component.process_physics_input(delta)
|
||||||
movement_component.process_physics(delta)
|
movement_component.process_physics(delta)
|
||||||
#movement_state_machine.process_physics(delta)
|
#movement_state_machine.process_physics(delta)
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export var callable_state_machine :NodePath
|
||||||
|
|
||||||
onready var current_state = StateAnimatedActor.new()
|
onready var current_state = StateAnimatedActor.new()
|
||||||
|
|
||||||
var animation_finished: bool = false
|
#var animation_finished: bool = false
|
||||||
var request_state_change: FuncRef
|
var request_state_change: FuncRef
|
||||||
|
|
||||||
# this just wouldn't work well. Maybe I can try a resource
|
# this just wouldn't work well. Maybe I can try a resource
|
||||||
|
|
@ -42,13 +42,16 @@ func _ready():
|
||||||
# Sprites should only have a process function
|
# Sprites should only have a process function
|
||||||
# but if I have this will the sprite still animate?
|
# but if I have this will the sprite still animate?
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if current_state.state_timeout != null:
|
# Shouldn't need this anymore!
|
||||||
if current_state.state_timeout.time_left == 0:
|
# if current_state.state_timeout != null:
|
||||||
print("You're out of time! I saw it!")
|
# if current_state.state_timeout.time_left == 0:
|
||||||
request_state_change.call_func('idle')
|
# print("You're out of time! I saw it!")
|
||||||
#play()
|
# request_state_change.call_func('idle')
|
||||||
else:
|
# #play()
|
||||||
print("what, no current_state?")
|
# else:
|
||||||
|
# print("what, no current_state?")
|
||||||
|
|
||||||
|
# Not sure what should be called first here.
|
||||||
if has_method('_state_process_' + current_state.name):
|
if has_method('_state_process_' + current_state.name):
|
||||||
call('_state_process_' + current_state.name)
|
call('_state_process_' + current_state.name)
|
||||||
process_animations()
|
process_animations()
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,17 @@ func process_physics(delta):
|
||||||
if has_method('_state_process_physics_' + current_state.name):
|
if has_method('_state_process_physics_' + current_state.name):
|
||||||
call('_state_process_physics_' + current_state.name)
|
call('_state_process_physics_' + current_state.name)
|
||||||
|
|
||||||
# Shouldn't need a proces function
|
# more likely needed for Players
|
||||||
#func process(delta):
|
func process_physics_input(delta):
|
||||||
# pass
|
if has_method('_state_process_physics_input_' + current_state.name):
|
||||||
|
call('_state_process_physics_input_' + current_state.name)
|
||||||
|
|
||||||
|
# More likely needed for NPCs
|
||||||
|
func process(delta):
|
||||||
|
if has_method('_state_process_' + current_state.name):
|
||||||
|
call('_state_process_' + current_state.name)
|
||||||
|
|
||||||
|
# For event based input polling (Hadouken?)
|
||||||
func process_input(event: InputEvent):
|
func process_input(event: InputEvent):
|
||||||
if has_method('_state_process_input_' + current_state.name):
|
if has_method('_state_process_input_' + current_state.name):
|
||||||
call('_state_process_input_' + current_state.name)
|
call('_state_process_input_' + current_state.name)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ var jerk: float
|
||||||
|
|
||||||
var physics_modifier :StateModifier
|
var physics_modifier :StateModifier
|
||||||
|
|
||||||
|
var animation_finished: bool = false
|
||||||
|
|
||||||
# Not sure if this should be here. probably not
|
# Not sure if this should be here. probably not
|
||||||
export(Array, String) var animation_sequence
|
export(Array, String) var animation_sequence
|
||||||
|
|
||||||
|
|
@ -42,9 +44,10 @@ var modifier: StateModifier
|
||||||
|
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
|
|
||||||
# Call parent class enter
|
# Call parent class enter
|
||||||
.enter()
|
.enter()
|
||||||
|
animation_finished = false
|
||||||
jerk = 0
|
jerk = 0
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,12 @@ extends AnimatedSprite_StateReceiver
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
var state_ref :State
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
# state_ref = get_node(callable_state_machine).get_state_reference('idle')
|
||||||
|
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||||
|
|
||||||
|
state_ref = get_node(callable_state_machine).get_state_reference('fall')
|
||||||
|
state_ref.connect("state_entered", self, "_on_state_entered_fall")
|
||||||
# It works but node order really mattered.
|
# It works but node order really mattered.
|
||||||
# State machine needed to be processed first probably for ready function.
|
# State machine needed to be processed first probably for ready function.
|
||||||
# good to know!
|
# good to know!
|
||||||
|
|
@ -12,5 +16,13 @@ func _ready():
|
||||||
#func _state_process_idle():
|
#func _state_process_idle():
|
||||||
# print("I got called!")
|
# print("I got called!")
|
||||||
|
|
||||||
func _on_state_entered_idle():
|
#func _state_process_fall():
|
||||||
print("Anim Knows Idle State Entered!")
|
# print("I got called!")
|
||||||
|
|
||||||
|
#func _on_state_entered_idle():
|
||||||
|
# print("Anim Knows Idle State Entered!")
|
||||||
|
|
||||||
|
func _on_state_entered_fall():
|
||||||
|
print("Anim Knows Fall State Entered!")
|
||||||
|
frame = 2
|
||||||
|
stop()
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,59 @@
|
||||||
extends Movement_StateReceiver
|
extends Movement_StateReceiver
|
||||||
|
|
||||||
func _ready():
|
#func _ready():
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
# var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||||
# It works but node order really mattered.
|
# It works but node order really mattered.
|
||||||
# State machine needed to be processed first probably for ready function.
|
# State machine needed to be processed first probably for ready function.
|
||||||
# good to know!
|
# good to know!
|
||||||
|
|
||||||
var fire_a_note:bool = false
|
var player_number: int = 1
|
||||||
# I don't need this right now but I proved it can be done!
|
|
||||||
|
func get_movement_direction() -> float:
|
||||||
|
#return Input.get_axis('move_left', 'move_right')
|
||||||
|
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))
|
||||||
|
|
||||||
|
#TODO: This is probably not a good way to do this.
|
||||||
|
# we want to check input once and make decisions based on
|
||||||
|
# velocity and desired movement.
|
||||||
|
func _state_process_physics_input_idle():
|
||||||
|
get_movement_direction()
|
||||||
|
|
||||||
|
func _state_process_physics_input_move():
|
||||||
|
get_movement_direction()
|
||||||
|
|
||||||
func _state_process_physics_idle():
|
func _state_process_physics_idle():
|
||||||
if fire_a_note == true:
|
#TODO: May need that 'bump' logic to make velocity work.
|
||||||
print("I got called! (MC)")
|
if desired_movement_vector.x != 0: # and velocity.x != 0:
|
||||||
fire_a_note = false
|
request_state_change.call_func('move')
|
||||||
|
|
||||||
func _on_state_entered_idle():
|
if !parent.is_on_floor():
|
||||||
print("Movement State Idle State Entered!")
|
#return fall_state
|
||||||
fire_a_note = true
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
func _state_process_physics_fall():
|
||||||
|
if get_movement_direction() != 0.0:
|
||||||
|
parent.transform.x.x = get_movement_direction()
|
||||||
|
|
||||||
|
if parent.is_on_floor():
|
||||||
|
#modifier.reference()
|
||||||
|
#idle_state.modifier = landing_modifier
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
func _state_process_physics_move():
|
||||||
|
# flip sprite in direction
|
||||||
|
if get_movement_direction() != 0.0:
|
||||||
|
parent.transform.x.x = get_movement_direction()
|
||||||
|
|
||||||
|
if desired_movement_vector.x == 0:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
#func _on_state_entered_idle():
|
||||||
|
# print("Movement State Idle State Entered!")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=2]
|
[gd_scene load_steps=11 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]
|
||||||
|
|
@ -6,6 +6,38 @@
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/idle.tres" type="Resource" id=4]
|
[ext_resource path="res://src/actors/players/playerE/states/idle.tres" type="Resource" id=4]
|
||||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-AnimatedSprite_StateReceiver.gd" type="Script" id=5]
|
[ext_resource path="res://src/actors/players/playerE/PlayerE-AnimatedSprite_StateReceiver.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd" type="Script" id=6]
|
[ext_resource path="res://src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd" type="Script" id=6]
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=2]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "fall"
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "fall"
|
||||||
|
move_speed = 90.0
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "jump" ]
|
||||||
|
emitter_frame_subscriptions = {
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=3]
|
||||||
|
resource_name = "move"
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "move"
|
||||||
|
move_speed = 90.0
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "run" ]
|
||||||
|
emitter_frame_subscriptions = {
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 7, 14 )
|
extents = Vector2( 7, 14 )
|
||||||
|
|
@ -16,7 +48,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 ) ]
|
states = [ ExtResource( 4 ), SubResource( 2 ), SubResource( 3 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
resource_name = "idle"
|
resource_name = "idle"
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
debug_state = false
|
debug_state = false
|
||||||
timeout_seconds = 2.0
|
timeout_seconds = 0.0
|
||||||
name = "idle"
|
name = "idle"
|
||||||
move_speed = 60.0
|
move_speed = 1.36422e-12
|
||||||
move_acceleration = 0.0
|
move_acceleration = 0.0
|
||||||
move_speed_modifier = 0.0
|
move_speed_modifier = 0.0
|
||||||
move_modifier_move_acceleration = 0.0
|
move_modifier_move_acceleration = 0.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user