From ef3e8e7938e3a61a52bcb9d46d27c19afbf8cebf Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Mon, 2 Oct 2023 01:04:18 +0400 Subject: [PATCH] shadows --- src/models/enemies/bat/Bat.tscn | 9 ++++++- src/models/enemies/bat/bat.gd | 2 +- src/models/enemies/ghost/Ghost.tscn | 1 - src/models/enemies/rat/Rat.tscn | 11 +++++++-- src/models/player/Player.tscn | 14 +++++++---- src/models/shadow/shadow.png | Bin 0 -> 1756 bytes src/models/shadow/shadow.png.import | 35 ++++++++++++++++++++++++++++ 7 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/models/shadow/shadow.png create mode 100644 src/models/shadow/shadow.png.import diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index 940b0be..d742495 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://src/models/enemies/bat/sprites/bat_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2] +[ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 4, 3 ) @@ -19,6 +20,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" +frame = 3 playing = true centered = false @@ -31,3 +33,8 @@ shape = SubResource( 1 ) [node name="SameSpeciesCollider" type="CollisionShape2D" parent="."] position = Vector2( 8.5, 10 ) shape = SubResource( 2 ) + +[node name="Shadow" type="Sprite" parent="."] +position = Vector2( 11, 21 ) +z_index = -1 +texture = ExtResource( 3 ) diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd index 8df845c..309c9de 100644 --- a/src/models/enemies/bat/bat.gd +++ b/src/models/enemies/bat/bat.gd @@ -45,7 +45,7 @@ func _physics_process(delta): velocity.x = cos(angle + 180) velocity.y = sin(angle + 180) - self.global_position.y += sin(Time.get_ticks_msec() * 0.01) / 3 + $Sprite.global_position.y += sin(Time.get_ticks_msec() * 0.01) / 3 velocity *= speed * speed_multiplier if not shooting: diff --git a/src/models/enemies/ghost/Ghost.tscn b/src/models/enemies/ghost/Ghost.tscn index 3dd4272..a763fe5 100644 --- a/src/models/enemies/ghost/Ghost.tscn +++ b/src/models/enemies/ghost/Ghost.tscn @@ -25,7 +25,6 @@ flip_h = true use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 2 playing = true centered = false diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn index 384a845..acae655 100644 --- a/src/models/enemies/rat/Rat.tscn +++ b/src/models/enemies/rat/Rat.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://src/models/enemies/rat/sprites/rat_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/enemies/rat/rat.gd" type="Script" id=2] +[ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 8, 3.5 ) @@ -11,9 +12,10 @@ script = ExtResource( 2 ) [node name="Sprite" type="AnimatedSprite" parent="."] use_parent_material = true +position = Vector2( -3, 0 ) frames = ExtResource( 1 ) animation = "idle" -frame = 2 +frame = 3 playing = true centered = false @@ -22,3 +24,8 @@ centered = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] position = Vector2( 11, 5.5 ) shape = SubResource( 1 ) + +[node name="Shadow" type="Sprite" parent="."] +position = Vector2( 11, 9 ) +z_index = -1 +texture = ExtResource( 3 ) diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index e6e7505..044a616 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -1,14 +1,15 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://src/models/player/sprites/player_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/player/player.gd" type="Script" id=2] [ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3] +[ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=4] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 4, 4 ) +extents = Vector2( 3.5, 3.5 ) [sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 7, 11 ) +extents = Vector2( 3.5, 9 ) [sub_resource type="Animation" id=4] resource_name = "RESET" @@ -48,7 +49,7 @@ tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 0.9 ), +"times": PoolRealArray( 0, 2 ), "transitions": PoolRealArray( 1, 1 ), "update": 1, "values": [ true, false ] @@ -111,4 +112,9 @@ gravity = Vector2( 0, -10 ) initial_velocity = 8.0 color = Color( 0.458824, 0.458824, 0.458824, 0.588235 ) +[node name="Shadow" type="Sprite" parent="."] +position = Vector2( 11, 24 ) +z_index = -1 +texture = ExtResource( 4 ) + [connection signal="area_entered" from="EnemyCollision" to="." method="area_entered"] diff --git a/src/models/shadow/shadow.png b/src/models/shadow/shadow.png new file mode 100644 index 0000000000000000000000000000000000000000..2f73eba8840513a18eaf1fc104d65877460a9c6a GIT binary patch literal 1756 zcmcIl&u`pB6yES7ltNFHD#XdS7pgM$c>HU}id)ibAS>Yzr7N1=7|)D%P1YV`JK0T+ z+~A6k0)i6~+_-Y!0OAke#^1n^3*3;(^RB&ZQJdz%N?wo0-+b?T?|Yv4bZ__FE0VxRLfUC@4 zLdDXUX9b{py^Y)Rg7HIHYq1=sd8q&S)6cq=icr7jMmQ?A+Bvn?MbwCGxZ0cd(p;!nb)!+#E|3FO%TNc` zz%PujH6kP+Zs1rqu^nK%ghtQ^g4OI|U?tMzB~q7ZC^8 z7zd#}qRNax|D+ikOS8zwO*aEOWU-T0VBJakecY8Fx1(vQEt)Q1 zyy^8&=Z(oy=MkV7GvilU8 zi8>7RlQ=;l5!7-q_pxs;<4)5~!IH>4KjK2`Bim!Q81~#|xZ3UEVRc@}98xXeG`LBR z5u7A9hJ($~r7yqu?TzPp_|;#35f2{N?%&^@on1Y9!Tsm^x1V2|qYeJ!?|-cAezX44 U#z&w1)to=W?cKo-cRu{&Us#