Compare commits

..

No commits in common. "48f3e631e6104678a5c8f9cf3f7006c4953947d7" and "3e454f57858928859493e500a228235f44c54b13" have entirely different histories.

7 changed files with 14 additions and 159 deletions

View File

@ -1,10 +1,7 @@
[gd_scene load_steps=14 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/components/Hitbox_Component.tscn" type="PackedScene" id=2] [ext_resource path="res://src/components/Hurtbox_Component.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/Actors/Enemies/Spider/spider_movement_component.gd" type="Script" id=3]
[ext_resource path="res://src/Actors/Enemies/Spider/states/move.gd" type="Script" id=4]
[ext_resource path="res://src/Actors/Enemies/Spider/states/idle.gd" type="Script" id=5]
[sub_resource type="StreamTexture" id=1] [sub_resource type="StreamTexture" id=1]
load_path = "res://.import/Spider1.png-85cc52177a93c8766bb76a39a26b9d70.stex" load_path = "res://.import/Spider1.png-85cc52177a93c8766bb76a39a26b9d70.stex"
@ -54,12 +51,11 @@ extents = Vector2( 10, 12 )
[sub_resource type="CircleShape2D" id=8] [sub_resource type="CircleShape2D" id=8]
[node name="Spider" instance=ExtResource( 1 )] [node name="Spider" instance=ExtResource( 1 )]
actor_type = "Enemy"
[node name="AnimatedSprite" parent="." index="0"] [node name="AnimatedSprite" parent="." index="0"]
frames = SubResource( 6 ) frames = SubResource( 6 )
animation = "jump" animation = "idle"
frame = 2 frame = 0
__meta__ = { __meta__ = {
"_aseprite_wizard_config_": { "_aseprite_wizard_config_": {
"layer": "", "layer": "",
@ -73,25 +69,12 @@ __meta__ = {
} }
} }
[node name="movement_component" parent="." index="1"]
script = ExtResource( 3 )
[node name="movement_state_machine" parent="." index="2"]
debug_state_machine = true
[node name="idle" parent="movement_state_machine" index="0"] [node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 5 )
timeout_seconds = 0.5
animation_sequence = [ "idle" ] animation_sequence = [ "idle" ]
[node name="fall" parent="movement_state_machine" index="1"] [node name="fall" parent="movement_state_machine" index="1"]
animation_sequence = [ "land" ] animation_sequence = [ "land" ]
[node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 4 )
animation_sequence = [ "jump" ]
jump_force = 200.0
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"] [node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
position = Vector2( 0, -1 ) position = Vector2( 0, -1 )
@ -100,13 +83,9 @@ position = Vector2( 0, -2 )
shape = SubResource( 7 ) shape = SubResource( 7 )
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="." index="6"] [node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="." index="6"]
position = Vector2( 0, 1 )
[node name="Hitbox_Component" parent="." index="7" instance=ExtResource( 2 )] [node name="Hurtbox_Component2" parent="." index="7" instance=ExtResource( 2 )]
damage_amount = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox_Component2" index="0"]
position = Vector2( 0, -1 ) modulate = Color( 1, 0, 0, 1 )
shape = SubResource( 8 ) shape = SubResource( 8 )
[connection signal="screen_entered" from="VisibilityNotifier2D" to="movement_component" method="_on_VisibilityNotifier2D_screen_entered"]

View File

@ -1,67 +0,0 @@
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():
var entered_screen = false
var jump_var = false
var last_player_direction: float
func process(delta):
if entered_screen:
if current_movement_state == "idle":
# Only check the player direction in idle because we don't want to track the player during jump
if owner is Actor:
last_player_direction = sign((owner.global_position.direction_to(PlayerInfo.player_position)).x)
jump_var = true
desired_movement_vector.x = last_player_direction
else:
desired_movement_vector.x = last_player_direction
jump_var = false
return
func wants_jump() -> bool:
return jump_var
## 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
func _on_VisibilityNotifier2D_screen_entered():
entered_screen = true
print("Spider wants to play!!!")

View File

@ -1,26 +0,0 @@
extends "res://src/templates/Actor/states/idle.gd"
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
move_component.velocity.x = 0
state_timeout.start()
func process_physics(delta: float) -> State:
# parent.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
# parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
if state_timeout.time_left == 0:
move_actor_as_desired(delta)
if move_component.velocity.x != 0.0:
return move_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -1,36 +0,0 @@
extends "res://src/templates/Actor/states/move.gd"
export var jump_force: float = 200.0
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)
#print("ready! MOD")
func enter() -> void:
.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
# 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():
idle_state.modifier = landing_modifier
return idle_state
return null

View File

@ -68,12 +68,17 @@ __meta__ = {
position = Vector2( 0, -3.5 ) position = Vector2( 0, -3.5 )
shape = SubResource( 9 ) shape = SubResource( 9 )
[node name="movement_state_machine" parent="." index="3"]
debug_state_machine = true
[node name="idle" parent="movement_state_machine" index="0"] [node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 3 ) script = ExtResource( 3 )
debug_state = true
timeout_seconds = 2.0 timeout_seconds = 2.0
move_speed = 0.0 move_speed = 0.0
[node name="move" parent="movement_state_machine" index="2"] [node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 2 ) script = ExtResource( 2 )
debug_state = true
timeout_seconds = 1.0 timeout_seconds = 1.0
move_speed = 30.0 move_speed = 30.0

View File

@ -36,7 +36,7 @@ extents = Vector2( 8, 53 )
script = ExtResource( 10 ) script = ExtResource( 10 )
[node name="PlayerStart" type="Position2D" parent="."] [node name="PlayerStart" type="Position2D" parent="."]
position = Vector2( 1047, 111 ) position = Vector2( 493, 291 )
[node name="CameraBoundaries" type="Area2D" parent="."] [node name="CameraBoundaries" type="Area2D" parent="."]
collision_layer = 256 collision_layer = 256

View File

@ -133,7 +133,7 @@ actor_type = "Enemy"
position = Vector2( 11, -7 ) position = Vector2( 11, -7 )
frames = SubResource( 20 ) frames = SubResource( 20 )
animation = "idle" animation = "idle"
frame = 2 frame = 1
__meta__ = { __meta__ = {
"_aseprite_wizard_config_": { "_aseprite_wizard_config_": {
"layer": "", "layer": "",