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 0000000..f5c39f5 Binary files /dev/null and b/src/models/sonic_wave/sonic_wave.png differ diff --git a/src/models/sonic_wave/sonic_wave.png.import b/src/models/sonic_wave/sonic_wave.png.import new file mode 100644 index 0000000..5df9dba --- /dev/null +++ b/src/models/sonic_wave/sonic_wave.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sonic_wave.png-1cdfaa07cb82928a187ef5a3d8e5dab8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/sonic_wave/sonic_wave.png" +dest_files=[ "res://.import/sonic_wave.png-1cdfaa07cb82928a187ef5a3d8e5dab8.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=false +svg/scale=1.0