diff --git a/Main.tscn b/Main.tscn index bb6227a..0db4e92 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/actors/players/playerE/PlayerE.tscn" type="PackedScene" id=1] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 208, 20 ) @@ -18,5 +18,4 @@ margin_bottom = 200.0 position = Vector2( 208, 20 ) shape = SubResource( 1 ) -[node name="ActorTemplate" parent="." instance=ExtResource( 1 )] -position = Vector2( 168, 32 ) +[node name="PlayerE" parent="." instance=ExtResource( 1 )] diff --git a/assets/actors/players/playerE/PlayerE_SpriteFrames.tres b/assets/actors/players/playerE/PlayerE_SpriteFrames.tres new file mode 100644 index 0000000..eec639d --- /dev/null +++ b/assets/actors/players/playerE/PlayerE_SpriteFrames.tres @@ -0,0 +1,130 @@ +[gd_resource type="SpriteFrames" load_steps=27 format=2] + +[sub_resource type="StreamTexture" id=1] +load_path = "res://.import/idle.png-dac221ba43c70fde9cf788217116f029.stex" + +[sub_resource type="AtlasTexture" id=2] +atlas = SubResource( 1 ) +region = Rect2( 0, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = SubResource( 1 ) +region = Rect2( 48, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = SubResource( 1 ) +region = Rect2( 96, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = SubResource( 1 ) +region = Rect2( 0, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = SubResource( 1 ) +region = Rect2( 48, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = SubResource( 1 ) +region = Rect2( 96, 48, 48, 48 ) + +[sub_resource type="StreamTexture" id=8] +load_path = "res://.import/jump.png-e5e27a6608040d3526a151777807f18b.stex" + +[sub_resource type="AtlasTexture" id=9] +atlas = SubResource( 8 ) +region = Rect2( 0, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = SubResource( 8 ) +region = Rect2( 48, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = SubResource( 8 ) +region = Rect2( 0, 48, 48, 48 ) + +[sub_resource type="StreamTexture" id=12] +load_path = "res://.import/land.png-c462761c5fb4bf0befa8d4a5a879e2f5.stex" + +[sub_resource type="AtlasTexture" id=13] +atlas = SubResource( 12 ) +region = Rect2( 0, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = SubResource( 12 ) +region = Rect2( 48, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=15] +atlas = SubResource( 12 ) +region = Rect2( 96, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=16] +atlas = SubResource( 12 ) +region = Rect2( 0, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=17] +atlas = SubResource( 12 ) +region = Rect2( 48, 48, 48, 48 ) + +[sub_resource type="StreamTexture" id=18] +load_path = "res://.import/run.png-d086b4c01d4e3ff36f750b9aff5a303a.stex" + +[sub_resource type="AtlasTexture" id=19] +atlas = SubResource( 18 ) +region = Rect2( 0, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=20] +atlas = SubResource( 18 ) +region = Rect2( 48, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=21] +atlas = SubResource( 18 ) +region = Rect2( 96, 0, 48, 48 ) + +[sub_resource type="AtlasTexture" id=22] +atlas = SubResource( 18 ) +region = Rect2( 0, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=23] +atlas = SubResource( 18 ) +region = Rect2( 48, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=24] +atlas = SubResource( 18 ) +region = Rect2( 96, 48, 48, 48 ) + +[sub_resource type="AtlasTexture" id=25] +atlas = SubResource( 18 ) +region = Rect2( 0, 96, 48, 48 ) + +[sub_resource type="AtlasTexture" id=26] +atlas = SubResource( 18 ) +region = Rect2( 48, 96, 48, 48 ) + +[resource] +resource_name = "PlayerE" +animations = [ { +"frames": [ SubResource( 2 ) ], +"loop": true, +"name": "default", +"speed": 13.0 +}, { +"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 5 ), SubResource( 6 ), SubResource( 2 ), SubResource( 7 ), SubResource( 7 ), SubResource( 7 ) ], +"loop": true, +"name": "idle", +"speed": 11.0 +}, { +"frames": [ SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ], +"loop": false, +"name": "jump", +"speed": 10.0 +}, { +"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 14 ), SubResource( 15 ), SubResource( 15 ), SubResource( 16 ), SubResource( 16 ), SubResource( 17 ), SubResource( 17 ) ], +"loop": false, +"name": "land", +"speed": 13.0 +}, { +"frames": [ SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ], +"loop": true, +"name": "run", +"speed": 13.0 +} ] diff --git a/assets/actors/players/playerE/template.png b/assets/actors/players/playerE/idle.png similarity index 100% rename from assets/actors/players/playerE/template.png rename to assets/actors/players/playerE/idle.png diff --git a/assets/actors/players/playerE/template-jump.png.import b/assets/actors/players/playerE/idle.png.import similarity index 68% rename from assets/actors/players/playerE/template-jump.png.import rename to assets/actors/players/playerE/idle.png.import index 58d396d..b20850d 100644 --- a/assets/actors/players/playerE/template-jump.png.import +++ b/assets/actors/players/playerE/idle.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/template-jump.png-99a30c82ac7d2ef1ff0cd02512f1ee55.stex" +path="res://.import/idle.png-dac221ba43c70fde9cf788217116f029.stex" metadata={ "vram_texture": false } [deps] -source_file="res://assets/actors/players/playerE/template-jump.png" -dest_files=[ "res://.import/template-jump.png-99a30c82ac7d2ef1ff0cd02512f1ee55.stex" ] +source_file="res://assets/actors/players/playerE/idle.png" +dest_files=[ "res://.import/idle.png-dac221ba43c70fde9cf788217116f029.stex" ] [params] diff --git a/assets/actors/players/playerE/template-jump.png b/assets/actors/players/playerE/jump.png similarity index 100% rename from assets/actors/players/playerE/template-jump.png rename to assets/actors/players/playerE/jump.png diff --git a/assets/actors/players/playerE/template.png.import b/assets/actors/players/playerE/jump.png.import similarity index 67% rename from assets/actors/players/playerE/template.png.import rename to assets/actors/players/playerE/jump.png.import index bf2593c..13705ec 100644 --- a/assets/actors/players/playerE/template.png.import +++ b/assets/actors/players/playerE/jump.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/template.png-4288ca8cd0abcf2db7d00f52e5ba2170.stex" +path="res://.import/jump.png-e5e27a6608040d3526a151777807f18b.stex" metadata={ "vram_texture": false } [deps] -source_file="res://assets/actors/players/playerE/template.png" -dest_files=[ "res://.import/template.png-4288ca8cd0abcf2db7d00f52e5ba2170.stex" ] +source_file="res://assets/actors/players/playerE/jump.png" +dest_files=[ "res://.import/jump.png-e5e27a6608040d3526a151777807f18b.stex" ] [params] @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/assets/actors/players/playerE/land.png b/assets/actors/players/playerE/land.png new file mode 100644 index 0000000..8e25377 Binary files /dev/null and b/assets/actors/players/playerE/land.png differ diff --git a/assets/actors/players/playerE/land.png.import b/assets/actors/players/playerE/land.png.import new file mode 100644 index 0000000..ec6c1fa --- /dev/null +++ b/assets/actors/players/playerE/land.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/land.png-c462761c5fb4bf0befa8d4a5a879e2f5.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/actors/players/playerE/land.png" +dest_files=[ "res://.import/land.png-c462761c5fb4bf0befa8d4a5a879e2f5.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/actors/players/playerE/new_spriteframes.tres b/assets/actors/players/playerE/new_spriteframes.tres deleted file mode 100644 index 1db1891..0000000 --- a/assets/actors/players/playerE/new_spriteframes.tres +++ /dev/null @@ -1,103 +0,0 @@ -[gd_resource type="SpriteFrames" load_steps=20 format=2] - -[sub_resource type="StreamTexture" id=1] -load_path = "res://.import/template-jump.png-99a30c82ac7d2ef1ff0cd02512f1ee55.stex" - -[sub_resource type="AtlasTexture" id=2] -atlas = SubResource( 1 ) -region = Rect2( 0, 48, 48, 48 ) - -[sub_resource type="StreamTexture" id=3] -load_path = "res://.import/template-jump.png-99a30c82ac7d2ef1ff0cd02512f1ee55.stex" - -[sub_resource type="AtlasTexture" id=4] -atlas = SubResource( 3 ) -region = Rect2( 0, 48, 48, 48 ) - -[sub_resource type="StreamTexture" id=5] -load_path = "res://.import/template-jump.png-99a30c82ac7d2ef1ff0cd02512f1ee55.stex" - -[sub_resource type="AtlasTexture" id=6] -atlas = SubResource( 5 ) -region = Rect2( 0, 48, 48, 48 ) - -[sub_resource type="AtlasTexture" id=7] -atlas = SubResource( 1 ) -region = Rect2( 0, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=8] -atlas = SubResource( 3 ) -region = Rect2( 0, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=9] -atlas = SubResource( 5 ) -region = Rect2( 0, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=10] -atlas = SubResource( 1 ) -region = Rect2( 48, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=11] -atlas = SubResource( 3 ) -region = Rect2( 48, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=12] -atlas = SubResource( 5 ) -region = Rect2( 48, 0, 48, 48 ) - -[sub_resource type="StreamTexture" id=13] -flags = 4 -load_path = "res://.import/template.png-4288ca8cd0abcf2db7d00f52e5ba2170.stex" - -[sub_resource type="AtlasTexture" id=14] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 0, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=15] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 48, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=16] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 96, 0, 48, 48 ) - -[sub_resource type="AtlasTexture" id=17] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 0, 48, 48, 48 ) - -[sub_resource type="AtlasTexture" id=18] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 48, 48, 48, 48 ) - -[sub_resource type="AtlasTexture" id=19] -flags = 4 -atlas = SubResource( 13 ) -region = Rect2( 96, 48, 48, 48 ) - -[resource] -animations = [ { -"frames": [ SubResource( 2 ), SubResource( 4 ), SubResource( 6 ) ], -"loop": true, -"name": "Jump Down", -"speed": 10.0 -}, { -"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ], -"loop": true, -"name": "Jump up", -"speed": 10.0 -}, { -"frames": [ SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ], -"loop": true, -"name": "Max Height", -"speed": 10.0 -}, { -"frames": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 17 ), SubResource( 18 ), SubResource( 14 ), SubResource( 19 ), SubResource( 19 ), SubResource( 19 ) ], -"loop": false, -"name": "idle", -"speed": 11.0 -} ] diff --git a/assets/actors/players/playerE/run.png b/assets/actors/players/playerE/run.png new file mode 100644 index 0000000..dee4c4c Binary files /dev/null and b/assets/actors/players/playerE/run.png differ diff --git a/assets/actors/players/playerE/run.png.import b/assets/actors/players/playerE/run.png.import new file mode 100644 index 0000000..b44fbe1 --- /dev/null +++ b/assets/actors/players/playerE/run.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/run.png-d086b4c01d4e3ff36f750b9aff5a303a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/actors/players/playerE/run.png" +dest_files=[ "res://.import/run.png-d086b4c01d4e3ff36f750b9aff5a303a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/lib/classes/actor.gd b/lib/classes/actor.gd index d0ed613..c17a3bf 100644 --- a/lib/classes/actor.gd +++ b/lib/classes/actor.gd @@ -15,6 +15,7 @@ export var debug_actor: bool = false onready var sound_effect_player: AudioStreamPlayer = $SE_Player #onready var movement_component: MovementComponent = $movement_component +onready var movement_component: Movement_StateReceiver = $Movement_StateReceiver #onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine onready var movement_state_machine: StateMachine = $movement_state_machine @@ -42,15 +43,14 @@ func _ready() -> void: sound_effects_dict[i.animation_name + str(i.frame_number)] = i.sound print (sound_effects_dict) -# Disable to test whether actually needed. -#func _unhandled_input(event: InputEvent) -> void: -# if actor_type == "Player": -# movement_component.process_input(event) -# movement_state_machine.process_input(event) -# -#func _physics_process(delta: float) -> void: -# movement_component.process_physics(delta) -# movement_state_machine.process_physics(delta) +func _unhandled_input(event: InputEvent) -> void: + if actor_type == "Player": + movement_component.process_input(event) + #movement_state_machine.process_input(event) + +func _physics_process(delta: float) -> void: + movement_component.process_physics(delta) + #movement_state_machine.process_physics(delta) # #func _process(delta: float) -> void: # if actor_type == "NPC" or actor_type == "Enemy": diff --git a/lib/classes/movement_state_receiver.gd b/lib/classes/movement_state_receiver.gd index 7209874..b26ae4d 100644 --- a/lib/classes/movement_state_receiver.gd +++ b/lib/classes/movement_state_receiver.gd @@ -41,10 +41,14 @@ const LEFT = -1.0 const RIGHT = 1.0 func _ready(): - pass + request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state') + get_node(callable_state_machine).connect("state_changed", self,"_on_state_change") +############ +# These get called by the parent +############ func process_physics(delta): - pass + move_actor_as_desired(delta) # Shouldn't need a proces function #func process(delta): @@ -52,7 +56,9 @@ func process_physics(delta): func process_input(event: InputEvent): pass - + +############ + # A Series of helper functions func go_up(): desired_movement_vector.y = UP @@ -92,6 +98,17 @@ func wants_climb() -> bool: func get_climb_shape_location() -> Vector2: return Vector2(-1,-1) +func _on_state_change(old_state_name:String, new_state :State): + print ("got the state change signal (MC) ", new_state.name) + # set current state to new_state + #TODO: Confirm that this is a reference to the state in the + ###### State machine + if new_state is StateAnimatedActor: #Testing this. Update: It works + current_state = new_state + else: + push_warning("Received non animated Actor state.") + #current_state = new_state + func move_actor_as_desired(delta: float, x_move_direction_override: float = 0): diff --git a/lib/templates/Actor/ActorTemplate.tscn b/lib/templates/Actor/ActorTemplate.tscn index ef89c21..fdf0050 100644 --- a/lib/templates/Actor/ActorTemplate.tscn +++ b/lib/templates/Actor/ActorTemplate.tscn @@ -1,8 +1,6 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=6 format=2] -[ext_resource path="res://lib/classes/animated_sprite_state_receiver.gd" type="Script" id=1] [ext_resource path="res://lib/classes/state_machine.gd" type="Script" id=2] -[ext_resource path="res://assets/actors/players/playerE/new_spriteframes.tres" type="SpriteFrames" id=3] [ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=4] [ext_resource path="res://lib/classes/movement_state_receiver.gd" type="Script" id=5] [ext_resource path="res://lib/classes/actor.gd" type="Script" id=8] @@ -26,27 +24,25 @@ collision_layer = 2 script = ExtResource( 8 ) [node name="AnimatedSprite_StateReceiver" type="AnimatedSprite" parent="."] -frames = ExtResource( 3 ) -animation = "idle" -script = ExtResource( 1 ) __meta__ = { "_aseprite_wizard_config_": { "layer": "", -"o_ex_p": "BG", -"o_folder": "res://assets/actors/players/playerE", -"o_name": "template-jump", +"o_ex_p": "-.*", +"o_folder": "", +"o_name": "", "only_visible": true, "op_exp": true, +"sf_name": "", "slice": "", -"source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Jump/player jump 48x48.aseprite" +"source": "" } } -callable_state_machine = NodePath("../movement_state_machine") [node name="Movement_StateReceiver" type="Node" parent="."] script = ExtResource( 5 ) +callable_state_machine = NodePath("../Movement_StateMachine") -[node name="movement_state_machine" type="Node" parent="."] +[node name="Movement_StateMachine" type="Node" parent="."] script = ExtResource( 2 ) starting_state_name = "idle" states = [ SubResource( 1 ) ] diff --git a/src/actors/players/playerE/PlayerE.tscn b/src/actors/players/playerE/PlayerE.tscn index be06cd7..6a8ceda 100644 --- a/src/actors/players/playerE/PlayerE.tscn +++ b/src/actors/players/playerE/PlayerE.tscn @@ -1,5 +1,23 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [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] [node name="PlayerE" instance=ExtResource( 1 )] +actor_type = "Player" + +[node name="AnimatedSprite_StateReceiver" parent="." index="0"] +frames = ExtResource( 2 ) +__meta__ = { +"_aseprite_wizard_config_": { +"layer": "", +"o_ex_p": "-.*", +"o_folder": "res://assets/actors/players/playerE", +"o_name": "run", +"only_visible": true, +"op_exp": true, +"sf_name": "PlayerE_SpriteFrames", +"slice": "", +"source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Run/player run 48x48.aseprite" +} +}