Made some changes :)

This commit is contained in:
pennyrigate 2022-12-08 23:28:49 -05:00
parent 038935709f
commit 8f6a068eba
76 changed files with 889 additions and 36 deletions

View file

@ -49,6 +49,11 @@ func _physics_process(delta):
if current_state != State.CLIMB: velocity.y += gravity
#Apply velocity
move_and_slide(velocity,Vector2.UP)
#Debug
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())
func _process_idle():
if anims.get_current_animation() != "idle": anims.play("idle")
@ -78,6 +83,7 @@ func _process_idle_walk():
check_jump()
#Goto Sword
if Input.is_action_just_pressed("sword"):
Game.play_sound(Game.a_sword,Game.ac_jump)
current_state = State.SWORD
return
@ -104,11 +110,18 @@ func _process_climb():
anims.set_speed_scale(abs(axis.y))
#Climb
position.y += axis.y * 0.65
#Sound
if axis.y == -1:
if Game.ac_climb.get_stream() != Game.a_climb_up: Game.play_sound(Game.a_climb_up,Game.ac_climb)
if axis.y == 1:
if Game.ac_climb.get_stream() != Game.a_climb_down: Game.play_sound(Game.a_climb_down,Game.ac_climb)
if axis.y == 0: Game.ac_climb.set_stream(null)
#Manual Jump,, only works when holding neutral or away from ladder
if axis.x != sprite.scale.x: check_jump()
#Auto Jump
if climb_ray.get_collider() == null:
velocity.y = -jump_force
Game.ac_climb.set_stream(null)
Game.play_sound(Game.a_jump,Game.ac_jump)
current_state = State.FALL
return
@ -119,7 +132,7 @@ func _process_sword():
velocity.x = 0
sword_sprite.scale.x = sprite.scale.x
#Move hitbox with flip
sword_hitbox.position.x = 10 * sprite.scale.x
sword_hitbox.position.x = sprite.scale.x * 10
#Return to idle after animationplayer end anim signal
@ -127,7 +140,9 @@ func _process_sword():
func check_jump():
if Input.is_action_just_pressed("jump") && !Input.is_action_pressed("ui_down"):
#Detach ladder
if current_state == State.CLIMB: position.x -= sprite.scale.x * 5
if current_state == State.CLIMB:
Game.ac_climb.set_stream(null)
position.x -= sprite.scale.x * 5
anims.set_speed_scale(1)
# Jump
jump_pressure = 0

View file

@ -458,15 +458,17 @@ region_rect = Rect2( 0, 0, 20, 20 )
[node name="SwordSprite" type="Sprite" parent="."]
material = SubResource( 28 )
region_enabled = true
region_rect = Rect2( 32, 0, 32, 32 )
region_rect = Rect2( 0, 0, 32, 32 )
[node name="Area2D" type="Area2D" parent="." groups=["player"]]
visible = false
position = Vector2( 0, 3 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 6 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["sword"]]
visible = false
position = Vector2( 0, 3 )
shape = SubResource( 6 )
@ -487,9 +489,10 @@ anims/stab = SubResource( 32 )
anims/walk = SubResource( 33 )
[node name="SwordArea" type="Area2D" parent="." groups=["sword"]]
visible = false
[node name="SwordHitBox" type="CollisionShape2D" parent="SwordArea"]
position = Vector2( 10, 3 )
position = Vector2( 0, 3 )
shape = SubResource( 34 )
disabled = true