diff --git a/Main.tscn b/Main.tscn index 70a653e..70f0760 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,3 +1,22 @@ -[gd_scene format=2] +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/actors/players/playerD/Player.tscn" type="PackedScene" id=1] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 208, 20 ) [node name="Main" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource( 1 )] +position = Vector2( 147, 101 ) + +[node name="ColorRect" type="ColorRect" parent="."] +margin_top = 160.0 +margin_right = 416.0 +margin_bottom = 200.0 + +[node name="StaticBody2D" type="StaticBody2D" parent="ColorRect"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="ColorRect/StaticBody2D"] +position = Vector2( 208, 20 ) +shape = SubResource( 1 ) diff --git a/assets/MManPortrait.png b/assets/MManPortrait.png new file mode 100644 index 0000000..4ee8b47 Binary files /dev/null and b/assets/MManPortrait.png differ diff --git a/assets/MManPortrait.png.import b/assets/MManPortrait.png.import new file mode 100644 index 0000000..53014f9 --- /dev/null +++ b/assets/MManPortrait.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/MManPortrait.png-4e2ec0d6412baee3672a65d68519d9e1.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/MManPortrait.png" +dest_files=[ "res://.import/MManPortrait.png-4e2ec0d6412baee3672a65d68519d9e1.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/playerD/Mega.png b/assets/actors/players/playerD/Mega.png index 4175bd2..b02e0d6 100644 Binary files a/assets/actors/players/playerD/Mega.png and b/assets/actors/players/playerD/Mega.png differ diff --git a/lib/components/GenericReceiver.tscn b/lib/components/GenericReceiver.tscn index 487ea0b..c338d8c 100644 --- a/lib/components/GenericReceiver.tscn +++ b/lib/components/GenericReceiver.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/GenericReceiver.gd" type="Script" id=1] +[ext_resource path="res://lib/components/GenericReceiver.gd" type="Script" id=1] [node name="GenericReceiver" type="Node"] script = ExtResource( 1 ) diff --git a/lib/components/GenericSender.tscn b/lib/components/GenericSender.tscn index efbdbd8..ddf6493 100644 --- a/lib/components/GenericSender.tscn +++ b/lib/components/GenericSender.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/GenericSender.gd" type="Script" id=1] +[ext_resource path="res://lib/components/GenericSender.gd" type="Script" id=1] [node name="GenericSender" type="Area2D"] collision_layer = 0 diff --git a/lib/components/Health_Component.tscn b/lib/components/Health_Component.tscn index 9baee23..2a6c49f 100644 --- a/lib/components/Health_Component.tscn +++ b/lib/components/Health_Component.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/Health_Component.gd" type="Script" id=1] +[ext_resource path="res://lib/components/Health_Component.gd" type="Script" id=1] [node name="Health_Component" type="Node"] script = ExtResource( 1 ) diff --git a/lib/components/Hitbox_Component.tscn b/lib/components/Hitbox_Component.tscn index 740633b..aed78f6 100644 --- a/lib/components/Hitbox_Component.tscn +++ b/lib/components/Hitbox_Component.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/Hitbox_Component.gd" type="Script" id=1] +[ext_resource path="res://lib/components/Hitbox_Component.gd" type="Script" id=1] [node name="Hitbox_Component" type="Area2D"] collision_layer = 128 diff --git a/lib/components/Hurtbox_Component.tscn b/lib/components/Hurtbox_Component.tscn index ce0b294..3ab3698 100644 --- a/lib/components/Hurtbox_Component.tscn +++ b/lib/components/Hurtbox_Component.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/Hurtbox_Component.gd" type="Script" id=1] +[ext_resource path="res://lib/components/Hurtbox_Component.gd" type="Script" id=1] [node name="Hurtbox_Component" type="Area2D"] script = ExtResource( 1 ) diff --git a/lib/components/Modifier_Component.tscn b/lib/components/Modifier_Component.tscn index cd6c7d0..c8c24c8 100644 --- a/lib/components/Modifier_Component.tscn +++ b/lib/components/Modifier_Component.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/Modifier_Component.gd" type="Script" id=1] +[ext_resource path="res://lib/components/Modifier_Component.gd" type="Script" id=1] [node name="Modifier_Component" type="Area2D"] script = ExtResource( 1 ) diff --git a/lib/components/Modifier_Receiver.tscn b/lib/components/Modifier_Receiver.tscn index 6e0c4a3..7ced085 100644 --- a/lib/components/Modifier_Receiver.tscn +++ b/lib/components/Modifier_Receiver.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/components/Modifier_Receiver.gd" type="Script" id=1] +[ext_resource path="res://lib/components/Modifier_Receiver.gd" type="Script" id=1] [node name="Modifier_Receiver" type="Node2D"] script = ExtResource( 1 ) diff --git a/lib/templates/Actor/ActorTemplate.tscn b/lib/templates/Actor/ActorTemplate.tscn index f8c863b..c9d86f8 100644 --- a/lib/templates/Actor/ActorTemplate.tscn +++ b/lib/templates/Actor/ActorTemplate.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=17 format=2] -[ext_resource path="res://src/components/Hurtbox_Component.tscn" type="PackedScene" id=1] -[ext_resource path="res://src/state_machine_animated_actor.gd" type="Script" id=2] -[ext_resource path="res://src/templates/Actor/states/fall.gd" type="Script" id=3] -[ext_resource path="res://src/templates/Actor/states/idle.gd" type="Script" id=4] -[ext_resource path="res://src/movement_component.gd" type="Script" id=5] -[ext_resource path="res://src/templates/Actor/resources/Smiley.png" type="Texture" id=6] -[ext_resource path="res://src/templates/Actor/states/move.gd" type="Script" id=7] -[ext_resource path="res://src/actor.gd" type="Script" id=8] +[ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=1] +[ext_resource path="res://lib/classes/state_machine_animated_actor.gd" type="Script" id=2] +[ext_resource path="res://lib/templates/Actor/states/fall.gd" type="Script" id=3] +[ext_resource path="res://lib/templates/Actor/states/idle.gd" type="Script" id=4] +[ext_resource path="res://src/classes/movement_component.gd" type="Script" id=5] +[ext_resource path="res://lib/templates/Actor/resources/Smiley.png" type="Texture" id=6] +[ext_resource path="res://lib/templates/Actor/states/move.gd" type="Script" id=7] +[ext_resource path="res://lib/classes/actor.gd" type="Script" id=8] [sub_resource type="AtlasTexture" id=76] atlas = ExtResource( 6 ) diff --git a/lib/templates/Interactable/Interactable_Component.tscn b/lib/templates/Interactable/Interactable_Component.tscn index c114073..f1245a9 100644 --- a/lib/templates/Interactable/Interactable_Component.tscn +++ b/lib/templates/Interactable/Interactable_Component.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/templates/Interactable/Interactable_Component.gd" type="Script" id=2] +[ext_resource path="res://lib/templates/Interactable/Interactable_Component.gd" type="Script" id=2] [node name="Interactable_Template" type="Area2D"] script = ExtResource( 2 ) diff --git a/project.godot b/project.godot index 79f53d8..a8e35b9 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://lib/components/Health_Component.gd" }, { +"base": "Interactable", +"class": "HealthPickup", +"language": "GDScript", +"path": "res://src/Interactables/HealthPickup.gd" +}, { "base": "Area2D", "class": "Interactable", "language": "GDScript", @@ -45,6 +50,11 @@ _global_script_classes=[ { "path": "res://lib/components/Modifier_Receiver.gd" }, { "base": "Node", +"class": "MovementComponent", +"language": "GDScript", +"path": "res://src/classes/movement_component.gd" +}, { +"base": "Node", "class": "State", "language": "GDScript", "path": "res://lib/classes/state.gd" @@ -73,10 +83,12 @@ _global_script_class_icons={ "Actor": "", "GitAPI": "", "HealthComponent": "", +"HealthPickup": "", "Interactable": "", "Interactable_Receiver": "", "ModifierProperties": "", "Modifier_Receiver": "", +"MovementComponent": "", "State": "", "StateAnimatedActor": "", "StateMachine": "", @@ -100,9 +112,9 @@ animation/layers/only_include_visible_layers_by_default=true [autoload] -PlayerInfo="*res://src/singleton_autoloads/PlayerInfo.gd" -UiManager="*res://src/singleton_autoloads/UIManager.gd" -LevelInfo="*res://src/singleton_autoloads/LevelInfo.gd" +PlayerInfo="*res://lib/singleton_autoloads/PlayerInfo.gd" +UiManager="*res://lib/singleton_autoloads/UIManager.gd" +LevelInfo="*res://lib/singleton_autoloads/LevelInfo.gd" [debug] diff --git a/src/Interactables/Chest.gd b/src/Interactables/Chest.gd new file mode 100644 index 0000000..fef2b16 --- /dev/null +++ b/src/Interactables/Chest.gd @@ -0,0 +1,22 @@ +extends Interactable + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +onready var sprite: Sprite = $Sprite + +const pickup = preload("res://src/Interactables/HealthPickup.tscn") +var opened := false + +func trigger_interaction(): + # This is something that should maybe be extended for every differant interactible. + # They could inherit from this base class and implement this function. + sprite.frame = 1 + + if !opened: + var chest_item = pickup.instance() + chest_item.global_position = global_position + Vector2(0,-50) + owner.add_child(chest_item) + opened = true diff --git a/src/Interactables/Chest.tscn b/src/Interactables/Chest.tscn new file mode 100644 index 0000000..27ff78b --- /dev/null +++ b/src/Interactables/Chest.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://lib/templates/Interactable/Interactable_Component.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Interactables/Chest.gd" type="Script" id=2] +[ext_resource path="res://assets/High Forest/Assets/Interior-01.png" type="Texture" id=3] + +[sub_resource type="RectangleShape2D" id=1] + +[node name="Chest" instance=ExtResource( 1 )] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="." index="0"] +texture = ExtResource( 3 ) +vframes = 2 +region_enabled = true +region_rect = Rect2( 49, 80, 30, 64 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +modulate = Color( 0.0313726, 1, 0, 1 ) +position = Vector2( 0, 3 ) +shape = SubResource( 1 ) diff --git a/src/Interactables/Door.gd b/src/Interactables/Door.gd new file mode 100644 index 0000000..684e18d --- /dev/null +++ b/src/Interactables/Door.gd @@ -0,0 +1,14 @@ +extends Interactable + +onready var door_animation: AnimatedSprite = $AnimatedSprite + +func trigger_interaction(): + + door_animation.play("default") + yield( door_animation, "animation_finished") + $StaticBody2D/CollisionShape2D.disabled = true + # This is something that should maybe be extended for every differant interactible. + # They could inherit from this base class and implement this function. +# sprite.frame = 1 + pass + diff --git a/src/Interactables/Door.tscn b/src/Interactables/Door.tscn new file mode 100644 index 0000000..6fb3b7d --- /dev/null +++ b/src/Interactables/Door.tscn @@ -0,0 +1,68 @@ +[gd_scene load_steps=15 format=2] + +[ext_resource path="res://lib/templates/Interactable/Interactable_Component.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Interactables/Door.gd" type="Script" id=2] +[ext_resource path="res://assets/mmz1_door.png" type="Texture" id=3] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 3 ) +region = Rect2( 0, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 3 ) +region = Rect2( 34, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 3 ) +region = Rect2( 68, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 3 ) +region = Rect2( 102, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 3 ) +region = Rect2( 136, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 3 ) +region = Rect2( 170, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 3 ) +region = Rect2( 204, 0, 34, 94 ) + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 3 ) +region = Rect2( 238, 0, 34, 94 ) + +[sub_resource type="SpriteFrames" id=9] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ], +"loop": false, +"name": "default", +"speed": 5.0 +} ] + +[sub_resource type="RectangleShape2D" id=10] +extents = Vector2( 40, 21 ) + +[sub_resource type="RectangleShape2D" id=11] +extents = Vector2( 19, 39 ) + +[node name="Door" instance=ExtResource( 1 )] +collision_layer = 0 +collision_mask = 2 +script = ExtResource( 2 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"] +frames = SubResource( 9 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +modulate = Color( 0, 1, 0.0392157, 1 ) +shape = SubResource( 10 ) + +[node name="StaticBody2D" type="StaticBody2D" parent="." index="2"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D" index="0"] +shape = SubResource( 11 ) diff --git a/src/Interactables/HealthPickup.gd b/src/Interactables/HealthPickup.gd new file mode 100644 index 0000000..d77ee57 --- /dev/null +++ b/src/Interactables/HealthPickup.gd @@ -0,0 +1,28 @@ +class_name HealthPickup +extends Interactable + + +onready var health_icon: AnimatedSprite = $AnimatedSprite + +onready var drop_raycast: RayCast2D = $RayCast2D + +func _ready(): + #gravity = ProjectSettings.get_setting("physics/2d/default_gravity") + gravity = 90 + # Doesn't get enabled until it drops + monitoring = false + +func _physics_process(delta): + + if drop_raycast.is_colliding() == false: + var velocity = Vector2(0,0) + position.y += delta * gravity + else: + monitoring = true + +func trigger_interaction(): + # This is something that should maybe be extended for every differant interactible. + # They could inherit from this base class and implement this function. +# sprite.frame = 1 + queue_free() + diff --git a/src/Interactables/HealthPickup.tscn b/src/Interactables/HealthPickup.tscn new file mode 100644 index 0000000..af37fe0 --- /dev/null +++ b/src/Interactables/HealthPickup.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://src/Interactables/HealthPickup.gd" type="Script" id=1] +[ext_resource path="res://lib/templates/Interactable/Interactable_Component.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Interactables/QuickHealthPickup.tres" type="SpriteFrames" id=3] + +[sub_resource type="CircleShape2D" id=1] +radius = 6.0 + +[node name="HealthPickup" instance=ExtResource( 2 )] +monitoring = false +script = ExtResource( 1 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"] +frames = ExtResource( 3 ) +frame = 2 +playing = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +shape = SubResource( 1 ) + +[node name="RayCast2D" type="RayCast2D" parent="." index="2"] +enabled = true +cast_to = Vector2( 0, 8 ) +collision_mask = 3 diff --git a/src/Interactables/QuickHealthPickup.tres b/src/Interactables/QuickHealthPickup.tres new file mode 100644 index 0000000..9daa0ec --- /dev/null +++ b/src/Interactables/QuickHealthPickup.tres @@ -0,0 +1,27 @@ +[gd_resource type="SpriteFrames" load_steps=6 format=2] + +[ext_resource path="res://assets/quick_health.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 15, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 30, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 45, 0, 15, 13 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] diff --git a/src/actors/players/playerD/Player.gd b/src/actors/players/playerD/Player.gd index 85eba39..5157bc4 100644 --- a/src/actors/players/playerD/Player.gd +++ b/src/actors/players/playerD/Player.gd @@ -4,12 +4,15 @@ export var player_number: int = 1 onready var player_hurtbox = $Hurtbox_Component/CollisionShape2D -onready var gun = $Gun +# Removing gun for now +#onready var gun = $Gun func _ready() -> void: PlayerInfo.player_health = $Health_Component.health - global_position = LevelInfo.player_start_position.transform.origin + + # Disabled for testing + #global_position = LevelInfo.player_start_position.transform.origin movement_component.player_number = player_number @@ -49,7 +52,8 @@ func touch_the_thing(the_thing: Interactable) -> bool: func _on_attack_do_attack(): var is_shooting = false print("Direction: ", transform.x.x) - is_shooting = gun.shoot(int(transform.x.x)) + # Gun removed for now + #is_shooting = gun.shoot(int(transform.x.x)) diff --git a/src/actors/players/playerD/Player.tscn b/src/actors/players/playerD/Player.tscn index e998bfa..d7f3eb1 100644 --- a/src/actors/players/playerD/Player.tscn +++ b/src/actors/players/playerD/Player.tscn @@ -1,27 +1,27 @@ -[gd_scene load_steps=127 format=2] +[gd_scene load_steps=126 format=2] [ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] -[ext_resource path="res://actors/players/playerD/movement_component.gd" type="Script" id=2] -[ext_resource path="res://actors/players/playerD/Player.gd" type="Script" id=3] -[ext_resource path="res://actors/players/playerD/states/idle.gd" type="Script" id=4] -[ext_resource path="res://actors/players/playerD/states/move.gd" type="Script" id=5] -[ext_resource path="res://actors/players/playerD/states/fall.gd" type="Script" id=6] +[ext_resource path="res://src/actors/players/playerD/movement_component.gd" type="Script" id=2] +[ext_resource path="res://src/actors/players/playerD/Player.gd" type="Script" id=3] +[ext_resource path="res://src/actors/players/playerD/states/idle.gd" type="Script" id=4] +[ext_resource path="res://src/actors/players/playerD/states/move.gd" type="Script" id=5] +[ext_resource path="res://src/actors/players/playerD/states/fall.gd" type="Script" id=6] [ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=7] -[ext_resource path="res://actors/players/playerD/states/jump.gd" type="Script" id=8] +[ext_resource path="res://src/actors/players/playerD/states/jump.gd" type="Script" id=8] [ext_resource path="res://lib/components/Modifier_Receiver.tscn" type="PackedScene" id=9] -[ext_resource path="res://actors/players/playerD/states/attack.gd" type="Script" id=10] -[ext_resource path="res://actors/players/playerD/states/dash.gd" type="Script" id=11] -[ext_resource path="res://actors/players/playerD/states/hurt.gd" type="Script" id=12] -[ext_resource path="res://actors/players/playerD/states/roll.gd" type="Script" id=14] -[ext_resource path="res://actors/players/playerD/states/die.gd" type="Script" id=15] +[ext_resource path="res://src/actors/players/playerD/states/attack.gd" type="Script" id=10] +[ext_resource path="res://src/actors/players/playerD/states/dash.gd" type="Script" id=11] +[ext_resource path="res://src/actors/players/playerD/states/hurt.gd" type="Script" id=12] +[ext_resource path="res://src/actors/players/playerD/states/roll.gd" type="Script" id=14] +[ext_resource path="res://src/actors/players/playerD/states/die.gd" type="Script" id=15] [ext_resource path="res://lib/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16] -[ext_resource path="res://actors/players/playerD/states/climb.gd" type="Script" id=17] +[ext_resource path="res://src/actors/players/playerD/states/climb.gd" type="Script" id=17] [sub_resource type="RectangleShape2D" id=197] extents = Vector2( 13, 18.5 ) [sub_resource type="StreamTexture" id=90] -load_path = "res://.import/Mega.png-93dfe0790902b932f7b46f7b23c5d4e7.stex" +load_path = "res://.import/Mega.png-398a010e8e27ac84fe3335706e03da1e.stex" [sub_resource type="AtlasTexture" id=91] atlas = SubResource( 90 ) @@ -557,7 +557,6 @@ shape = SubResource( 197 ) position = Vector2( -1, -51 ) frames = SubResource( 196 ) animation = "idle_shoot" -frame = 0 flip_h = false __meta__ = { "_aseprite_wizard_config_": { @@ -672,30 +671,15 @@ shape = SubResource( 89 ) [node name="Health_Component" parent="." index="6" instance=ExtResource( 7 )] max_health = 100 -[node name="Gun" type="Position2D" parent="." index="7"] -physics_interpolation_mode = 1 -position = Vector2( 23, -9 ) -script = ExtResource( 13 ) - -[node name="Cooldown" type="Timer" parent="Gun" index="0"] -wait_time = 0.5 -one_shot = true - -[node name="Line2D" type="Line2D" parent="Gun" index="1"] -position = Vector2( -3, 0 ) -points = PoolVector2Array( -5, 0, 1.25483, 0, 5, 0 ) -width = 2.0 -default_color = Color( 1, 0.607843, 0, 1 ) - -[node name="Interactable_Receiver" type="Node2D" parent="." index="8"] +[node name="Interactable_Receiver" type="Node2D" parent="." index="7"] script = ExtResource( 16 ) interactable_parent_callback = "touch_the_thing" -[node name="Modifier_Receiver" parent="." index="9" instance=ExtResource( 9 )] +[node name="Modifier_Receiver" parent="." index="8" instance=ExtResource( 9 )] modifier_parent_callback = "receive_modifier" debug_receiver = true -[node name="Ladder_Detection" type="RayCast2D" parent="." index="10"] +[node name="Ladder_Detection" type="RayCast2D" parent="." index="9"] modulate = Color( 0.247059, 0.92549, 0.0313726, 1 ) position = Vector2( 0, 5 ) enabled = true diff --git a/src/classes/movement_component.gd b/src/classes/movement_component.gd new file mode 100644 index 0000000..c02b49e --- /dev/null +++ b/src/classes/movement_component.gd @@ -0,0 +1,82 @@ +class_name MovementComponent +extends Node + +## Movement component +# attempts to interact with movement of the scene root without knowing what +# it is. It can be perhaps a static body or kinematicbody +# it doesn't actually move a node, that's what the state machine does +# but it does keep track of velocity +# I can't give it an actor node or a direct reference. +# It can use a number of detection components to help inform decisions. + +export var debug_component: bool = false + +onready var desired_movement_vector: Vector2 = Vector2(0,0) +var current_movement_state:String + +# Since animactor state machine can actually view properties from this type +# I'm thinking about moving the velocity tracker in here instead of player. +var velocity = Vector2(0,0) +var momentum = Vector2(0,0) +var acceleration = Vector2(0,0) + +var sim_velocity = Vector2(0,0) + + +#Can't use floats here, switched to constants. +#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT} + +var attack_function: FuncRef + +const UP = -1.0 +const DOWN = 1.0 +const LEFT = -1.0 +const RIGHT = 1.0 + +func process_physics(delta): + pass + +func process(delta): + pass + +func process_input(event: InputEvent): + pass + +# A Series of helper functions +func go_up(): + desired_movement_vector.y = UP +func go_down(): + desired_movement_vector.y = DOWN +func go_left(): + desired_movement_vector.x = LEFT +func go_right(): + desired_movement_vector.x = RIGHT +func stop(): + desired_movement_vector = Vector2(0,0) + +# Return the desired direction of movement for the character +# in the range [-1, 1], where positive values indicate a desire +# to move to the right and negative values to the left. +func get_movement_direction() -> float: + return desired_movement_vector.x + +# Return a boolean indicating if the character wants to jump +func wants_jump() -> bool: + return false + +# Return a boolean indicating if the character wants to attack +func wants_shoot() -> bool: + return false + +# Return a boolean indicating if the character wants to dash +func wants_dash() -> bool: + return false + +func wants_roll() -> bool: + return false + +func wants_climb() -> bool: + return false + +func get_climb_shape_location() -> Vector2: + return Vector2(-1,-1)