Compare commits

..

2 Commits

Author SHA1 Message Date
8fa6a6f370 Setup project with player from previous work! 2025-03-08 22:07:24 -08:00
d6bfe92c00 Importing a player 2025-03-08 15:51:56 -08:00
38 changed files with 1953 additions and 24 deletions

View File

@ -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 )

0
assets
View File

BIN
assets/MManPortrait.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Mega.png-398a010e8e27ac84fe3335706e03da1e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/actors/players/playerD/Mega.png"
dest_files=[ "res://.import/Mega.png-398a010e8e27ac84fe3335706e03da1e.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

View File

@ -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 )

View File

@ -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

View File

@ -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 )

View File

@ -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

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/Smiley.png-8c81e651641e7afc57c144693e5c2423.stex"
path="res://.import/Smiley.png-2f59c79aee2a45c4593491b462fdf12b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/templates/Actor/resources/Smiley.png"
dest_files=[ "res://.import/Smiley.png-8c81e651641e7afc57c144693e5c2423.stex" ]
source_file="res://lib/templates/Actor/resources/Smiley.png"
dest_files=[ "res://.import/Smiley.png-2f59c79aee2a45c4593491b462fdf12b.stex" ]
[params]

View File

@ -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 )

View File

@ -9,13 +9,91 @@
config_version=4
_global_script_classes=[ {
"base": "KinematicBody2D",
"class": "Actor",
"language": "GDScript",
"path": "res://lib/classes/actor.gd"
}, {
"base": "",
"class": "GitAPI",
"language": "NativeScript",
"path": "res://addons/godot-git-plugin/git_api.gdns"
}, {
"base": "Node",
"class": "HealthComponent",
"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",
"path": "res://lib/templates/Interactable/Interactable_Component.gd"
}, {
"base": "Node2D",
"class": "Interactable_Receiver",
"language": "GDScript",
"path": "res://lib/templates/Interactable/Interactable_Receiver.gd"
}, {
"base": "Reference",
"class": "ModifierProperties",
"language": "GDScript",
"path": "res://lib/classes/state_modifier_properties.gd"
}, {
"base": "Node2D",
"class": "Modifier_Receiver",
"language": "GDScript",
"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"
}, {
"base": "State",
"class": "StateAnimatedActor",
"language": "GDScript",
"path": "res://lib/classes/state_animated_actor.gd"
}, {
"base": "Node",
"class": "StateMachine",
"language": "GDScript",
"path": "res://lib/classes/state_machine.gd"
}, {
"base": "StateMachine",
"class": "StateMachineAnimatedActor",
"language": "GDScript",
"path": "res://lib/classes/state_machine_animated_actor.gd"
}, {
"base": "Reference",
"class": "StateModifier",
"language": "GDScript",
"path": "res://lib/classes/state_modifier.gd"
} ]
_global_script_class_icons={
"GitAPI": ""
"Actor": "",
"GitAPI": "",
"HealthComponent": "",
"HealthPickup": "",
"Interactable": "",
"Interactable_Receiver": "",
"ModifierProperties": "",
"Modifier_Receiver": "",
"MovementComponent": "",
"State": "",
"StateAnimatedActor": "",
"StateMachine": "",
"StateMachineAnimatedActor": "",
"StateModifier": ""
}
[application]
@ -34,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]

View File

@ -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

View File

@ -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 )

14
src/Interactables/Door.gd Normal file
View File

@ -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

View File

@ -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 )

View File

@ -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()

View File

@ -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

View File

@ -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
} ]

View File

@ -0,0 +1,75 @@
extends Actor
export var player_number: int = 1
onready var player_hurtbox = $Hurtbox_Component/CollisionShape2D
# Removing gun for now
#onready var gun = $Gun
func _ready() -> void:
PlayerInfo.player_health = $Health_Component.health
# Disabled for testing
#global_position = LevelInfo.player_start_position.transform.origin
movement_component.player_number = player_number
var portrait = preload("res://assets/MManPortrait.png")
func hit_Receiver(damage):
$Hurtbox_Component.set_hurtbox(false)
$Health_Component.take_damage(damage)
if $Health_Component.health > 0:
movement_state_machine.change_state($movement_state_machine/hurt)
PlayerInfo.player_health = $Health_Component.health
if PlayerInfo.player_health <= 0:
return
yield( get_tree().create_timer(2 + $movement_state_machine/hurt.timeout_seconds), "timeout")
$Hurtbox_Component.set_hurtbox(true)
func receive_modifier(incomming_modifier :StateModifier, is_adding_modifier_operation: bool):
#var mod :StateModifier
if is_adding_modifier_operation:
print("Player Received modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = incomming_modifier
else:
print("Player Removed modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = null
func touch_the_thing(the_thing: Interactable) -> bool:
print("You see! a THING...", the_thing.name)
if the_thing is HealthPickup:
# Do some healthy stuff.
the_thing.trigger_interaction()
return false
return true
func _on_attack_do_attack():
var is_shooting = false
print("Direction: ", transform.x.x)
# Gun removed for now
#is_shooting = gun.shoot(int(transform.x.x))
func _on_Health_Component_health_depleted():
$Hurtbox_Component.set_hurtbox(false)
movement_state_machine.change_state($movement_state_machine/die)
yield( get_tree().create_timer(10), "timeout")
#queue_free()
func _on_roll_frame_reached(state_name, animation_name, frame_number):
print("I'm invincible!!!")
$Hurtbox_Component.set_hurtbox(false)
func _on_roll_state_exited():
print("Nevermind. I'm vulnerable.")
$Hurtbox_Component.set_hurtbox(true)
func _on_die_state_entered():
pass # Replace with function body.

View File

@ -0,0 +1,695 @@
[gd_scene load_steps=126 format=2]
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[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://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://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://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-398a010e8e27ac84fe3335706e03da1e.stex"
[sub_resource type="AtlasTexture" id=91]
atlas = SubResource( 90 )
region = Rect2( 1680, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=92]
atlas = SubResource( 90 )
region = Rect2( 1920, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=93]
atlas = SubResource( 90 )
region = Rect2( 2160, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=94]
atlas = SubResource( 90 )
region = Rect2( 2400, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=95]
atlas = SubResource( 90 )
region = Rect2( 0, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=96]
atlas = SubResource( 90 )
region = Rect2( 240, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=97]
atlas = SubResource( 90 )
region = Rect2( 1440, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=98]
atlas = SubResource( 90 )
region = Rect2( 480, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=99]
atlas = SubResource( 90 )
region = Rect2( 480, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=100]
atlas = SubResource( 90 )
region = Rect2( 720, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=101]
atlas = SubResource( 90 )
region = Rect2( 960, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=102]
atlas = SubResource( 90 )
region = Rect2( 1200, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=103]
atlas = SubResource( 90 )
region = Rect2( 1440, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=104]
atlas = SubResource( 90 )
region = Rect2( 240, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=105]
atlas = SubResource( 90 )
region = Rect2( 480, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=106]
atlas = SubResource( 90 )
region = Rect2( 720, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=107]
atlas = SubResource( 90 )
region = Rect2( 960, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=108]
atlas = SubResource( 90 )
region = Rect2( 1200, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=109]
atlas = SubResource( 90 )
region = Rect2( 1440, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=110]
atlas = SubResource( 90 )
region = Rect2( 1680, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=111]
atlas = SubResource( 90 )
region = Rect2( 1920, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=112]
atlas = SubResource( 90 )
region = Rect2( 2160, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=113]
atlas = SubResource( 90 )
region = Rect2( 2400, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=114]
atlas = SubResource( 90 )
region = Rect2( 0, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=115]
atlas = SubResource( 90 )
region = Rect2( 960, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=116]
atlas = SubResource( 90 )
region = Rect2( 1200, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=117]
atlas = SubResource( 90 )
region = Rect2( 1200, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=118]
atlas = SubResource( 90 )
region = Rect2( 0, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=119]
atlas = SubResource( 90 )
region = Rect2( 1440, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=120]
atlas = SubResource( 90 )
region = Rect2( 1680, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=121]
atlas = SubResource( 90 )
region = Rect2( 1920, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=122]
atlas = SubResource( 90 )
region = Rect2( 2160, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=123]
atlas = SubResource( 90 )
region = Rect2( 240, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=124]
atlas = SubResource( 90 )
region = Rect2( 480, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=125]
atlas = SubResource( 90 )
region = Rect2( 720, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=126]
atlas = SubResource( 90 )
region = Rect2( 240, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=127]
atlas = SubResource( 90 )
region = Rect2( 1680, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=128]
atlas = SubResource( 90 )
region = Rect2( 1920, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=129]
atlas = SubResource( 90 )
region = Rect2( 2160, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=130]
atlas = SubResource( 90 )
region = Rect2( 2400, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=131]
atlas = SubResource( 90 )
region = Rect2( 0, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=132]
atlas = SubResource( 90 )
region = Rect2( 240, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=133]
atlas = SubResource( 90 )
region = Rect2( 480, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=134]
atlas = SubResource( 90 )
region = Rect2( 720, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=135]
atlas = SubResource( 90 )
region = Rect2( 960, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=136]
atlas = SubResource( 90 )
region = Rect2( 1200, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=137]
atlas = SubResource( 90 )
region = Rect2( 1680, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=138]
atlas = SubResource( 90 )
region = Rect2( 1920, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=139]
atlas = SubResource( 90 )
region = Rect2( 2160, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=140]
atlas = SubResource( 90 )
region = Rect2( 2400, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=141]
atlas = SubResource( 90 )
region = Rect2( 0, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=142]
atlas = SubResource( 90 )
region = Rect2( 240, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=143]
atlas = SubResource( 90 )
region = Rect2( 480, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=144]
atlas = SubResource( 90 )
region = Rect2( 720, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=145]
atlas = SubResource( 90 )
region = Rect2( 960, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=146]
atlas = SubResource( 90 )
region = Rect2( 1200, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=147]
atlas = SubResource( 90 )
region = Rect2( 1440, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=148]
atlas = SubResource( 90 )
region = Rect2( 1920, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=149]
atlas = SubResource( 90 )
region = Rect2( 2160, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=150]
atlas = SubResource( 90 )
region = Rect2( 2400, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=151]
atlas = SubResource( 90 )
region = Rect2( 0, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=152]
atlas = SubResource( 90 )
region = Rect2( 240, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=153]
atlas = SubResource( 90 )
region = Rect2( 480, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=154]
atlas = SubResource( 90 )
region = Rect2( 720, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=155]
atlas = SubResource( 90 )
region = Rect2( 960, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=156]
atlas = SubResource( 90 )
region = Rect2( 1200, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=157]
atlas = SubResource( 90 )
region = Rect2( 1440, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=158]
atlas = SubResource( 90 )
region = Rect2( 1920, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=159]
atlas = SubResource( 90 )
region = Rect2( 2160, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=160]
atlas = SubResource( 90 )
region = Rect2( 2400, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=161]
atlas = SubResource( 90 )
region = Rect2( 0, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=162]
atlas = SubResource( 90 )
region = Rect2( 240, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=163]
atlas = SubResource( 90 )
region = Rect2( 480, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=164]
atlas = SubResource( 90 )
region = Rect2( 720, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=165]
atlas = SubResource( 90 )
region = Rect2( 960, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=166]
atlas = SubResource( 90 )
region = Rect2( 1200, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=167]
atlas = SubResource( 90 )
region = Rect2( 1440, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=168]
atlas = SubResource( 90 )
region = Rect2( 2400, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=169]
atlas = SubResource( 90 )
region = Rect2( 0, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=170]
atlas = SubResource( 90 )
region = Rect2( 720, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=171]
atlas = SubResource( 90 )
region = Rect2( 960, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=172]
atlas = SubResource( 90 )
region = Rect2( 1200, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=173]
atlas = SubResource( 90 )
region = Rect2( 1440, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=174]
atlas = SubResource( 90 )
region = Rect2( 1680, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=175]
atlas = SubResource( 90 )
region = Rect2( 1920, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=176]
atlas = SubResource( 90 )
region = Rect2( 2160, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=177]
atlas = SubResource( 90 )
region = Rect2( 2400, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=178]
atlas = SubResource( 90 )
region = Rect2( 0, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=179]
atlas = SubResource( 90 )
region = Rect2( 240, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=180]
atlas = SubResource( 90 )
region = Rect2( 480, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=181]
atlas = SubResource( 90 )
region = Rect2( 720, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=182]
atlas = SubResource( 90 )
region = Rect2( 960, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=183]
atlas = SubResource( 90 )
region = Rect2( 1200, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=184]
atlas = SubResource( 90 )
region = Rect2( 1440, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=185]
atlas = SubResource( 90 )
region = Rect2( 1680, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=186]
atlas = SubResource( 90 )
region = Rect2( 1920, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=187]
atlas = SubResource( 90 )
region = Rect2( 2160, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=188]
atlas = SubResource( 90 )
region = Rect2( 2400, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=189]
atlas = SubResource( 90 )
region = Rect2( 0, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=190]
atlas = SubResource( 90 )
region = Rect2( 240, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=191]
atlas = SubResource( 90 )
region = Rect2( 480, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=192]
atlas = SubResource( 90 )
region = Rect2( 720, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=193]
atlas = SubResource( 90 )
region = Rect2( 960, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=194]
atlas = SubResource( 90 )
region = Rect2( 1680, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=195]
atlas = SubResource( 90 )
region = Rect2( 1680, 480, 240, 160 )
[sub_resource type="SpriteFrames" id=196]
animations = [ {
"frames": [ SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ) ],
"loop": true,
"name": "climb",
"speed": 10.0
}, {
"frames": [ SubResource( 97 ) ],
"loop": false,
"name": "climb_step",
"speed": 10.0
}, {
"frames": [ SubResource( 98 ) ],
"loop": false,
"name": "climb_upstep",
"speed": 10.0
}, {
"frames": [ SubResource( 99 ), SubResource( 99 ), SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 103 ), SubResource( 103 ) ],
"loop": false,
"name": "dash",
"speed": 10.0
}, {
"frames": [ SubResource( 104 ), SubResource( 105 ), SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 112 ), SubResource( 114 ) ],
"loop": false,
"name": "die",
"speed": 10.0
}, {
"frames": [ SubResource( 115 ), SubResource( 116 ) ],
"loop": true,
"name": "hurt",
"speed": 4.0
}, {
"frames": [ SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ) ],
"loop": true,
"name": "idle",
"speed": 10.0
}, {
"frames": [ SubResource( 123 ), SubResource( 124 ), SubResource( 125 ) ],
"loop": true,
"name": "idle_shield",
"speed": 10.0
}, {
"frames": [ SubResource( 126 ) ],
"loop": true,
"name": "idle_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 128 ), SubResource( 131 ), SubResource( 132 ), SubResource( 133 ) ],
"loop": false,
"name": "jump",
"speed": 10.0
}, {
"frames": [ SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 135 ), SubResource( 136 ) ],
"loop": false,
"name": "jump_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 137 ), SubResource( 138 ), SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ) ],
"loop": false,
"name": "roll",
"speed": 10.0
}, {
"frames": [ SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 151 ), SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ) ],
"loop": true,
"name": "run",
"speed": 10.0
}, {
"frames": [ SubResource( 158 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ) ],
"loop": true,
"name": "run_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 168 ), SubResource( 169 ), SubResource( 126 ) ],
"loop": false,
"name": "shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 170 ), SubResource( 171 ), SubResource( 172 ), SubResource( 172 ), SubResource( 173 ), SubResource( 174 ), SubResource( 175 ), SubResource( 176 ), SubResource( 176 ), SubResource( 177 ), SubResource( 178 ), SubResource( 179 ), SubResource( 180 ), SubResource( 181 ), SubResource( 182 ), SubResource( 183 ), SubResource( 184 ), SubResource( 185 ), SubResource( 186 ), SubResource( 187 ), SubResource( 188 ), SubResource( 189 ) ],
"loop": true,
"name": "slash",
"speed": 10.0
}, {
"frames": [ SubResource( 118 ), SubResource( 190 ), SubResource( 191 ), SubResource( 192 ), SubResource( 193 ) ],
"loop": false,
"name": "stand",
"speed": 10.0
}, {
"frames": [ SubResource( 194 ) ],
"loop": false,
"name": "step",
"speed": 10.0
}, {
"frames": [ SubResource( 195 ) ],
"loop": false,
"name": "step_shoot",
"speed": 10.0
} ]
[sub_resource type="RectangleShape2D" id=89]
extents = Vector2( 12, 16 )
[node name="Player" instance=ExtResource( 1 )]
script = ExtResource( 3 )
actor_type = "Player"
player_number = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
position = Vector2( 0, -3.5 )
shape = SubResource( 197 )
[node name="AnimatedSprite" parent="." index="1"]
position = Vector2( -1, -51 )
frames = SubResource( 196 )
animation = "idle_shoot"
flip_h = false
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
"o_ex_p": "_+",
"o_folder": "res://assets",
"o_name": "",
"only_visible": true,
"op_exp": false,
"slice": "",
"source": "D:/Sync/Assets/Library/Mega.ase"
}
}
[node name="movement_component" parent="." index="2"]
script = ExtResource( 2 )
player_number = 1
interactable_node = NodePath("../Interactable_Receiver")
[node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 4 )
debug_state = true
move_speed = 0.0
animation_sequence = [ "idle" ]
jump_node = NodePath("../jump")
attack_node = NodePath("../attack")
dash_node = NodePath("../dash")
roll_node = NodePath("../roll")
climb_node = NodePath("../climb")
[node name="fall" parent="movement_state_machine" index="1"]
script = ExtResource( 6 )
move_speed = 90.0
animation_sequence = [ "jump" ]
landing_node = NodePath("")
[node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 5 )
move_speed = 90.0
animation_sequence = [ "step", "run" ]
jump_node = NodePath("../jump")
attack_node = NodePath("../attack")
[node name="jump" type="Node" parent="movement_state_machine" index="3"]
script = ExtResource( 8 )
move_speed = 90.0
move_modifier_move_acceleration = -100.0
animation_sequence = [ "jump" ]
idle_node = NodePath("../idle")
fall_node = NodePath("../fall")
attack_node = NodePath("../attack")
jump_force = 250.0
[node name="attack" type="Node" parent="movement_state_machine" index="4"]
script = ExtResource( 10 )
timeout_seconds = 1.5
move_speed = 90.0
animation_sequence = [ "shoot" ]
jump_node = NodePath("../jump")
idle_node = NodePath("../idle")
fall_node = NodePath("../fall")
move_node = NodePath("../move")
[node name="hurt" type="Node" parent="movement_state_machine" index="5"]
script = ExtResource( 12 )
timeout_seconds = 2.0
move_speed = -10.0
animation_sequence = [ "hurt" ]
idle_node = NodePath("../idle")
[node name="dash" type="Node" parent="movement_state_machine" index="6"]
script = ExtResource( 11 )
move_speed = 90.0
move_speed_modifier = 90.0
move_modifier_move_acceleration = -100.0
jerk_factor = -20.0
animation_sequence = [ "dash" ]
fall_node = NodePath("../fall")
idle_node = NodePath("../idle")
attack_node = NodePath("../attack")
jump_node = NodePath("../jump")
[node name="roll" type="Node" parent="movement_state_machine" index="7"]
script = ExtResource( 14 )
move_speed = 150.0
animation_sequence = [ "roll" ]
emitter_frame_subscriptions = {
2: "roll"
}
fall_node = NodePath("../fall")
idle_node = NodePath("../idle")
[node name="die" type="Node" parent="movement_state_machine" index="8"]
script = ExtResource( 15 )
animation_sequence = [ "die" ]
[node name="climb" type="Node" parent="movement_state_machine" index="9"]
script = ExtResource( 17 )
debug_state = true
animation_sequence = [ "climb_step", "climb", "climb_upstep" ]
idle_node = NodePath("../idle")
[node name="Hurtbox_Component" parent="." index="4"]
collision_layer = 16
collision_mask = 128
hurtbox_entered_function = "hit_Receiver"
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
position = Vector2( 0, -2 )
shape = SubResource( 89 )
[node name="Health_Component" parent="." index="6" instance=ExtResource( 7 )]
max_health = 100
[node name="Interactable_Receiver" type="Node2D" parent="." index="7"]
script = ExtResource( 16 )
interactable_parent_callback = "touch_the_thing"
[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="9"]
modulate = Color( 0.247059, 0.92549, 0.0313726, 1 )
position = Vector2( 0, 5 )
enabled = true
cast_to = Vector2( 0, 15 )
collision_mask = 1024
collide_with_areas = true
collide_with_bodies = false
[connection signal="do_attack" from="movement_state_machine/attack" to="." method="_on_attack_do_attack"]
[connection signal="frame_reached" from="movement_state_machine/roll" to="." method="_on_roll_frame_reached"]
[connection signal="state_exited" from="movement_state_machine/roll" to="." method="_on_roll_state_exited"]
[connection signal="state_entered" from="movement_state_machine/die" to="." method="_on_die_state_entered"]
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]

View File

@ -0,0 +1,140 @@
extends MovementComponent
## Constants available to you
# UP = -1.0
# DOWN = 1.0
# LEFT = -1.0
# RIGHT = 1.0
# Avalable functions to call
# A Series of helper functions
# go_up():
# go_down():
# go_left():
# go_right():
# stop():
export var player_number: int = 1
export (NodePath) var interactable_node
onready var interactable_receiver_node: Interactable_Receiver = get_node(interactable_node)
onready var ladder_detection:RayCast2D = $"../Ladder_Detection"
var ladder_collision: RayCast2D
func _ready():
ladder_collision = ladder_detection
# Guess there isn't a hit from inside in 3.5
# Remember to make raycast as tall as needed for the player
#ladder_collision.hit_from_inside = true
func process_physics(delta):
PlayerInfo.player_position = owner.global_position
func process_input(event: InputEvent):
var interactables = interactable_receiver_node.interactable_function_callables
for interactable in interactables: # Iterate through the interactable collection
if interactable is Interactable: # Make sure we didn't push something dumb in there.
if (Input.is_action_pressed("ui_up")): # We pressed up?
interactable.trigger_interaction()
get_movement_direction()
# 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 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))
# Return a boolean indicating if the character wants to jump
func wants_jump() -> bool:
if Input.is_action_just_pressed("jump_" + str(player_number)):
desired_movement_vector.y = 1
return true
else:
return false
# Return a boolean indicating if the character wants to jump
func wants_shoot() -> bool:
if Input.is_action_just_pressed("shoot_" + str(player_number)):
return true
else:
return false
func wants_dash() -> bool:
if Input.is_action_just_pressed("dash_" + str(player_number)):
return true
else:
return false
func wants_roll() -> bool:
if Input.is_action_just_pressed("dash_" + str(player_number)) and Input.is_action_pressed("ui_up"):
return true
else:
return false
func wants_climb() -> bool:
if ladder_detection.is_colliding() and Input.is_action_pressed("ui_up"):
#print("betcha wanna climb though!")
return true
else:
return false
func get_climb_shape_location() -> Vector2:
if ladder_detection.is_colliding():
var point: Vector2 = ladder_collision.get_collision_point()
var shape_id = ladder_collision.get_collider_shape()
var object = ladder_collision.get_collider()
# This works but doesn't get the shapes location.
# if object is Area2D:
# print("You got an area bro!" , object.global_position)
# This appears to get the shapes location!
var area = Physics2DServer.area_get_transform(object)
var areashape = Physics2DServer.area_get_shape_transform(object, shape_id)
var y_dir = Input.get_axis("ui_up" , "ui_down")
#var target = get_collider() # A CollisionObject2D.
#var shape_id = get_collider_shape() # The shape index in the collider.
#var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
#var shape = target.shape_owner_get_owner(owner_id)
#UiManager.debug_text = str(round(point.x)) + ' ' + str(round(point.y)) #( "Mod(" + str(sign(_move_speed_modifier)) + ") Dir(" + str(move_direction) + ") Vel(" + str(sign(current_x_velocity)) + ") Mov(" + str(sign(move_component.desired_movement_vector.x)) +
return Vector2(areashape.origin.x, y_dir)
else:
return Vector2(-1,-1)
## Other needed variables
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state
# current_movement_state:String - The name of the current State
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
# velocity: Vector2 - Current velocity, you can change this at will but state may modify it
# Declare any other member variables here. Examples:
# var a = 2
# var b = "text"
# Called every frame. 'delta' is the elapsed time since the previous frame.
# you do not normally need to define this for Actor
#func process(delta):
# pass
# For Enemy and NPC Actors:
# should be called on the frame process.
# For Player Actors:
# Should be called on the input process

View File

@ -0,0 +1,140 @@
extends StateAnimatedActor
export (NodePath) var jump_node
export (NodePath) var idle_node
export (NodePath) var fall_node
export (NodePath) var move_node
export (NodePath) var draw_weapon_node
onready var jump_state: StateAnimatedActor = get_node(jump_node)
onready var idle_state: StateAnimatedActor = get_node(idle_node)
onready var fall_state: StateAnimatedActor = get_node(fall_node)
onready var move_state: StateAnimatedActor = get_node(move_node)
#onready var weapon_state_modifier: StateModifier = get_node(draw_weapon_node)
var can_fire = true
signal do_attack()
var draw_weapon_modifier: StateModifier
func _ready():
state_timeout.connect("timeout", self, "disable_cooldown")
draw_weapon_modifier = StateModifier.new()
var mod_timer :Timer = draw_weapon_modifier.ready( "draw_weapon", "_shoot" , draw_weapon_modifier.TYPE.ANIMATION_SUFFIX, 2.0)
add_child(mod_timer)
func disable_cooldown():
if debug_state:
print("Attack state cooldown timeout. Can attack again.")
state_ready = true
func enter() -> void:
if modifier:
if modifier.get_instance_id() == draw_weapon_modifier.get_instance_id():
#print ("They the same cannot apply modifier: ", draw_weapon_modifier.get_instance_id())
modifier = null
.enter()
##TODO: Turn this to clear only the animation modifiers.
# modifier_stack_ref.clear()
# mod_animation_sequence.clear()
# #mod_animation_sequence = animation_sequence.duplicate(true)
# mod_animation_sequence.append_array(animation_sequence)
# # Reset animation suffix in case there isn't one
# animation_suffix = '_shoot'
# animation_index = 0
# current_animation_sequence = 0
# #var enter_animation = ''
# var enter_frame = 0
#
# if debug_state:
# print(parent.name, " entering State: ", self.name)
# move_component.current_movement_state = self.name
# emit_signal("state_entered")
can_fire = true
# if modifier_stack_ref.has($"../draw_weapon") == false:
# $"../draw_weapon".enter()
# modifier_stack_ref.push_front($"../draw_weapon")
if debug_state:
print("Previous State Info: ", previous_animation_name, " ",
previous_state_frame_number, " ", previous_state_name)
match previous_animation_name:
"idle":
#animations.play("idle_shoot")
if debug_state:
print("no need to change idle animation")
"run":
animations.play("run_shoot")
animations.frame = previous_state_frame_number
"jump":
animations.play("jump_shoot")
animations.frame = previous_state_frame_number
if debug_state:
print("Starting Animation: jump_shoot at frame ", animations.animation , animations.frame)
_:
print("Warning!: Attack state encountered unhandled prev animation: ", previous_animation_name)
# An example where the modifier is left to alert on a timeout
#mod_timer.connect("timeout", draw_weapon_modifier, "_on_Timer_timeout")
# An example where the current node subscribes
#mod_timer.connect("timeout", self, "_on_Timer_timeout")
state_timeout.start()
draw_weapon_modifier.state_timeout.start()
state_ready = false
animation_finished = false
func _on_Timer_timeout():
print("Modifier Timeout from attack! Forcing animation recall")
#animations.stop()
func process_frame(delta: float) -> State:
if animation_finished:
draw_weapon_modifier.state_timeout.start()
modifier = draw_weapon_modifier
return idle_state
# if animations.frame == 2:
# animations.stop()
# if state_timeout.time_left == 0 and animations.animation == "shoot":
# return idle_state
return null
func process_physics(delta: float) -> State:
if can_fire: # trying to do this in the physics because irrecular behavior
emit_signal("do_attack")
can_fire = false
if move_component.wants_jump() and parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
jump_state.modifier = draw_weapon_modifier
return jump_state
move_actor_as_desired(delta)
# if previous_state_name == "move" and move_component.velocity.x == 0.0:
# return idle_state
if move_component.velocity.x != 0.0:
draw_weapon_modifier.state_timeout.start()
move_state.modifier = draw_weapon_modifier
#draw_weapon_modifier.transfer_owner(move_state)
return move_state
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
# if move_component.velocity.x != 0.0:
# return move_state
if !parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
fall_state.modifier = draw_weapon_modifier
return fall_state
return null

View File

@ -0,0 +1,51 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: StateAnimatedActor = get_node(idle_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
var climbing_modifier: StateModifier
func _ready():
climbing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
# climbing_modifier.ready( "landing", "jump" , climbing_modifier.TYPE.EXIT_ANIMATION)
# climbing_modifier.starting_frame = 6
#print("ready! MOD")
func enter() -> void:
.enter()
animations.frame = 5
func process_physics(delta: float) -> State:
# First allow horizontal movement.
#move_actor_as_desired(delta)
# Make wure we still want to climb
var ladder_location = move_component.get_climb_shape_location()
if ladder_location != Vector2(-1,-1):
UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location))
# An attempt to snap to the ladder location
if parent.global_position.x != round(ladder_location.x):
parent.global_translate(Vector2(round((ladder_location.x - parent.global_position.x)),(ladder_location.y * move_speed) * delta))
if ladder_location.y != 0:
animations.play()
else:
# Make sure we hopped the step index
if animation_index > 0:
animations.stop()
else:
return idle_state
#parent.move_local_x()
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
# if parent.is_on_floor():
# #modifier.reference()
# idle_state.modifier = climbing_modifier
# return idle_state
return null

View File

@ -0,0 +1,78 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
export (NodePath) var attack_node
export (NodePath) var jump_node
onready var jump_state: State = get_node(jump_node)
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
onready var attack_state: State = get_node(attack_node)
#var speed_decay_rate := 1.0
func process_physics(delta: float) -> State:
# if move_component.wants_shoot():
# return attack_state
if move_component.wants_jump():
return jump_state
# Move the last direction we were facing.
move_actor_as_desired(delta, parent.transform.x.x)
# # Assuming adjusted_move_speed is set to the mood speed modifier on state entry
# # Move speed is the base speed plus the modifier minus the decay adjusted for time
# jerk += jerk_factor * delta
# adjusted_move_speed += move_modifier_move_acceleration * delta
# var new_move_speed = move_speed + (move_acceleration * delta) + adjusted_move_speed + jerk
#
# # A really crappy normalization to prevent modifying past the base move speed.
# if move_speed_modifier > 0 and new_move_speed < move_speed: # positive modifier
# #print("nope1")
# new_move_speed = move_speed
# elif move_speed_modifier < 0 and new_move_speed > move_speed: # negative modifier
# #print("nope2")
# new_move_speed = move_speed
# else:
# UiManager.debug_text = str(round(adjusted_move_speed)) + "," + str(round(new_move_speed)) + "," + str(round(jerk))
# #print(adjusted_move_speed, ",", new_move_speed, ",", jerk)
#
# #print(new_move_speed, " ", adjusted_move_speed)
#
# move_component.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# #print(speed_multiplier)
# move_component.velocity.x = parent.transform.x.x * new_move_speed
# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
## Trying a whole new model
# var new_move_speed = move_speed * speed_multiplier
# if speed_multiplier > 1.0:
# print("PPS: ", new_move_speed * delta)
# speed_multiplier -= delta * (speed_decay_rate * speed_multiplier)
# #speed_decay_rate += delta * speed_decay_rate
#
# elif speed_multiplier < 1.0:
# speed_multiplier += delta * (speed_decay_rate * speed_multiplier)
# #speed_decay_rate += delta * speed_decay_rate
#
# # Deadzone
# if speed_multiplier < 1.1 and speed_multiplier > 0.9:
# speed_multiplier = 1.0
#
# move_component.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# #print(speed_multiplier)
# move_component.velocity.x = parent.transform.x.x * new_move_speed
# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
if move_component.velocity.x == 0.0 or animations.playing == false:
if !parent.is_on_floor():
return fall_state
else:
return idle_state
return null

View File

@ -0,0 +1,12 @@
extends StateAnimatedActor
func enter() -> void:
# modifier_stack_ref.clear()
.enter()
move_component.velocity.x = 0
func process_physics(_delta: float) -> State:
#Dead Dead dead.
#move_actor_as_desired(_delta)
return null

View File

@ -0,0 +1,50 @@
extends StateAnimatedActor
export (NodePath) var idle_node
export (NodePath) var landing_node
onready var idle_state: StateAnimatedActor = get_node(idle_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
var landing_modifier: StateModifier
func _ready():
landing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
landing_modifier.ready( "landing", "jump" , landing_modifier.TYPE.EXIT_ANIMATION)
landing_modifier.starting_frame = 6
#print("ready! MOD")
func enter() -> void:
# var landing_mod_index = modifier_stack_ref.rfind(landing_mod)
# if landing_mod_index != -1:
# #print("You're Supposed to be dead!?: ", landing_mod_index)
# modifier_stack_ref.remove(landing_mod_index)
.enter()
# Jump to fall frame
animations.frame = 5
animations.stop()
func process_physics(delta: float) -> State:
# First allow horizontal movement.
move_actor_as_desired(delta)
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
#modifier.reference()
idle_state.modifier = landing_modifier
return idle_state
return null
#func exit() -> void:
# .exit()
## push_animation_state_modifier(landing_mod)
## $"../landing".enter()
## modifier_stack_ref.push_front($"../landing")
# return

View File

@ -0,0 +1,57 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: State = get_node(idle_node)
var flash_color = Color.yellow
var store_modifier: StateModifier
func enter() -> void:
if modifier:
if debug_state:
print(name, " skipping modifier and holding for next state.")
store_modifier = modifier
modifier = null
# modifier_stack_ref.clear()
.enter()
move_component.velocity.x = 0
#parent.set_hurtbox(false)
#TODO: Error check if timer was actually instanced
state_timeout.start()
func exit() -> void:
modifier = store_modifier
.exit()
animations.modulate = Color.white
func process_input(_event: InputEvent) -> State:
# move_component.wants_jump()
move_component.get_movement_direction()
return null
func process_frame(delta: float) -> State:
# Apply a little effect when damage taken.
#UiManager.debug_text = str(abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
animations.modulate = flash_color.linear_interpolate(Color.white, abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
if state_timeout.time_left == 0:
return idle_state
return null
func process_physics(delta: float) -> State:
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
move_component.velocity.x = parent.transform.x.x * move_speed
# if (parent.direction.x > 0):
# parent.velocity.x = 1 * move_speed
# else:
# parent.velocity.x = -1 * move_speed
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
return null

View File

@ -0,0 +1,52 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var move_node
export (NodePath) var jump_node
export (NodePath) var attack_node
export (NodePath) var dash_node
export (NodePath) var roll_node
export (NodePath) var climb_node
onready var fall_state: State = get_node(fall_node)
onready var move_state: State = get_node(move_node)
onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
onready var dash_state: State = get_node(dash_node)
onready var roll_state: State = get_node(roll_node)
onready var climb_state: State = get_node(climb_node)
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
#move_component.velocity.x = 0
#move_component.momentum.x *= -1
if debug_state:
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
func process_physics(delta: float) -> State:
if move_component.wants_jump() and parent.is_on_floor():
return jump_state
# We need to offer roll before dash because the inputs are the same
if move_component.wants_roll() and parent.is_on_floor():
return roll_state
if move_component.wants_dash() and parent.is_on_floor():
return dash_state
if move_component.wants_climb():
return climb_state
if move_component.wants_shoot():
return attack_state
move_actor_as_desired(delta)
if move_component.desired_movement_vector.x != 0 and move_component.velocity.x != 0:
return move_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -0,0 +1,45 @@
extends StateAnimatedActor
export (NodePath) var idle_node
export (NodePath) var fall_node
export (NodePath) var attack_node
export (NodePath) var landing_node
onready var idle_state: State = get_node(idle_node)
onready var fall_state: State = get_node(fall_node)
onready var attack_state: State = get_node(attack_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
export var jump_force: float = 200.0
func enter() -> void:
# var landing_mod_index = modifier_stack_ref.rfind(landing_mod)
# if landing_mod_index != -1:
# #print("You're Supposed to be dead!?: ", landing_mod_index)
# modifier_stack_ref.remove(landing_mod_index)
# if modifier_stack_ref.has(landing_mod):
# print("Jump from Landing Mod at: ", modifier_stack_ref.rfind(landing_mod))
.enter()
# Apply initial jump velocity on state enter
move_component.velocity.y = -jump_force
func process_physics(delta: float) -> State:
if move_component.velocity.y > 0:
return fall_state
if move_component.wants_shoot():
return attack_state
# First allow horizontal movement.
move_actor_as_desired(delta)
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
return idle_state
return null

View File

@ -0,0 +1,34 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
export (NodePath) var jump_node
export (NodePath) var attack_node
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
func process_physics(delta: float) -> State:
if move_component.wants_jump() and parent.is_on_floor():
return jump_state
if move_component.wants_shoot():
return attack_state
move_actor_as_desired(delta)
# if move_component.velocity.x == 0.0:
# return idle_state
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if move_component.desired_movement_vector.x == 0:
return idle_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -0,0 +1,46 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
var speed_decay_rate := 1.0
func enter():
#remove_animation_state_modifiers()
.enter()
func process_physics(delta: float) -> State:
# if move_component.wants_shoot():
# return attack_state
if speed_multiplier > 1.0:
#print(speed_multiplier,", ", delta)
speed_multiplier -= delta * speed_decay_rate
speed_decay_rate += delta
elif speed_multiplier < 1.0:
speed_multiplier += delta * speed_decay_rate
speed_decay_rate += delta
# Deadzone
if speed_multiplier < 1.1 and speed_multiplier > 0.9:
speed_multiplier = 1.0
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
#print(speed_multiplier)
move_component.velocity.x = parent.transform.x.x * move_speed * speed_multiplier
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
if animations.frame >= 10:
#print("WTF - ", animations.frame, " ,", move_component.velocity.x)
if !parent.is_on_floor():
return fall_state
else:
return idle_state
return null

View File

@ -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)