tube transport! also 3-block jump marginally easier

This commit is contained in:
Haze Weathers 2023-01-22 22:24:50 -05:00
parent 4d13d2932c
commit 8c60bbf293
6 changed files with 101 additions and 123 deletions

View file

@ -0,0 +1,10 @@
extends Area2D
export var speed = 120.0
export var direction = Vector2.RIGHT
func _on_TubeEntrance_area_entered(area):
if area.is_in_group("player"):
var player = area.get_parent()
player.global_position = global_position + Vector2(4.0, 4.0)
player.enter_transport(speed, direction)

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://objects/environment/tube/tube_entrance.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 4 )
[node name="TubeEntrance" type="Area2D"]
monitorable = false
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape2D" parent="."]
position = Vector2( 4, 4 )
shape = SubResource( 1 )
[connection signal="area_entered" from="." to="." method="_on_TubeEntrance_area_entered"]

View file

@ -0,0 +1,5 @@
extends Area2D
func _on_TubeExit_area_entered(area):
if area.is_in_group("player"):
area.get_parent().exit_transport()

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://objects/environment/tube/tube_exit.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 4 )
[node name="TubeExit" type="Area2D"]
monitorable = false
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape2D" parent="."]
position = Vector2( 4, 4 )
shape = SubResource( 1 )
[connection signal="area_entered" from="." to="." method="_on_TubeExit_area_entered"]

View file

@ -14,7 +14,7 @@ onready var dust_particles = $DustParticles
#Map
onready var map = get_owner()
##States
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE}
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT}
var current_state = State.IDLE
##Runtime
var axis = Vector2.ZERO #Current direction being held
@ -25,10 +25,12 @@ var walk_speed = 50
var gravity = 12
var jump_pressure = 0
var jump_force = 150
var doublejump_force = 120
var doublejump_force = 122
var current_ladder = null #Used for checking climbing every frame instead of area entered
var can_doublejump = true
var can_move_in_air = false
var transport_speed = 0.0
var transport_direction = Vector2.ZERO
#Positions
var arrowpos = Vector2(5,3)
##Preload
@ -70,6 +72,10 @@ func _physics_process(delta):
continue
State.SHOOT:
_process_shoot()
continue
State.TRANSPORT:
_process_transport(delta)
return
#Gravity
if current_state != State.CLIMB:
@ -188,7 +194,7 @@ func _process_sword():
#Move hitbox with flip
sword_hitbox.position.x = sprite.scale.x * 10
#Return to idle after animationplayer end anim signal
func _process_shoot():
#Stop
velocity.x = 0
@ -199,6 +205,9 @@ func _process_shoot():
return
move(walk_speed,0,true)
func _process_transport(delta):
position += transport_direction * transport_speed * delta
func spawn_arrow():
Game.play_sound(Game.a_shoot,Game.ac_jump)
var arrow = ArrowProjectile.instance()
@ -269,6 +278,15 @@ func check_ladder():
#Move the raycast
#climb_ray.position.x = 4 * sprite.scale.x
func enter_transport(speed, direction):
transport_speed = speed
transport_direction = direction
current_state = State.TRANSPORT
anims.play("doublejump")
func exit_transport():
current_state = State.FALL
func die():
if current_state == State.INACTIVE:
return