Compare commits

..

No commits in common. "522e409dabc6453445c3dabb913b5fda7cf771e0" and "ae9256f08325314649ba05679a435d1be35ed0fb" have entirely different histories.

8 changed files with 33 additions and 132 deletions

View File

@ -49,10 +49,6 @@ 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)
# #

View File

@ -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,16 +42,13 @@ 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):
# Shouldn't need this anymore! if current_state.state_timeout != null:
# if current_state.state_timeout != null: if current_state.state_timeout.time_left == 0:
# if current_state.state_timeout.time_left == 0: print("You're out of time! I saw it!")
# print("You're out of time! I saw it!") request_state_change.call_func('idle')
# request_state_change.call_func('idle') #play()
# #play() else:
# else: print("what, no current_state?")
# 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()

View File

@ -53,17 +53,10 @@ 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)
# more likely needed for Players # Shouldn't need a proces function
func process_physics_input(delta): #func process(delta):
if has_method('_state_process_physics_input_' + current_state.name): # pass
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)

View File

@ -28,8 +28,6 @@ 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
@ -44,10 +42,9 @@ 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

View File

@ -2,12 +2,8 @@ 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 var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
# state_ref = 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")
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!
@ -16,13 +12,5 @@ func _ready():
#func _state_process_idle(): #func _state_process_idle():
# print("I got called!") # print("I got called!")
#func _state_process_fall(): func _on_state_entered_idle():
# print("I got called!") print("Anim Knows Idle State Entered!")
#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()

View File

@ -1,59 +1,22 @@
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 player_number: int = 1 var fire_a_note:bool = false
# 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():
#TODO: May need that 'bump' logic to make velocity work. if fire_a_note == true:
if desired_movement_vector.x != 0: # and velocity.x != 0: print("I got called! (MC)")
request_state_change.call_func('move') fire_a_note = false
if !parent.is_on_floor(): func _on_state_entered_idle():
#return fall_state print("Movement State Idle State Entered!")
request_state_change.call_func('fall') fire_a_note = true
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!")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=8 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,38 +6,6 @@
[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 )
@ -48,7 +16,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 ), SubResource( 2 ), SubResource( 3 ) ] states = [ ExtResource( 4 ) ]
[node name="AnimatedSprite_StateReceiver" parent="." index="1"] [node name="AnimatedSprite_StateReceiver" parent="." index="1"]
frames = ExtResource( 2 ) frames = ExtResource( 2 )

View File

@ -3,13 +3,12 @@
[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 = 0.0 timeout_seconds = 2.0
name = "idle" name = "idle"
move_speed = 1.36422e-12 move_speed = 60.0
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