From f314860b17b823283d36be666911ae8551844cb8 Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Mon, 2 Oct 2023 00:09:01 +0400 Subject: [PATCH] TODO bat sonic wave --- src/models/enemies/bat/Bat.tscn | 6 ++++ src/models/enemies/bat/bat.gd | 14 ++++++++ src/models/player/Player.tscn | 6 ++-- src/models/sonic_wave/Sonic_Wave.gd | 9 +++++ src/models/sonic_wave/Sonic_Wave.tscn | 18 ++++++++++ src/models/sonic_wave/sonic_wave.png | Bin 0 -> 1802 bytes src/models/sonic_wave/sonic_wave.png.import | 35 ++++++++++++++++++++ 7 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/models/sonic_wave/Sonic_Wave.gd create mode 100644 src/models/sonic_wave/Sonic_Wave.tscn create mode 100644 src/models/sonic_wave/sonic_wave.png create mode 100644 src/models/sonic_wave/sonic_wave.png.import diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index 940b0be..31ae654 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -19,6 +19,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" +frame = 2 playing = true centered = false @@ -31,3 +32,8 @@ shape = SubResource( 1 ) [node name="SameSpeciesCollider" type="CollisionShape2D" parent="."] position = Vector2( 8.5, 10 ) shape = SubResource( 2 ) + +[node name="Timer" type="Timer" parent="."] +autostart = true + +[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd index 5b8c5b8..7d250f1 100644 --- a/src/models/enemies/bat/bat.gd +++ b/src/models/enemies/bat/bat.gd @@ -3,6 +3,9 @@ extends EnemyClass var velocity = Vector2.ZERO var speed = 64 +onready var sonic_wave_preload = preload("res://src/models/sonic_wave/Sonic_Wave.tscn") +var sonic_wave + func _ready(): hp = 15 @@ -27,3 +30,14 @@ func _physics_process(_delta): velocity *= speed * speed_multiplier velocity = move_and_slide(velocity) + + +func _shoot(): + sonic_wave = sonic_wave_preload.instance() + get_parent().add_child(sonic_wave) + sonic_wave.global_position.x = self.global_position.x + 8 + sonic_wave.global_position.y = self.global_position.y + 8 + + +func _on_Timer_timeout(): + _shoot() diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index e6e7505..77b9f7f 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -5,10 +5,10 @@ [ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3] [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 +48,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 ] diff --git a/src/models/sonic_wave/Sonic_Wave.gd b/src/models/sonic_wave/Sonic_Wave.gd new file mode 100644 index 0000000..2f77e7a --- /dev/null +++ b/src/models/sonic_wave/Sonic_Wave.gd @@ -0,0 +1,9 @@ +extends KinematicBody2D + +var velocity = Vector2.ZERO +var speed = 120 +onready var player = $"../../Player" + +func _physics_process(delta): + self.global_position = self.global_position.move_toward(player.global_position, delta * speed) + $Sprite.look_at(player.global_position) diff --git a/src/models/sonic_wave/Sonic_Wave.tscn b/src/models/sonic_wave/Sonic_Wave.tscn new file mode 100644 index 0000000..ee3e8e0 --- /dev/null +++ b/src/models/sonic_wave/Sonic_Wave.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/models/sonic_wave/sonic_wave.png" type="Texture" id=1] +[ext_resource path="res://src/models/sonic_wave/Sonic_Wave.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 3, 4.25 ) + +[node name="Sonic_Wave" type="KinematicBody2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource( 1 ) diff --git a/src/models/sonic_wave/sonic_wave.png b/src/models/sonic_wave/sonic_wave.png new file mode 100644 index 0000000000000000000000000000000000000000..f5c39f557b651f411e55aea0d29a0417003f301b GIT binary patch literal 1802 zcmcIl&2QX99CZbW(m*5-MJg2%mW!YT#vXrvP$#6jDOm}pQMyvn1JLozc-P9>PdBqSsR90(FZYWV{Y|3M{?s@^y<-nF*{wILT)^7`w|`@MPZ=b3}` zwRach&&>;hu+Uj;Z}9UBKj!9U`M>(We4C$6XRFr>L3rkc>Nq9bIy@@~v)AM9R=E|t z=V6w}h_H~#qa@>KLAbOu$`IbBr5Ms)ochxJAAXd?nE2AB8NeWG(SE$TpVMpmYhAp* zja?!wEsB>$9w$g>iNsMdNDFV|OJiP-UssP6NgPAUZC_fh3W{67y4Yel6>V7q7(yu8 zuB?WZiEQ^RQG=SMKub||pxT~cd8#4SKZ%#iN#t#`uhhl(oiFvvGV>H=I2_7DU1oVt zQC-(npr&XV;0RFcr6n4Hv^d`|v}u9!I4fh8iWMUY*-q(8T%EbFt96@B&uZPVBP zP)P8!V78MF#`X}b&;d<2cfqmhSYPI~a*9fpcNrTrNv$^(MNOAY@xo@D5;iO@R*LEY zw2eyYOFT867X(o4YMQ6Io^HJfbq~S`G~kUuP>D_kW+aaGP67=Auag!fN-^!UeTj>b zN4#=7|UHp4rW6V>=h-x7v7$J9;F2<=GK zH4~VoiGcwP4LC##fn!+IaU#bwh}y7S&13%QpuwZ8l`6s+EyHmQ8WIp1VFV&#&`OXE zY{RllY=&6XElGS>x5Wl54;bO@>XJyX7qL7+yno^Z^{A4iy{elzJDhI$k zy;)xkVsYGb9>P_x`x34~rbMbA$B%LEWI89b!#?Gt$AmwD6)Y-;D5uLk?(}~)m+~a> z1=>Ac`pJU-AEno};yy}yl&_qMR82;ymY7K>%D?k^n0M1N%eh7X%cwUsWU*-` zBSbDmSOvP{+CXy+1e}Ps6^V$enh@L2)+cobaid^Dq#R#yto4!Qu^G(Q-0E_=+Vh*~ zenC?{)tv7JXKwuz@ttI|(_Ze*eewP$UoRYq&pv(s`Ie~8pSg48&Z{q749?CRfWz6_ z7dC(Y{@V|uUp~0{+V0Zl-+cDek?`He#d9~@7f=0sc-NkJ=icoHum5%M>*Bea@*l4p ey^){3H*@sm%b&vZ&)=%us