From 392dc2d6079bb71ebb6b4022ae4518774148cfab Mon Sep 17 00:00:00 2001 From: Julian Murgia Date: Tue, 3 Aug 2021 17:48:55 +0200 Subject: [PATCH] Add ESCAnimationResource to hold characters animations. (#342) Co-authored-by: StraToN Co-authored-by: Dennis Ploeger Co-authored-by: dploeger --- .../core-scripts/behaviors/esc_movable.gd | 46 +-- .../game/core-scripts/esc_item.gd | 15 +- .../resources/esc_animationname.gd | 10 + .../resources/esc_animationresource.gd | 58 +++ .../resources/esc_directionangle.gd | 11 + docs/api/ESCAnimationName.md | 27 ++ docs/api/ESCAnimationResource.md | 54 +++ docs/api/ESCDirectionAngle.md | 27 ++ docs/api/ESCItem.md | 4 +- docs/api/ESCLogger.md | 8 +- docs/api/ESCMovable.md | 8 +- game/characters/mark/mark.tscn | 329 +++++++++++++----- game/characters/mark/mark_animations.tres | 51 +++ game/characters/mark/mark_anims.gd | 90 ----- project.godot | 22 +- 15 files changed, 553 insertions(+), 207 deletions(-) create mode 100644 addons/escoria-core/game/core-scripts/resources/esc_animationname.gd create mode 100644 addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd create mode 100644 addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd create mode 100644 docs/api/ESCAnimationName.md create mode 100644 docs/api/ESCAnimationResource.md create mode 100644 docs/api/ESCDirectionAngle.md create mode 100644 game/characters/mark/mark_animations.tres delete mode 100644 game/characters/mark/mark_anims.gd diff --git a/addons/escoria-core/game/core-scripts/behaviors/esc_movable.gd b/addons/escoria-core/game/core-scripts/behaviors/esc_movable.gd index bc5f5c18..81cb126f 100644 --- a/addons/escoria-core/game/core-scripts/behaviors/esc_movable.gd +++ b/addons/escoria-core/game/core-scripts/behaviors/esc_movable.gd @@ -113,7 +113,7 @@ func _process(delta: float) -> void: current_animation = parent.animation_sprite.animation var animation_to_play = \ - parent.animations.directions[last_dir][0] + parent.animations.directions[last_dir].animation if current_animation != animation_to_play: if parent.animation_sprite.frames.has_animation( animation_to_play @@ -132,7 +132,8 @@ func _process(delta: float) -> void: true ) - pose_scale = parent.animations.directions[last_dir][1] + pose_scale = -1 if parent.animations.directions[last_dir].mirrored \ + else 1 update_terrain() else: @@ -242,12 +243,12 @@ func walk_stop(pos: Vector2) -> void: var orientation = walk_context.target_object.node.interaction_direction last_dir = orientation parent.animation_sprite.play( - parent.animations.idles[orientation][0] + parent.animations.idles[orientation].animation ) - pose_scale = parent.animations.idles[orientation][1] + pose_scale = -1 if parent.animations.idles[orientation].mirrored else 1 else: - parent.animation_sprite.play(parent.animations.idles[last_dir][0]) - pose_scale = parent.animations.idles[last_dir][1] + parent.animation_sprite.play(parent.animations.idles[last_dir].animation) + pose_scale = -1 if parent.animations.idles[last_dir].mirrored else 1 update_terrain() @@ -316,15 +317,15 @@ func update_terrain(on_event_finished_name = null) -> void: # # - deg: Degrees # - animations: Player animations script -func _get_dir_deg(deg: int, animations: Script) -> int: +func _get_dir_deg(deg: int, animations: ESCAnimationResource) -> int: # We turn the angle by -90° because angle_to_point gives the angle # against X axis, not Y deg = wrapi(deg - 90, 0, 360) var dir = -1 var i = 0 - for arr_angle_zone in animations.dir_angles: - if is_angle_in_interval(deg, arr_angle_zone): + for direction_angle in animations.dir_angles: + if is_angle_in_interval(deg, direction_angle): dir = i break else: @@ -347,22 +348,23 @@ func _get_dir_deg(deg: int, animations: Script) -> int: # #### Parameters # # - angle: Angle to test -# - interval: Array of size 2, containing the starting angle, and the size of -# interval -# eg: [90, 40] corresponds to angle between 90° and 130° -func is_angle_in_interval(angle: float, interval: Array) -> bool: +# - direction_angle: ESCDirectionAngle resource, containing the starting angle, +# and the size of interval +# eg: angle_start=90, angle_size=40 corresponds to angle between 90° and 130° +func is_angle_in_interval(angle: float, direction_angle: ESCDirectionAngle) -> bool: angle = wrapi(angle, 0, 360) if angle == 0: angle = 360 - var start_angle = wrapi(interval[0], 0, 360) - var angle_area = interval[1] - var end_angle = wrapi(interval[0] + angle_area, 0, 360) + var start_angle = wrapi(direction_angle.angle_start, 0, 360) + var angle_area = direction_angle.angle_size + var end_angle = wrapi(direction_angle.angle_start + angle_area, 0, 360) if ((angle >= 270 and angle <= 360) \ or (angle >= 0 and angle <= 90)) \ - and wrapi(angle + 180, 0, 360) > wrapi(interval[0] + 180, 0, 360) \ + and wrapi(angle + 180, 0, 360) > wrapi(direction_angle.angle_start + + 180, 0, 360) \ and wrapi(angle + 180, 0, 360) <= wrapi( - interval[0] + angle_area + 180, 0, 360 + direction_angle.angle_start + angle_area + 180, 0, 360 ): return true elif wrapi(angle, 0, 360) > start_angle \ @@ -392,12 +394,12 @@ func set_angle(deg: int, immediate = true) -> void: # The character may have a state animation from before, which would be # resumed, so we immediately force the correct idle animation if parent.animation_sprite.animation != \ - parent.animations.idles[last_dir][0]: - parent.animation_sprite.play(parent.animations.idles[last_dir][0]) - pose_scale = parent.animations.idles[last_dir][1] + parent.animations.idles[last_dir].animation: + parent.animation_sprite.play(parent.animations.idles[last_dir].animation) + pose_scale = -1 if parent.animations.idles[last_dir].mirrored else 1 update_terrain() # Returns the angle that corresponds to the current direction of the object. func _get_angle() -> int: - return parent.animations.dir_angles[last_dir][0] + return parent.animations.dir_angles[last_dir].animation diff --git a/addons/escoria-core/game/core-scripts/esc_item.gd b/addons/escoria-core/game/core-scripts/esc_item.gd index 8013fe26..6d915720 100644 --- a/addons/escoria-core/game/core-scripts/esc_item.gd +++ b/addons/escoria-core/game/core-scripts/esc_item.gd @@ -120,8 +120,8 @@ export(int) var speed: int = 300 # Speed damp of this item if movable export(float) var v_speed_damp: float = 1.0 -# Animations script (for walking, idling...) -export(Script) var animations +# ESCAnimationsResource (for walking, idling...) +var animations: ESCAnimationResource # The movable subnode var _movable: ESCMovable = null @@ -369,5 +369,14 @@ func _get_inventory_item() -> ESCInventoryItem: inventory_item = inventory_item_scene_file.instance() inventory_item.global_id = self.global_id return inventory_item - + +func _get_property_list(): + var properties = [] + properties.append({ + "name": "animations", + "type": TYPE_OBJECT, + "hint": PROPERTY_HINT_RESOURCE_TYPE, + "hint_string": "ESCAnimationResource" + }) + return properties diff --git a/addons/escoria-core/game/core-scripts/resources/esc_animationname.gd b/addons/escoria-core/game/core-scripts/resources/esc_animationname.gd new file mode 100644 index 00000000..044e05db --- /dev/null +++ b/addons/escoria-core/game/core-scripts/resources/esc_animationname.gd @@ -0,0 +1,10 @@ +# Class defining an animation to use for an angle. +tool +extends Resource +class_name ESCAnimationName + +# Name of the animation +export(String) var animation: String + +# Animation mirror (false is no mirror, true is mirrored) +export(bool) var mirrored: bool diff --git a/addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd b/addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd new file mode 100644 index 00000000..7cae50ae --- /dev/null +++ b/addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd @@ -0,0 +1,58 @@ +# Resource containing all defined animations and angles for +# characters movement. +tool +extends Resource +class_name ESCAnimationResource + + +# Array containing the different angles available for animations. +# Each angle is defined by an array [start_angle, angle_size]. +# start_angle must be between 0 and 360. +# Angle 0 and 360 are the same and correspond to UP/NORTH +# 90 is RIGHT/EAST, 180 is DOWN/SOUTH, etc +var dir_angles: Array = [] + +# Array of animations for each direction, from UP to RIGHT_UP clockwise +# [animation_name, scale]: scale parameter can be set to -1 to mirror +# the animation +var directions: Array = [] + + +# Array containing the idle animations for each direction (in the +# order defined by dir_angles): scale parameter can be set to -1 to mirror +# the animation +var idles: Array = [] + +# Array containing the speak animations for each direction (in the +# order defined by dir_angles): scale parameter can be set to -1 to mirror +# the animation +var speaks: Array = [] + + +func _get_property_list(): + var properties = [] + properties.append({ + "name": "dir_angles", + "type": TYPE_ARRAY, + "hint": 19, + "hint_string": "17/17:ESCDirectionAngle" + }) + properties.append({ + "name": "directions", + "type": TYPE_ARRAY, + "hint": 19, + "hint_string": "17/17:ESCAnimationName" + }) + properties.append({ + "name": "idles", + "type": TYPE_ARRAY, + "hint": 19, + "hint_string": "17/17:ESCAnimationName" + }) + properties.append({ + "name": "speaks", + "type": TYPE_ARRAY, + "hint": 19, + "hint_string": "17/17:ESCAnimationName" + }) + return properties diff --git a/addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd b/addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd new file mode 100644 index 00000000..347f4928 --- /dev/null +++ b/addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd @@ -0,0 +1,11 @@ +# Class defining an angle, with a start angle (between 0 and 360) and a size. +tool +extends Resource +class_name ESCDirectionAngle + + +# Start angle of the directional angle. +export(int) var angle_start: int + +# Size of the angle +export(int) var angle_size: int diff --git a/docs/api/ESCAnimationName.md b/docs/api/ESCAnimationName.md new file mode 100644 index 00000000..4778ade2 --- /dev/null +++ b/docs/api/ESCAnimationName.md @@ -0,0 +1,27 @@ + + +# ESCAnimationName + +**Extends:** [Resource](../Resource) + +## Description + +Class defining an animation to use for an angle. + +## Property Descriptions + +### animation + +```gdscript +export var animation: String = "" +``` + +Name of the animation + +### mirrored + +```gdscript +export var mirrored: bool = false +``` + +Animation mirror (false is no mirror, true is mirrored) \ No newline at end of file diff --git a/docs/api/ESCAnimationResource.md b/docs/api/ESCAnimationResource.md new file mode 100644 index 00000000..a94a2445 --- /dev/null +++ b/docs/api/ESCAnimationResource.md @@ -0,0 +1,54 @@ + + +# ESCAnimationResource + +**Extends:** [Resource](../Resource) + +## Description + +Resource containing all defined animations and angles for +characters movement. + +## Property Descriptions + +### dir\_angles + +```gdscript +var dir_angles: Array +``` + +Array containing the different angles available for animations. +Each angle is defined by an array [start_angle, angle_size]. +start_angle must be between 0 and 360. +Angle 0 and 360 are the same and correspond to UP/NORTH +90 is RIGHT/EAST, 180 is DOWN/SOUTH, etc + +### directions + +```gdscript +var directions: Array +``` + +Array of animations for each direction, from UP to RIGHT_UP clockwise +[animation_name, scale]: scale parameter can be set to -1 to mirror +the animation + +### idles + +```gdscript +var idles: Array +``` + +Array containing the idle animations for each direction (in the +order defined by dir_angles): scale parameter can be set to -1 to mirror +the animation + +### speaks + +```gdscript +var speaks: Array +``` + +Array containing the speak animations for each direction (in the +order defined by dir_angles): scale parameter can be set to -1 to mirror +the animation \ No newline at end of file diff --git a/docs/api/ESCDirectionAngle.md b/docs/api/ESCDirectionAngle.md new file mode 100644 index 00000000..921f9662 --- /dev/null +++ b/docs/api/ESCDirectionAngle.md @@ -0,0 +1,27 @@ + + +# ESCDirectionAngle + +**Extends:** [Resource](../Resource) + +## Description + + Class defining an angle, with a start angle (between 0 and 360) and a size. + +## Property Descriptions + +### angle\_start + +```gdscript +export var angle_start: int = 0 +``` + +Start angle of the directional angle. + +### angle\_size + +```gdscript +export var angle_size: int = 0 +``` + +Size of the angle \ No newline at end of file diff --git a/docs/api/ESCItem.md b/docs/api/ESCItem.md index 3b91432d..2a4e5637 100644 --- a/docs/api/ESCItem.md +++ b/docs/api/ESCItem.md @@ -191,10 +191,10 @@ Speed damp of this item if movable ### animations ```gdscript -export var animations = "[Object:null]" +var animations: ESCAnimationResource ``` - Animations script (for walking, idling...) + ESCAnimationsResource (for walking, idling...) ### animation\_sprite diff --git a/docs/api/ESCLogger.md b/docs/api/ESCLogger.md index bc26fade..8ad1b92b 100644 --- a/docs/api/ESCLogger.md +++ b/docs/api/ESCLogger.md @@ -13,7 +13,7 @@ Logging framework for Escoria ### LOG\_DEBUG ```gdscript -const LOG_WARNING: int = 1 +const LOG_DEBUG: int = 3 ``` Valid log levels @@ -21,7 +21,7 @@ Valid log levels ### LOG\_ERROR ```gdscript -const LOG_WARNING: int = 1 +const LOG_DEBUG: int = 3 ``` Valid log levels @@ -29,7 +29,7 @@ Valid log levels ### LOG\_INFO ```gdscript -const LOG_WARNING: int = 1 +const LOG_DEBUG: int = 3 ``` Valid log levels @@ -37,7 +37,7 @@ Valid log levels ### LOG\_WARNING ```gdscript -const LOG_WARNING: int = 1 +const LOG_DEBUG: int = 3 ``` Valid log levels diff --git a/docs/api/ESCMovable.md b/docs/api/ESCMovable.md index 2986eaaf..bcb2551a 100644 --- a/docs/api/ESCMovable.md +++ b/docs/api/ESCMovable.md @@ -178,7 +178,7 @@ Update the sprite scale and lighting ### is\_angle\_in\_interval ```gdscript -func is_angle_in_interval(angle: float, interval: Array) -> bool +func is_angle_in_interval(angle: float, direction_angle: ESCDirectionAngle) -> bool ``` Returns true if given angle is inside the interval given by a starting_angle @@ -187,9 +187,9 @@ and the size. #### Parameters - angle: Angle to test -- interval: Array of size 2, containing the starting angle, and the size of - interval - eg: [90, 40] corresponds to angle between 90° and 130° +- direction_angle: ESCDirectionAngle resource, containing the starting angle, + and the size of interval +eg: angle_start=90, angle_size=40 corresponds to angle between 90° and 130° ### set\_angle diff --git a/game/characters/mark/mark.tscn b/game/characters/mark/mark.tscn index ad0c8934..e187f457 100644 --- a/game/characters/mark/mark.tscn +++ b/game/characters/mark/mark.tscn @@ -1,68 +1,181 @@ -[gd_scene load_steps=40 format=2] +[gd_scene load_steps=75 format=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_player.gd" type="Script" id=1] [ext_resource path="res://game/characters/mark/png/mark_talk_down.png" type="Texture" id=2] -[ext_resource path="res://game/characters/mark/mark_anims.gd" type="Script" id=3] +[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationname.gd" type="Script" id=3] [ext_resource path="res://game/characters/mark/png/mark.png" type="Texture" id=4] [ext_resource path="res://game/characters/mark/png/mark_talk_down_right.png" type="Texture" id=5] [ext_resource path="res://game/characters/mark/png/mark_talk_up.png" type="Texture" id=6] [ext_resource path="res://game/characters/mark/png/mark_talk_right.png" type="Texture" id=7] +[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd" type="Script" id=8] +[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd" type="Script" id=9] -[sub_resource type="AtlasTexture" id=1] -atlas = ExtResource( 2 ) -region = Rect2( 0, 0, 24, 70 ) +[sub_resource type="Resource" id=33] +script = ExtResource( 9 ) +angle_start = 340 +angle_size = 40 -[sub_resource type="AtlasTexture" id=2] -atlas = ExtResource( 2 ) -region = Rect2( 24, 0, 24, 70 ) +[sub_resource type="Resource" id=34] +script = ExtResource( 9 ) +angle_start = 20 +angle_size = 50 -[sub_resource type="AtlasTexture" id=3] -atlas = ExtResource( 2 ) -region = Rect2( 48, 0, 24, 70 ) +[sub_resource type="Resource" id=35] +script = ExtResource( 9 ) +angle_start = 70 +angle_size = 40 -[sub_resource type="AtlasTexture" id=4] -atlas = ExtResource( 4 ) -region = Rect2( 216, 0, 24, 70 ) +[sub_resource type="Resource" id=36] +script = ExtResource( 9 ) +angle_start = 110 +angle_size = 50 -[sub_resource type="AtlasTexture" id=5] -atlas = ExtResource( 4 ) -region = Rect2( 240, 0, 24, 70 ) +[sub_resource type="Resource" id=37] +script = ExtResource( 9 ) +angle_start = 160 +angle_size = 40 -[sub_resource type="AtlasTexture" id=6] -atlas = ExtResource( 4 ) -region = Rect2( 264, 0, 24, 70 ) +[sub_resource type="Resource" id=38] +script = ExtResource( 9 ) +angle_start = 200 +angle_size = 50 -[sub_resource type="AtlasTexture" id=7] -atlas = ExtResource( 4 ) -region = Rect2( 288, 0, 24, 70 ) +[sub_resource type="Resource" id=39] +script = ExtResource( 9 ) +angle_start = 250 +angle_size = 40 -[sub_resource type="AtlasTexture" id=8] -atlas = ExtResource( 4 ) -region = Rect2( 312, 0, 24, 70 ) +[sub_resource type="Resource" id=40] +script = ExtResource( 9 ) +angle_start = 290 +angle_size = 50 -[sub_resource type="AtlasTexture" id=9] -atlas = ExtResource( 4 ) -region = Rect2( 72, 0, 24, 70 ) +[sub_resource type="Resource" id=41] +script = ExtResource( 3 ) +animation = "walk_up" +mirrored = false -[sub_resource type="AtlasTexture" id=10] -atlas = ExtResource( 4 ) -region = Rect2( 336, 0, 24, 70 ) +[sub_resource type="Resource" id=42] +script = ExtResource( 3 ) +animation = "walk_up" +mirrored = false -[sub_resource type="AtlasTexture" id=11] -atlas = ExtResource( 4 ) -region = Rect2( 360, 0, 24, 70 ) +[sub_resource type="Resource" id=43] +script = ExtResource( 3 ) +animation = "walk_right" +mirrored = false -[sub_resource type="AtlasTexture" id=12] -atlas = ExtResource( 4 ) -region = Rect2( 384, 0, 24, 70 ) +[sub_resource type="Resource" id=44] +script = ExtResource( 3 ) +animation = "walk_down" +mirrored = false -[sub_resource type="AtlasTexture" id=13] -atlas = ExtResource( 6 ) -region = Rect2( 0, 0, 24, 70 ) +[sub_resource type="Resource" id=45] +script = ExtResource( 3 ) +animation = "walk_down" +mirrored = false -[sub_resource type="AtlasTexture" id=14] -atlas = ExtResource( 6 ) -region = Rect2( 24, 0, 24, 70 ) +[sub_resource type="Resource" id=46] +script = ExtResource( 3 ) +animation = "walk_down" +mirrored = false + +[sub_resource type="Resource" id=47] +script = ExtResource( 3 ) +animation = "walk_right" +mirrored = true + +[sub_resource type="Resource" id=48] +script = ExtResource( 3 ) +animation = "walk_up" +mirrored = false + +[sub_resource type="Resource" id=50] +script = ExtResource( 3 ) +animation = "idle_up" +mirrored = false + +[sub_resource type="Resource" id=51] +script = ExtResource( 3 ) +animation = "idle_up" +mirrored = false + +[sub_resource type="Resource" id=52] +script = ExtResource( 3 ) +animation = "idle_right" +mirrored = false + +[sub_resource type="Resource" id=53] +script = ExtResource( 3 ) +animation = "idle_down_right" +mirrored = false + +[sub_resource type="Resource" id=54] +script = ExtResource( 3 ) +animation = "idle_down" +mirrored = false + +[sub_resource type="Resource" id=55] +script = ExtResource( 3 ) +animation = "idle_down_left" +mirrored = false + +[sub_resource type="Resource" id=56] +script = ExtResource( 3 ) +animation = "idle_left" +mirrored = false + +[sub_resource type="Resource" id=57] +script = ExtResource( 3 ) +animation = "idle_up" +mirrored = false + +[sub_resource type="Resource" id=58] +script = ExtResource( 3 ) +animation = "speak_up" +mirrored = false + +[sub_resource type="Resource" id=59] +script = ExtResource( 3 ) +animation = "speak_up" +mirrored = false + +[sub_resource type="Resource" id=60] +script = ExtResource( 3 ) +animation = "speak_right" +mirrored = false + +[sub_resource type="Resource" id=61] +script = ExtResource( 3 ) +animation = "speak_down" +mirrored = false + +[sub_resource type="Resource" id=62] +script = ExtResource( 3 ) +animation = "speak_down" +mirrored = false + +[sub_resource type="Resource" id=63] +script = ExtResource( 3 ) +animation = "speak_down" +mirrored = false + +[sub_resource type="Resource" id=64] +script = ExtResource( 3 ) +animation = "speak_right" +mirrored = true + +[sub_resource type="Resource" id=65] +script = ExtResource( 3 ) +animation = "speak_up" +mirrored = false + +[sub_resource type="Resource" id=49] +script = ExtResource( 8 ) +dir_angles = [ SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ), SubResource( 39 ), SubResource( 40 ) ] +directions = [ SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ) ] +idles = [ SubResource( 50 ), SubResource( 51 ), SubResource( 52 ), SubResource( 53 ), SubResource( 54 ), SubResource( 55 ), SubResource( 56 ), SubResource( 57 ) ] +speaks = [ SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ), SubResource( 63 ), SubResource( 64 ), SubResource( 65 ) ] [sub_resource type="AtlasTexture" id=15] atlas = ExtResource( 7 ) @@ -96,18 +209,70 @@ region = Rect2( 168, 0, 24, 70 ) atlas = ExtResource( 4 ) region = Rect2( 192, 0, 24, 70 ) +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 4 ) +region = Rect2( 216, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 4 ) +region = Rect2( 240, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 4 ) +region = Rect2( 264, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 4 ) +region = Rect2( 288, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 4 ) +region = Rect2( 312, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=29] +atlas = ExtResource( 4 ) +region = Rect2( 24, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 2 ) +region = Rect2( 0, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 2 ) +region = Rect2( 24, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 2 ) +region = Rect2( 48, 0, 24, 70 ) + [sub_resource type="AtlasTexture" id=23] atlas = ExtResource( 4 ) region = Rect2( 48, 0, 24, 70 ) -[sub_resource type="AtlasTexture" id=24] +[sub_resource type="AtlasTexture" id=9] atlas = ExtResource( 4 ) -region = Rect2( 120, 0, 24, 70 ) +region = Rect2( 72, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 4 ) +region = Rect2( 336, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 4 ) +region = Rect2( 360, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 4 ) +region = Rect2( 384, 0, 24, 70 ) [sub_resource type="AtlasTexture" id=25] atlas = ExtResource( 4 ) region = Rect2( 96, 0, 24, 70 ) +[sub_resource type="AtlasTexture" id=24] +atlas = ExtResource( 4 ) +region = Rect2( 120, 0, 24, 70 ) + [sub_resource type="AtlasTexture" id=26] atlas = ExtResource( 5 ) region = Rect2( 0, 0, 24, 70 ) @@ -120,19 +285,28 @@ region = Rect2( 24, 0, 24, 70 ) atlas = ExtResource( 5 ) region = Rect2( 48, 0, 24, 70 ) -[sub_resource type="AtlasTexture" id=29] -atlas = ExtResource( 4 ) -region = Rect2( 24, 0, 24, 70 ) - [sub_resource type="AtlasTexture" id=30] atlas = ExtResource( 4 ) region = Rect2( 0, 0, 24, 70 ) +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 6 ) +region = Rect2( 0, 0, 24, 70 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 6 ) +region = Rect2( 24, 0, 24, 70 ) + [sub_resource type="SpriteFrames" id=31] animations = [ { -"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ), SubResource( 3 ) ], +"frames": [ SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ) ], "loop": true, -"name": "speak_down", +"name": "speak_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 21 ) ], +"loop": true, +"name": "walk_down", "speed": 6.0 }, { "frames": [ SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ], @@ -140,6 +314,21 @@ animations = [ { "name": "walk_right", "speed": 6.0 }, { +"frames": [ SubResource( 29 ) ], +"loop": true, +"name": "idle_down_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ), SubResource( 3 ) ], +"loop": true, +"name": "speak_down", +"speed": 6.0 +}, { +"frames": [ SubResource( 23 ) ], +"loop": true, +"name": "idle_right", +"speed": 5.0 +}, { "frames": [ SubResource( 9 ) ], "loop": true, "name": "idle_up", @@ -150,24 +339,9 @@ animations = [ { "name": "walk_up", "speed": 6.0 }, { -"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 13 ), SubResource( 14 ), SubResource( 14 ) ], +"frames": [ SubResource( 25 ) ], "loop": true, -"name": "speak_up", -"speed": 3.0 -}, { -"frames": [ SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ) ], -"loop": true, -"name": "speak_right", -"speed": 5.0 -}, { -"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 21 ) ], -"loop": true, -"name": "walk_down", -"speed": 6.0 -}, { -"frames": [ SubResource( 23 ) ], -"loop": true, -"name": "idle_right", +"name": "idle_left", "speed": 5.0 }, { "frames": [ SubResource( 24 ) ], @@ -175,25 +349,20 @@ animations = [ { "name": "idle_down_left", "speed": 5.0 }, { -"frames": [ SubResource( 25 ) ], -"loop": true, -"name": "idle_left", -"speed": 5.0 -}, { "frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ], "loop": true, "name": "speak_down_right", "speed": 6.0 }, { -"frames": [ SubResource( 29 ) ], -"loop": true, -"name": "idle_down_right", -"speed": 5.0 -}, { "frames": [ SubResource( 30 ) ], "loop": true, "name": "idle_down", "speed": 5.0 +}, { +"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 13 ), SubResource( 14 ), SubResource( 14 ) ], +"loop": true, +"name": "speak_up", +"speed": 3.0 } ] [sub_resource type="CapsuleShape2D" id=32] @@ -204,7 +373,7 @@ script = ExtResource( 1 ) global_id = "player" is_movable = true dialog_color = Color( 1, 1, 1, 1 ) -animations = ExtResource( 3 ) +animations = SubResource( 49 ) [node name="sprite" type="AnimatedSprite" parent="."] position = Vector2( 0, -140.938 ) diff --git a/game/characters/mark/mark_animations.tres b/game/characters/mark/mark_animations.tres new file mode 100644 index 00000000..84da7026 --- /dev/null +++ b/game/characters/mark/mark_animations.tres @@ -0,0 +1,51 @@ +[gd_resource type="Resource" load_steps=11 format=2] + +[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd" type="Script" id=2] + +[sub_resource type="Resource" id=1] +script = ExtResource( 2 ) +angle_start = 340 +angle_size = 40 + +[sub_resource type="Resource" id=2] +script = ExtResource( 2 ) +angle_start = 20 +angle_size = 50 + +[sub_resource type="Resource" id=3] +script = ExtResource( 2 ) +angle_start = 70 +angle_size = 40 + +[sub_resource type="Resource" id=4] +script = ExtResource( 2 ) +angle_start = 110 +angle_size = 50 + +[sub_resource type="Resource" id=5] +script = ExtResource( 2 ) +angle_start = 160 +angle_size = 40 + +[sub_resource type="Resource" id=6] +script = ExtResource( 2 ) +angle_start = 200 +angle_size = 50 + +[sub_resource type="Resource" id=7] +script = ExtResource( 2 ) +angle_start = 250 +angle_size = 40 + +[sub_resource type="Resource" id=8] +script = ExtResource( 2 ) +angle_start = 290 +angle_size = 50 + +[resource] +script = ExtResource( 1 ) +dir_angles = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ] +directions = [ ] +idles = [ ] +speaks = [ ] diff --git a/game/characters/mark/mark_anims.gd b/game/characters/mark/mark_anims.gd deleted file mode 100644 index 67b3bccc..00000000 --- a/game/characters/mark/mark_anims.gd +++ /dev/null @@ -1,90 +0,0 @@ -#const dir_angles = [ -# 0, # 0 NORTH FACE CAMERA -# 45, # 1 NORTHEAST -# 90, # 2 EAST -# 135, # 3 SOUTHEAST -# 180, # 4 SOUTH BACK TO CAMERA -# 225, # 5 SOUTHWEST -# 270, # 6 WEST -# 315, # 7 NORTHWEST -#] - -# Angle is [from_angle, area_angle] -# example : on a clock, [180, 45] starts exactly from 6 o'clock (180°) -# and stops between 7 o'clock and 8 o'clock (45° from 6 o'clock) -const dir_angles = [ - [340, 40], # 0 UP - [20, 50], # 1 RIGHT UP - [70, 40], # 2 RIGHT - [110, 50], # 3 RIGHT DOWN - [160, 40], # 4 DOWN - [200, 50], # 5 LEFT DOWN - [250, 40], # 6 LEFT - [290, 50] # 7 LEFT UP -] - -# Array of animations for each direction, from UP to RIGHT_UP clockwise -# [animation_name, scale]: scale parameter can be set to -1 to mirror the animation -const directions = [ - ["walk_up", 1], # 0 UP - ["walk_up", 1], # 1 RIGHT UP - ["walk_right", 1], # 2 RIGHT - ["walk_down", 1], # 3 RIGHT DOWN - ["walk_down", 1], # 4 DOWN - ["walk_down", 1], # 5 LEFT DOWN - ["walk_right", -1], # 6 LEFT - ["walk_up", 1] # 7 LEFT UP -] - -const idles = [ - ["idle_up", 1], # 0 UP - ["idle_up", 1], # 1 RIGHT UP - ["idle_right", 1], # 2 RIGHT - ["idle_down_right", 1], # 3 RIGHT DOWN - ["idle_down", 1], # 4 DOWN - ["idle_down_left", 1], # 5 LEFT DOWN - ["idle_left", 1], # 6 LEFT - ["idle_up", 1] # 7 LEFT UP -] - -const speaks = [ - ["speak_up", 1], # 0 UP - ["speak_up", 1], # 1 RIGHT UP - ["speak_right", 1], # 2 RIGHT - ["speak_down", 1], # 3 RIGHT DOWN - ["speak_down", 1], # 4 DOWN - ["speak_down", 1], # 5 LEFT DOWN - ["speak_right", -1], # 6 LEFT - ["speak_up", 1] # 7 LEFT UP -] - - -#const directions = ["walk_left", -1, # 0 -# "walk_left", -1, # 1 -# "walk_back", 1, # 2 -# "walk_back", 1, # 3 -# "walk_left", 1, # 4 -# "walk_left", 1, # 5 -# "walk_front", 1, # 6 -# "walk_front", 1 # 7 -# ] -# -#const idles = [ "idle_front_right", 1, # 0 -# "idle_front_right", 1, # 1 -# "idle_back", 1, # 2 -# "idle_back", 1, # 3 -# "idle_front_left", 1, # 4 -# "idle_front_left", 1, # 5 -# "idle_front", 1, # 6 -# "idle_front", 1 # 7 -# ] -# -#const speaks = ["idle_front_left", 1, # 0 -# "idle_front_left", 1, # 1 -# "idle_back", 1, # 2 -# "idle_back", 1, # 3 -# "idle_front_right", 1, # 4 -# "idle_front_right", 1, # 5 -# "idle_front", 1, # 6 -# "idle_front", 1 # 7 -# ] diff --git a/project.godot b/project.godot index 09891336..25ae2656 100644 --- a/project.godot +++ b/project.godot @@ -84,6 +84,16 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/core-scripts/esc/esc_action_manager.gd" }, { +"base": "Resource", +"class": "ESCAnimationName", +"language": "GDScript", +"path": "res://addons/escoria-core/game/core-scripts/resources/esc_animationname.gd" +}, { +"base": "Resource", +"class": "ESCAnimationResource", +"language": "GDScript", +"path": "res://addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd" +}, { "base": "TextureRect", "class": "ESCBackground", "language": "GDScript", @@ -154,6 +164,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/scenes/dialogs/dialog_player.gd" }, { +"base": "Resource", +"class": "ESCDirectionAngle", +"language": "GDScript", +"path": "res://addons/escoria-core/game/core-scripts/resources/esc_directionangle.gd" +}, { "base": "ESCStatement", "class": "ESCEvent", "language": "GDScript", @@ -470,6 +485,8 @@ _global_script_class_icons={ "DebugCommand": "", "DecGlobalCommand": "", "ESCActionManager": "", +"ESCAnimationName": "", +"ESCAnimationResource": "", "ESCBackground": "", "ESCBackgroundMusic": "", "ESCBackgroundSound": "", @@ -484,6 +501,7 @@ _global_script_class_icons={ "ESCDialog": "", "ESCDialogOption": "", "ESCDialogsPlayer": "", +"ESCDirectionAngle": "", "ESCEvent": "", "ESCEventManager": "", "ESCExecution": "", @@ -548,7 +566,7 @@ _global_script_class_icons={ [application] -config/name="Escoria" +config/name="Escoria-reloaded" run/main_scene="res://addons/escoria-core/game/main_scene.tscn" boot_splash/image="res://addons/escoria-core/logo/escoria-logo-small.png" boot_splash/fullsize=false @@ -610,7 +628,7 @@ ui/game_scene="res://addons/escoria-ui-9verbs/game.tscn" esc_show_debug_prompt={ "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":16777245,"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":16777245,"physical_scancode":0,"unicode":0,"echo":false,"script":null) ] } switch_action_verb={