added hatches!
This commit is contained in:
parent
9947cdfc45
commit
3433dae09c
10 changed files with 267 additions and 18 deletions
BIN
graphics/hatch/hatch.png
Normal file
BIN
graphics/hatch/hatch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 266 B |
35
graphics/hatch/hatch.png.import
Normal file
35
graphics/hatch/hatch.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/hatch.png-e12a4a7b9a8d86a05e31be49a9422eca.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/hatch/hatch.png"
|
||||
dest_files=[ "res://.import/hatch.png-e12a4a7b9a8d86a05e31be49a9422eca.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
|
BIN
graphics/hud/down_prompt.png
Normal file
BIN
graphics/hud/down_prompt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 B |
35
graphics/hud/down_prompt.png.import
Normal file
35
graphics/hud/down_prompt.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/down_prompt.png-89717297e979e201fddd0a1efbfcafb6.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/hud/down_prompt.png"
|
||||
dest_files=[ "res://.import/down_prompt.png-89717297e979e201fddd0a1efbfcafb6.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
|
|
@ -13,6 +13,7 @@
|
|||
[ext_resource path="res://maps/map.gd" type="Script" id=11]
|
||||
[ext_resource path="res://objects/environment/turniwood/turning_platform.tscn" type="PackedScene" id=12]
|
||||
[ext_resource path="res://objects/collectibles/arrow.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://objects/environment/hatch/hatch.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://objects/respawn_point.tscn" type="PackedScene" id=16]
|
||||
[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=17]
|
||||
[ext_resource path="res://objects/enemy/tin.tscn" type="PackedScene" id=20]
|
||||
|
@ -45,9 +46,6 @@ animations = [ {
|
|||
"speed": 20.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=8]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[node name="Map2" type="Node2D" groups=["map"]]
|
||||
script = ExtResource( 11 )
|
||||
|
||||
|
@ -119,9 +117,6 @@ format = 1
|
|||
[node name="Turniwood5" parent="." instance=ExtResource( 12 )]
|
||||
position = Vector2( 80, 120 )
|
||||
|
||||
[node name="Turniwood10" parent="." instance=ExtResource( 12 )]
|
||||
position = Vector2( 224, 104 )
|
||||
|
||||
[node name="Turniwood6" parent="." instance=ExtResource( 12 )]
|
||||
position = Vector2( 72, 112 )
|
||||
delay = 0.5
|
||||
|
@ -196,17 +191,13 @@ playing = true
|
|||
position = Vector2( 27, 128 )
|
||||
|
||||
[node name="Roboturret" parent="." instance=ExtResource( 24 )]
|
||||
position = Vector2( 168, 152 )
|
||||
position = Vector2( 184, 112 )
|
||||
scale = Vector2( -1, 1 )
|
||||
shoot_time = 4.0
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2( 196, 116 )
|
||||
shape = SubResource( 8 )
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2( 210, 116 )
|
||||
shape = SubResource( 8 )
|
||||
[node name="Hatch" parent="." instance=ExtResource( 14 )]
|
||||
position = Vector2( 216, 112 )
|
||||
|
||||
[editable path="RollingFiend"]
|
||||
|
|
30
objects/environment/hatch/hatch.gd
Normal file
30
objects/environment/hatch/hatch.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
extends Node2D
|
||||
|
||||
onready var anims = $SpriteAnim
|
||||
onready var down_prompt = $DownPrompt
|
||||
onready var snap_position = $Position2D
|
||||
var can_interact = false
|
||||
var player = null
|
||||
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("enter_hatch") && can_interact:
|
||||
anims.play("open")
|
||||
player.enter_hatch(position + snap_position.position)
|
||||
down_prompt.scale.y = -1
|
||||
down_prompt.visible = true
|
||||
player.connect("hatch_exited", self, "exit_hatch", [], CONNECT_ONESHOT)
|
||||
|
||||
func exit_hatch():
|
||||
anims.play("open")
|
||||
down_prompt.scale.y = 1
|
||||
|
||||
func _on_TriggerArea_area_entered(area):
|
||||
down_prompt.visible = true
|
||||
down_prompt.scale.y = 1
|
||||
can_interact = true
|
||||
player = area.get_owner()
|
||||
|
||||
func _on_TriggerArea_area_exited(area):
|
||||
if down_prompt.scale.y == 1:
|
||||
down_prompt.visible = false
|
||||
can_interact = false
|
78
objects/environment/hatch/hatch.tscn
Normal file
78
objects/environment/hatch/hatch.tscn
Normal file
|
@ -0,0 +1,78 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/hatch/hatch.png" type="Texture" id=1]
|
||||
[ext_resource path="res://graphics/hud/down_prompt.png" type="Texture" id=2]
|
||||
[ext_resource path="res://objects/environment/hatch/hatch.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "open"
|
||||
length = 0.9
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.2, 0.7, 0.8 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0, 1, 2, 1, 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "idle"
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("DownPrompt:position")
|
||||
tracks/0/interp = 0
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 4, -18 ), Vector2( 4, -16 ), Vector2( 4, -18 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[node name="Hatch" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 6, 3 )
|
||||
texture = ExtResource( 1 )
|
||||
hframes = 3
|
||||
|
||||
[node name="SpriteAnim" type="AnimationPlayer" parent="."]
|
||||
anims/open = SubResource( 1 )
|
||||
|
||||
[node name="DownPrompt" type="Sprite" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 4, -18 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="ArrowAnim" type="AnimationPlayer" parent="."]
|
||||
autoplay = "idle"
|
||||
anims/idle = SubResource( 2 )
|
||||
|
||||
[node name="TriggerArea" type="Area2D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TriggerArea"]
|
||||
position = Vector2( 4, 4 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="."]
|
||||
position = Vector2( 4, -2 )
|
||||
__meta__ = {
|
||||
"_gizmo_extents_": 0.0
|
||||
}
|
||||
|
||||
[connection signal="area_entered" from="TriggerArea" to="." method="_on_TriggerArea_area_entered"]
|
||||
[connection signal="area_exited" from="TriggerArea" to="." method="_on_TriggerArea_area_exited"]
|
|
@ -1,5 +1,7 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
signal hatch_exited
|
||||
|
||||
const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
|
||||
|
||||
##CLEAN UP CODE LATER
|
||||
|
@ -20,10 +22,12 @@ onready var sword_hitbox = $SwordArea
|
|||
onready var death_particles = $DeathSplatter
|
||||
onready var dust_particles = $DustParticles
|
||||
onready var iframe_timer = $IframeTimer
|
||||
onready var hitbox = $Area2D/CollisionShape2D2
|
||||
|
||||
#Map
|
||||
onready var map = get_owner()
|
||||
##States
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT}
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT,HATCH}
|
||||
var current_state = State.IDLE
|
||||
var can_die = true
|
||||
##Runtime
|
||||
|
@ -83,6 +87,9 @@ func _physics_process(delta):
|
|||
State.TRANSPORT:
|
||||
_process_transport(delta)
|
||||
return
|
||||
State.HATCH:
|
||||
_process_hatch(delta)
|
||||
return
|
||||
|
||||
#Gravity
|
||||
if current_state != State.CLIMB:
|
||||
|
@ -217,6 +224,11 @@ func _process_shoot():
|
|||
func _process_transport(delta):
|
||||
position += transport_direction * transport_speed * delta
|
||||
|
||||
func _process_hatch(delta):
|
||||
if Input.is_action_just_pressed("exit_hatch"):
|
||||
anims.play("enter hatch", -1, -1.25,true)
|
||||
emit_signal("hatch_exited")
|
||||
|
||||
func spawn_arrow():
|
||||
Audio.play_sound(Audio.a_shoot,Audio.ac_jump)
|
||||
var arrow = ArrowProjectile.instance()
|
||||
|
@ -299,6 +311,13 @@ func enter_transport(speed, direction):
|
|||
func exit_transport():
|
||||
current_state = State.FALL
|
||||
|
||||
func enter_hatch(snap_position):
|
||||
position = snap_position
|
||||
current_state = State.INACTIVE
|
||||
hitbox.disabled = true
|
||||
collision_layer = 0
|
||||
anims.play("enter hatch", -1, 1.25)
|
||||
|
||||
func die():
|
||||
if can_die:
|
||||
Audio.ac_climb.set_stream(null) # stop climbing sound\
|
||||
|
@ -346,6 +365,16 @@ func die():
|
|||
sprite.visible = true
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
#Set hatch state
|
||||
if anim_name == "enter hatch":
|
||||
match current_state:
|
||||
State.INACTIVE:
|
||||
current_state = State.HATCH
|
||||
return
|
||||
State.HATCH:
|
||||
current_state = State.IDLE
|
||||
hitbox.disabled = false
|
||||
collision_layer = 2
|
||||
if current_state == State.INACTIVE:
|
||||
return
|
||||
#Return to idle after slash
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=34 format=2]
|
||||
[gd_scene load_steps=35 format=2]
|
||||
|
||||
[ext_resource path="res://objects/player/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/player/sg_walk.png" type="Texture" id=2]
|
||||
|
@ -170,6 +170,45 @@ tracks/4/keys = {
|
|||
"values": [ 0.0, 0.0, 90.0, 90.0, 180.0, 180.0, 270.0, 270.0, 360.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=45]
|
||||
resource_name = "enter hatch"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:offset")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.3, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -6 ), Vector2( 0, 0 ), Vector2( 0, 10 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 5 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Sprite:region_rect")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.3, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Rect2( 1, 0, 20, 20 ), Rect2( 1, 0, 20, 20 ), Rect2( 1, 0, 20, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=30]
|
||||
resource_name = "idle"
|
||||
length = 0.5
|
||||
|
@ -621,9 +660,9 @@ max_fall_speed = 255.0
|
|||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 38 )
|
||||
texture = ExtResource( 3 )
|
||||
texture = ExtResource( 5 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 20, 20 )
|
||||
region_rect = Rect2( 1, 0, 20, 20 )
|
||||
script = ExtResource( 17 )
|
||||
|
||||
[node name="SwordSprite" type="Sprite" parent="."]
|
||||
|
@ -664,6 +703,7 @@ collide_with_bodies = false
|
|||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/climb = SubResource( 29 )
|
||||
anims/doublejump = SubResource( 35 )
|
||||
"anims/enter hatch" = SubResource( 45 )
|
||||
anims/idle = SubResource( 30 )
|
||||
anims/jump = SubResource( 31 )
|
||||
"anims/shoot air" = SubResource( 37 )
|
||||
|
|
|
@ -225,6 +225,17 @@ ui_reset={
|
|||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":67,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
enter_hatch={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
exit_hatch={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[input_devices]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue