Compare commits
2 Commits
48f3e631e6
...
9ef4d1748b
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ef4d1748b | |||
| 2ff08298b7 |
|
|
@ -8,7 +8,7 @@ func _ready():
|
||||||
landing_modifier= StateModifier.new()
|
landing_modifier= StateModifier.new()
|
||||||
#add_child(modifier)
|
#add_child(modifier)
|
||||||
#modifier.init_ref()
|
#modifier.init_ref()
|
||||||
landing_modifier.ready( "landing", "jump" , landing_modifier.TYPE.EXIT_ANIMATION)
|
landing_modifier.ready( "landing", "land" , landing_modifier.TYPE.EXIT_ANIMATION)
|
||||||
#print("ready! MOD")
|
#print("ready! MOD")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,16 @@ extends Interactable
|
||||||
|
|
||||||
onready var sprite: Sprite = $Sprite
|
onready var sprite: Sprite = $Sprite
|
||||||
|
|
||||||
|
const pickup = preload("res://src/Interactables/HealthPickup.tscn")
|
||||||
|
var opened := false
|
||||||
|
|
||||||
func trigger_interaction():
|
func trigger_interaction():
|
||||||
# This is something that should maybe be extended for every differant interactible.
|
# This is something that should maybe be extended for every differant interactible.
|
||||||
# They could inherit from this base class and implement this function.
|
# They could inherit from this base class and implement this function.
|
||||||
sprite.frame = 1
|
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
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,22 @@ extends Interactable
|
||||||
|
|
||||||
onready var health_icon: AnimatedSprite = $AnimatedSprite
|
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():
|
func trigger_interaction():
|
||||||
# This is something that should maybe be extended for every differant interactible.
|
# This is something that should maybe be extended for every differant interactible.
|
||||||
# They could inherit from this base class and implement this function.
|
# They could inherit from this base class and implement this function.
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,18 @@
|
||||||
radius = 6.0
|
radius = 6.0
|
||||||
|
|
||||||
[node name="HealthPickup" instance=ExtResource( 2 )]
|
[node name="HealthPickup" instance=ExtResource( 2 )]
|
||||||
|
monitoring = false
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
|
||||||
frames = ExtResource( 3 )
|
frames = ExtResource( 3 )
|
||||||
|
frame = 2
|
||||||
playing = true
|
playing = true
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="RayCast2D" type="RayCast2D" parent="." index="2"]
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 8 )
|
||||||
|
collision_mask = 3
|
||||||
|
|
|
||||||
|
|
@ -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( 92, 87 )
|
||||||
|
|
||||||
[node name="CameraBoundaries" type="Area2D" parent="."]
|
[node name="CameraBoundaries" type="Area2D" parent="."]
|
||||||
collision_layer = 256
|
collision_layer = 256
|
||||||
|
|
@ -122,6 +122,9 @@ position = Vector2( 494, 39 )
|
||||||
[node name="HealthPickup" parent="." instance=ExtResource( 5 )]
|
[node name="HealthPickup" parent="." instance=ExtResource( 5 )]
|
||||||
position = Vector2( 226, 153 )
|
position = Vector2( 226, 153 )
|
||||||
|
|
||||||
|
[node name="HealthPickup" parent="HealthPickup" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 754, -123 )
|
||||||
|
|
||||||
[node name="Chest2" parent="." instance=ExtResource( 4 )]
|
[node name="Chest2" parent="." instance=ExtResource( 4 )]
|
||||||
position = Vector2( 319, 112 )
|
position = Vector2( 319, 112 )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,7 +633,8 @@ idle_node = NodePath("../idle")
|
||||||
script = ExtResource( 11 )
|
script = ExtResource( 11 )
|
||||||
move_speed = 90.0
|
move_speed = 90.0
|
||||||
move_speed_modifier = 90.0
|
move_speed_modifier = 90.0
|
||||||
move_modifier_move_acceleration = -180.0
|
move_modifier_move_acceleration = -100.0
|
||||||
|
jerk_factor = -20.0
|
||||||
animation_sequence = [ "dash" ]
|
animation_sequence = [ "dash" ]
|
||||||
fall_node = NodePath("../fall")
|
fall_node = NodePath("../fall")
|
||||||
idle_node = NodePath("../idle")
|
idle_node = NodePath("../idle")
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func process_frame(delta: float) -> State:
|
||||||
func process_physics(delta: float) -> State:
|
func process_physics(delta: float) -> State:
|
||||||
move_component.velocity.y += gravity * delta
|
move_component.velocity.y += gravity * delta
|
||||||
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||||
move_component.velocity = parent.transform.x * move_speed
|
move_component.velocity.x = parent.transform.x.x * move_speed
|
||||||
# if (parent.direction.x > 0):
|
# if (parent.direction.x > 0):
|
||||||
# parent.velocity.x = 1 * move_speed
|
# parent.velocity.x = 1 * move_speed
|
||||||
# else:
|
# else:
|
||||||
|
|
|
||||||
|
|
@ -353,12 +353,6 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
|
||||||
print("Acceleration changed.", abs(move_component.acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
|
print("Acceleration changed.", abs(move_component.acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
|
||||||
move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
|
move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
|
||||||
|
|
||||||
# ##TODO: I don't know where I should actually set the momentum. :
|
|
||||||
# if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
|
||||||
# move_component.momentum.x = 0
|
|
||||||
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
|
||||||
# move_component.momentum.x = abs(move_speed_modifier)
|
|
||||||
|
|
||||||
# If we're no longer tryingg to move int the direction of our movement and momentum.
|
# If we're no longer tryingg to move int the direction of our movement and momentum.
|
||||||
if sign(current_x_velocity) != sign(move_component.desired_movement_vector.x) and move_component.momentum.x != 0:
|
if sign(current_x_velocity) != sign(move_component.desired_movement_vector.x) and move_component.momentum.x != 0:
|
||||||
if sign(_move_speed_modifier) == -1 : # decreased speed modifier
|
if sign(_move_speed_modifier) == -1 : # decreased speed modifier
|
||||||
|
|
@ -375,13 +369,15 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
|
||||||
sign(current_x_velocity) == 1) or (sign(move_component.desired_movement_vector.x) == -1 and
|
sign(current_x_velocity) == 1) or (sign(move_component.desired_movement_vector.x) == -1 and
|
||||||
sign(current_x_velocity) == -1):
|
sign(current_x_velocity) == -1):
|
||||||
print("be more opposite")
|
print("be more opposite")
|
||||||
if sign(_move_speed_modifier) == 1:
|
# if sign(_move_speed_modifier) == 1: # increased speed modifier
|
||||||
print("faster faster.")
|
# print("faster faster.")
|
||||||
elif sign(move_component.desired_movement_vector.x) == sign(current_x_velocity) and move_component.momentum.x != 0:
|
elif sign(move_component.desired_movement_vector.x) == sign(current_x_velocity) and move_component.momentum.x != 0:
|
||||||
if sign(move_component.acceleration.x) != sign(move_component.momentum.x) and x_move_direction_override == 0:
|
if sign(move_component.acceleration.x) != sign(move_component.momentum.x) and x_move_direction_override == 0:
|
||||||
print("Step it up!")
|
print("Step it up!")
|
||||||
# Flip the direction of the acceleration
|
# Flip the direction of the acceleration
|
||||||
move_component.acceleration.x *= -1
|
move_component.acceleration.x *= -1
|
||||||
|
|
||||||
|
# Apply momentum and acceleration if a modifer exists
|
||||||
if move_component.momentum.x <= 0 and _move_speed_modifier !=0:
|
if move_component.momentum.x <= 0 and _move_speed_modifier !=0:
|
||||||
#if we're trying to move but we have no momentum applied currently
|
#if we're trying to move but we have no momentum applied currently
|
||||||
#if move_component.desired_movement_vector.x != 0:
|
#if move_component.desired_movement_vector.x != 0:
|
||||||
|
|
@ -391,43 +387,22 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
|
||||||
if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
||||||
move_component.momentum.x = 0
|
move_component.momentum.x = 0
|
||||||
elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
||||||
|
##TODO: in most cases this should only be applied once. need to find a way to warn against this.
|
||||||
move_component.momentum.x = abs(move_speed_modifier)
|
move_component.momentum.x = abs(move_speed_modifier)
|
||||||
|
print("momentum applied!")
|
||||||
|
|
||||||
|
# Reverse the accelerations if we carry over momentum but the modifier no longer applies.
|
||||||
if move_component.momentum.x > 0 and _move_speed_modifier == 0:
|
if move_component.momentum.x > 0 and _move_speed_modifier == 0:
|
||||||
if sign(move_component.acceleration.x) == sign(move_component.momentum.x):
|
if sign(move_component.acceleration.x) == sign(move_component.momentum.x):
|
||||||
print("Whoh Woah your done.")
|
print("Whoh Woah your done.")
|
||||||
# Flip the direction of the acceleration
|
# Flip the direction of the acceleration
|
||||||
move_component.acceleration.x *= -1
|
move_component.acceleration.x *= -1
|
||||||
##TODO: I don't know where I should actually set the momentum. :
|
|
||||||
# This was not the place
|
|
||||||
# if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
|
||||||
# move_component.momentum.x = 0
|
|
||||||
# move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
|
|
||||||
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
|
||||||
# move_component.momentum.x = abs(move_speed_modifier)
|
|
||||||
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
|
||||||
# print("wait does it matter")
|
|
||||||
# else: # physics won't apply here
|
|
||||||
# print("uh")
|
|
||||||
|
|
||||||
# else:
|
|
||||||
# print("Direction changed")
|
|
||||||
# if move_component.momentum.x > abs(current_x_velocity):
|
|
||||||
# move_component.momentum.x = abs(current_x_velocity)
|
|
||||||
|
|
||||||
# flip the acceleration to apply against the momentum
|
|
||||||
#move_component.acceleration.x *= -1 * sign(move_component.momentum.x)
|
|
||||||
# If the movement direction changes and we have momentum
|
|
||||||
# print("Flip that thing!")
|
|
||||||
# move_component.momentum.x *= -1
|
|
||||||
# if sign(move_component.acceleration.x ) == sign(_move_speed_modifier):
|
|
||||||
# move_component.acceleration.x *= -1 * sign(current_x_velocity)
|
|
||||||
|
|
||||||
|
|
||||||
# We're going to adjust our move speed only to the modifier
|
# We're going to adjust our move speed only to the modifier
|
||||||
move_component.momentum.x += move_component.acceleration.x * delta
|
move_component.momentum.x += move_component.acceleration.x * delta
|
||||||
jerk += _jerk_factor * delta
|
jerk += _jerk_factor * delta
|
||||||
|
|
||||||
# Momentum should always be the inverse of the speed modifier
|
|
||||||
|
|
||||||
var new_move_speed :float = 0
|
var new_move_speed :float = 0
|
||||||
if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
if sign(_move_speed_modifier) == -1: # decreased speed modifier
|
||||||
|
|
@ -453,7 +428,7 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
|
||||||
var sim_move_speed = (MIN_SPEED + (sign(_move_speed_modifier) * -1 * move_component.momentum.x))
|
var sim_move_speed = (MIN_SPEED + (sign(_move_speed_modifier) * -1 * move_component.momentum.x))
|
||||||
|
|
||||||
# if move_component.momentum.x != 0:
|
# if move_component.momentum.x != 0:
|
||||||
if false:
|
if true:
|
||||||
UiManager.debug_text = ( "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)) +
|
UiManager.debug_text = ( "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)) +
|
||||||
")\nNS:" + str(round(sim_move_speed)) + #" Z:" + str(sign(_move_speed_modifier) * -1 * move_component.momentum.x) +
|
")\nNS:" + str(round(sim_move_speed)) + #" Z:" + str(sign(_move_speed_modifier) * -1 * move_component.momentum.x) +
|
||||||
"\nS:" + str(round(_move_speed + _move_speed_modifier)) + ",M" + str(round(move_component.momentum.x)) +
|
"\nS:" + str(round(_move_speed + _move_speed_modifier)) + ",M" + str(round(move_component.momentum.x)) +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user