diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn new file mode 100644 index 0000000..8379ea4 --- /dev/null +++ b/src/models/enemies/bat/Bat.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/models/enemies/bat/sprite.png" type="Texture" id=1] +[ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 4, 3 ) + +[node name="Bat" type="KinematicBody2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) +centered = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 7, 4 ) +shape = SubResource( 1 ) diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd new file mode 100644 index 0000000..fc91a9f --- /dev/null +++ b/src/models/enemies/bat/bat.gd @@ -0,0 +1,17 @@ +extends KinematicBody2D + +var velocity = Vector2.ZERO +var speed = 48 + +func _process(_delta): + get_node("Sprite").flip_h = true if $"../Player".global_position.x > self.position.x else false + +func _physics_process(_delta): + if position.distance_to(Vector2($"../Player".global_position.x, $"../Player".global_position.y)) > 48: + velocity.x = speed * cos(get_angle_to(Vector2($"../Player".global_position.x + 7, $"../Player".global_position.y + 8))) + velocity.y = speed * sin(get_angle_to(Vector2($"../Player".global_position.x + 7, $"../Player".global_position.y + 8))) + else: + velocity = Vector2.ZERO + + move_and_slide(velocity) + diff --git a/src/models/enemies/bat/sprite.png b/src/models/enemies/bat/sprite.png new file mode 100644 index 0000000..b30bf61 Binary files /dev/null and b/src/models/enemies/bat/sprite.png differ diff --git a/src/models/enemies/bat/sprite.png.import b/src/models/enemies/bat/sprite.png.import new file mode 100644 index 0000000..2b84f0a --- /dev/null +++ b/src/models/enemies/bat/sprite.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sprite.png-742176af9ae55b1874092f535d7f098a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/enemies/bat/sprite.png" +dest_files=[ "res://.import/sprite.png-742176af9ae55b1874092f535d7f098a.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 diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index 14e9b52..3b617e1 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/models/player/player.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 4, 5.5 ) +extents = Vector2( 7, 11 ) [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 7, 11 )