Bat
parent
3864513cf3
commit
58bc799cb9
|
@ -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 )
|
|
@ -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)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -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
|
|
@ -4,7 +4,7 @@
|
||||||
[ext_resource path="res://src/models/player/player.gd" type="Script" id=2]
|
[ext_resource path="res://src/models/player/player.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 4, 5.5 )
|
extents = Vector2( 7, 11 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 7, 11 )
|
extents = Vector2( 7, 11 )
|
||||||
|
|
Loading…
Reference in New Issue