Beakable (optional loot) vases

+ Tweakes spike hitboxes
This commit is contained in:
Sagi Dayan 2020-11-10 22:58:40 -05:00
parent 5eb6b0194e
commit 9a12f677ea
14 changed files with 202 additions and 18 deletions

Binary file not shown.

View file

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/vase_break.wav-6e8ada9144910081f448ca2eac54d76e.sample"
[deps]
source_file="res://assets/Audio/SFX/vase_break.wav"
dest_files=[ "res://.import/vase_break.wav-6e8ada9144910081f448ca2eac54d76e.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/breakable_vase.png-015476e56cb858a4448823a1ebcd90fe.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Items/breakable_vase.png"
dest_files=[ "res://.import/breakable_vase.png-015476e56cb858a4448823a1ebcd90fe.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
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View file

@ -9,18 +9,18 @@
polygon = PoolVector2Array( 0, 13.9545, 0, 13.7219, 3.48895, 8.37286, 6.97746, 14.1871, 11.6288, 8.1403, 15.3499, 13.7219, 16, 14.1871, 16, 16, 0, 16 ) polygon = PoolVector2Array( 0, 13.9545, 0, 13.7219, 3.48895, 8.37286, 6.97746, 14.1871, 11.6288, 8.1403, 15.3499, 13.7219, 16, 14.1871, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=2] [sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 16, 16, 0, 16, 0, 7.90773, 16, 7.90773 ) points = PoolVector2Array( 16, 16, 0, 16, 2.1503, 7.92169, 13.4183, 7.92712 )
[sub_resource type="ConvexPolygonShape2D" id=3] [sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 16, 7.28073, 0, 7.28073, 0, 0, 16, 0 ) points = PoolVector2Array( 13.7554, 7.7776, 3.16282, 7.69971, 0, 0, 16, 0 )
[sub_resource type="ConvexPolygonShape2D" id=4] [sub_resource type="ConvexPolygonShape2D" id=4]
points = PoolVector2Array( 7.49643, 16, 0, 16, 0, 0, 7.49643, 0 ) points = PoolVector2Array( 7.75813, 12.6593, 0, 16, 0, 0, 7.83601, 2.26145 )
[sub_resource type="ConvexPolygonShape2D" id=6] [sub_resource type="ConvexPolygonShape2D" id=5]
points = PoolVector2Array( 8.39368, 0, 16, 0, 16, 16, 8.39368, 16 ) points = PoolVector2Array( 8.22545, 2.91456, 16, 0, 16, 16, 8.31891, 13.9433 )
[sub_resource type="TileSet" id=5] [sub_resource type="TileSet" id=6]
0/name = "spikes.png 0" 0/name = "spikes.png 0"
0/texture = ExtResource( 1 ) 0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 ) 0/tex_offset = Vector2( 0, 0 )
@ -95,20 +95,20 @@ points = PoolVector2Array( 8.39368, 0, 16, 0, 16, 16, 8.39368, 16 )
3/navigation_offset = Vector2( 0, 0 ) 3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 ) 3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape = SubResource( 6 ) 3/shape = SubResource( 5 )
3/shape_one_way = false 3/shape_one_way = false
3/shape_one_way_margin = 1.0 3/shape_one_way_margin = 1.0
3/shapes = [ { 3/shapes = [ {
"autotile_coord": Vector2( 0, 0 ), "autotile_coord": Vector2( 0, 0 ),
"one_way": false, "one_way": false,
"one_way_margin": 1.0, "one_way_margin": 1.0,
"shape": SubResource( 6 ), "shape": SubResource( 5 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ] } ]
3/z_index = 0 3/z_index = 0
[node name="TrapTiles" type="TileMap"] [node name="TrapTiles" type="TileMap"]
tile_set = SubResource( 5 ) tile_set = SubResource( 6 )
cell_size = Vector2( 16, 16 ) cell_size = Vector2( 16, 16 )
collision_layer = 4 collision_layer = 4
occluder_light_mask = 0 occluder_light_mask = 0

View file

@ -225,7 +225,10 @@ attack={
2d_physics/layer_3="Hazerds" 2d_physics/layer_3="Hazerds"
2d_render/layer_4="World" 2d_render/layer_4="World"
2d_physics/layer_4="World" 2d_physics/layer_4="World"
2d_render/layer_5="Collectable"
2d_physics/layer_5="Collectable" 2d_physics/layer_5="Collectable"
2d_render/layer_6="Breakable"
2d_physics/layer_6="Breakable"
[rendering] [rendering]

View file

@ -322,8 +322,15 @@ func _on_DashTimeout_timeout(timed_out=true) -> void:
func _on_SordRange_body_entered(body: Node) -> void: func _on_SordRange_body_entered(body: Node) -> void:
if body.is_in_group("Enemies"): if body.is_in_group("Enemies"):
body.take_damage($Sprite.scale.x) body.take_damage($Sprite.scale.x)
if body.get_parent().is_in_group("Breakable"):
body.get_parent().take_damage()
pass # Replace with function body. pass # Replace with function body.
func _on_SordRange_area_entered(body: Node) -> void:
if body.get_parent().is_in_group("Breakable"):
body.get_parent().take_damage()
pass
func get_camera(): func get_camera():
return $Camera return $Camera
func face_player(right:bool = true): func face_player(right:bool = true):

View file

@ -697,7 +697,7 @@ frame = 32
[node name="SordRange" type="Area2D" parent="Sprite"] [node name="SordRange" type="Area2D" parent="Sprite"]
position = Vector2( -8, 8 ) position = Vector2( -8, 8 )
collision_mask = 2 collision_mask = 34
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/SordRange"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/SordRange"]
position = Vector2( 14, -6 ) position = Vector2( 14, -6 )
@ -744,5 +744,6 @@ collision_mask = 8
[node name="Camera" parent="." instance=ExtResource( 4 )] [node name="Camera" parent="." instance=ExtResource( 4 )]
smoothing_enabled = false smoothing_enabled = false
[connection signal="area_entered" from="Sprite/SordRange" to="." method="_on_SordRange_area_entered"]
[connection signal="body_entered" from="Sprite/SordRange" to="." method="_on_SordRange_body_entered"] [connection signal="body_entered" from="Sprite/SordRange" to="." method="_on_SordRange_body_entered"]
[connection signal="timeout" from="DashTimeout" to="." method="_on_DashTimeout_timeout"] [connection signal="timeout" from="DashTimeout" to="." method="_on_DashTimeout_timeout"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=27 format=2] [gd_scene load_steps=28 format=2]
[ext_resource path="res://src/GameWorld/Levels/PreGame.gd" type="Script" id=1] [ext_resource path="res://src/GameWorld/Levels/PreGame.gd" type="Script" id=1]
[ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=2] [ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=2]
@ -18,6 +18,7 @@
[ext_resource path="res://src/Hazards/SpikeTrap.tscn" type="PackedScene" id=16] [ext_resource path="res://src/Hazards/SpikeTrap.tscn" type="PackedScene" id=16]
[ext_resource path="res://src/Items/Spring.tscn" type="PackedScene" id=17] [ext_resource path="res://src/Items/Spring.tscn" type="PackedScene" id=17]
[ext_resource path="res://src/Hazards/Stomp.tscn" type="PackedScene" id=18] [ext_resource path="res://src/Hazards/Stomp.tscn" type="PackedScene" id=18]
[ext_resource path="res://src/Items/BrakableVase.tscn" type="PackedScene" id=19]
[sub_resource type="TileSet" id=1] [sub_resource type="TileSet" id=1]
0/name = "tileset.png 0" 0/name = "tileset.png 0"
@ -260,8 +261,11 @@ node = ExtResource( 6 )
[node name="Coin" parent="Coins" instance=ExtResource( 9 )] [node name="Coin" parent="Coins" instance=ExtResource( 9 )]
position = Vector2( 15, -12 ) position = Vector2( 15, -12 )
[node name="Coin4" parent="Coins" instance=ExtResource( 9 )]
position = Vector2( 281, -12 )
[node name="Coin3" parent="Coins" instance=ExtResource( 9 )] [node name="Coin3" parent="Coins" instance=ExtResource( 9 )]
position = Vector2( 9, 109 ) position = Vector2( 122, 107 )
[node name="Coin2" parent="Coins" instance=ExtResource( 9 )] [node name="Coin2" parent="Coins" instance=ExtResource( 9 )]
position = Vector2( 535, 42 ) position = Vector2( 535, 42 )
@ -284,4 +288,15 @@ position = Vector2( 217, 167 )
to_point = Vector2( 0, 65 ) to_point = Vector2( 0, 65 )
duration = 0.5 duration = 0.5
delay = 0.2 delay = 0.2
g = "UP_DOWN"
[node name="BrakableVase" parent="." instance=ExtResource( 19 )]
position = Vector2( 295, 240 )
loot = ExtResource( 9 )
[node name="BrakableVase2" parent="." instance=ExtResource( 19 )]
position = Vector2( 61, 64 )
[node name="BrakableVase3" parent="." instance=ExtResource( 19 )]
position = Vector2( 87, 64 )
[connection signal="body_entered" from="CutsceneAreas/OldDudeIntroArea" to="." method="_on_OldDudeIntroArea_body_entered"] [connection signal="body_entered" from="CutsceneAreas/OldDudeIntroArea" to="." method="_on_OldDudeIntroArea_body_entered"]

16
src/Items/BrakableVase.gd Normal file
View file

@ -0,0 +1,16 @@
extends Node2D
export var loot:PackedScene = null
var _breakable = true
func take_damage():
if not _breakable: return
_breakable = false
AudioManager.play_sfx(AudioManager.Sfx.VASE_BREAK)
$AnimationPlayer.play("break")
yield(get_tree().create_timer(.2), "timeout")
if loot != null:
var scene = loot.instance()
scene.position = position + Vector2(0, -8)
get_parent().add_child(scene)

View file

@ -0,0 +1,87 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/Items/breakable_vase.png" type="Texture" id=1]
[ext_resource path="res://src/Items/BrakableVase.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5, 5 )
[sub_resource type="Animation" id=3]
resource_name = "break"
length = 0.3
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.3 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 1, 2, 3, 4 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Area2D/CollisionShape2D:disabled")
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": [ true ]
}
[sub_resource type="Animation" id=2]
resource_name = "idle"
length = 0.1
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 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ 0 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Area2D/CollisionShape2D:disabled")
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": [ false ]
}
[node name="BrakableVase" type="Node2D" groups=[
"Breakable",
]]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
light_mask = 0
position = Vector2( 0, -8 )
texture = ExtResource( 1 )
hframes = 6
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 32
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 0, -5 )
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "idle"
playback_speed = 0.8
anims/break = SubResource( 3 )
anims/idle = SubResource( 2 )

View file

@ -7,14 +7,10 @@ export var to_level_coord:Vector2 = Vector2(-1, -1)
export var is_exit:bool = true export var is_exit:bool = true
const spawn_offset = 30 const spawn_offset = 30
var initialized = false
const NON_SPECIFIED_LEVEL :=Vector2(-1, -1) const NON_SPECIFIED_LEVEL :=Vector2(-1, -1)
func _ready() -> void:
if not initialized: add_to_group("WarpZones")
initialized = true;
func _on_body_entered(body:Node): func _on_body_entered(body:Node):

View file

@ -5,7 +5,9 @@
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 ) extents = Vector2( 16, 16 )
[node name="WarpZone" type="Area2D"] [node name="WarpZone" type="Area2D" groups=[
"WarpZones",
]]
collision_layer = 0 collision_layer = 0
script = ExtResource( 1 ) script = ExtResource( 1 )

View file

@ -31,7 +31,8 @@ enum Sfx{
UI_MOVE, UI_MOVE,
UI_SELECT, UI_SELECT,
SPRING, SPRING,
SPIKE_TRAP SPIKE_TRAP,
VASE_BREAK
} }
var _sfx_files := { var _sfx_files := {
@ -43,6 +44,7 @@ var _sfx_files := {
Sfx.PLAYER_DIE : load("res://assets/Audio/SFX/player_die.wav"), Sfx.PLAYER_DIE : load("res://assets/Audio/SFX/player_die.wav"),
Sfx.SPRING : load("res://assets/Audio/SFX/spring.wav"), Sfx.SPRING : load("res://assets/Audio/SFX/spring.wav"),
Sfx.SPIKE_TRAP : load("res://assets/Audio/SFX/spike_trap.wav"), Sfx.SPIKE_TRAP : load("res://assets/Audio/SFX/spike_trap.wav"),
Sfx.VASE_BREAK : load("res://assets/Audio/SFX/vase_break.wav"),
Sfx.UI_MOVE : load("res://assets/Audio/UI_Sounds/menu_move_sound.wav"), Sfx.UI_MOVE : load("res://assets/Audio/UI_Sounds/menu_move_sound.wav"),
Sfx.UI_SELECT : '', Sfx.UI_SELECT : '',
} }