clegg
This commit is contained in:
commit
6a269eb236
97 changed files with 2137 additions and 0 deletions
28
bat/bat.gd
Normal file
28
bat/bat.gd
Normal file
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
@onready var startpos = position
|
||||
@export var speed = 1.0
|
||||
@export var sine_distance = 64.0
|
||||
@export var shoot_cooldown = 1.0
|
||||
const BULLET = preload("res://bat/bat_bullet/bat_bullet.tscn")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
%ShootTimer.start(shoot_cooldown)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
var sine = sin(Time.get_ticks_msec() / 300.0) * sine_distance
|
||||
position.y = startpos.y + sine
|
||||
|
||||
|
||||
func _on_shoot_timer_timeout() -> void:
|
||||
var player = get_owner().get_node("Player")
|
||||
var bullet = BULLET.instantiate()
|
||||
bullet.global_position = global_position
|
||||
get_parent().add_child(bullet)
|
||||
if player.position.x < position.x:
|
||||
bullet.direction = -1
|
||||
else:
|
||||
bullet.direction = 1
|
1
bat/bat.gd.uid
Normal file
1
bat/bat.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dibk7l4v1bbm
|
55
bat/bat.tscn
Normal file
55
bat/bat.tscn
Normal file
|
@ -0,0 +1,55 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://n8d1t160vvln"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dibk7l4v1bbm" path="res://bat/bat.gd" id="1_dj6ma"]
|
||||
[ext_resource type="Texture2D" uid="uid://1gfwereeox0m" path="res://gren.png" id="4_eu2gq"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_libqc"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_eu2gq")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 30.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5bpm1"]
|
||||
size = Vector2(16, 16)
|
||||
|
||||
[node name="Bat" type="Node2D"]
|
||||
script = ExtResource("1_dj6ma")
|
||||
speed = 2.0
|
||||
sine_distance = 32.0
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_libqc")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.659971
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["death", "enemy_hitbox"]]
|
||||
collision_layer = 8
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("RectangleShape2D_5bpm1")
|
||||
|
||||
[node name="ShootTimer" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[connection signal="timeout" from="ShootTimer" to="." method="_on_shoot_timer_timeout"]
|
12
bat/bat_bullet/bat_bullet.gd
Normal file
12
bat/bat_bullet/bat_bullet.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
@export var speed = 100.0
|
||||
@export var direction = 1
|
||||
var grazed = false
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
position.x += (speed * direction) * delta
|
||||
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
if !body.is_in_group("player_hitbox"): queue_free()
|
1
bat/bat_bullet/bat_bullet.gd.uid
Normal file
1
bat/bat_bullet/bat_bullet.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dwqt7eu84wgv7
|
24
bat/bat_bullet/bat_bullet.tscn
Normal file
24
bat/bat_bullet/bat_bullet.tscn
Normal file
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://jf4rxymi15id"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dwqt7eu84wgv7" path="res://bat/bat_bullet/bat_bullet.gd" id="1_bopwj"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pxoj5"]
|
||||
size = Vector2(8, 4)
|
||||
|
||||
[node name="BatBullet" type="Node2D"]
|
||||
script = ExtResource("1_bopwj")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
offset_left = -4.0
|
||||
offset_top = -2.0
|
||||
offset_right = 4.0
|
||||
offset_bottom = 2.0
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["enemy_bullet", "hurt"]]
|
||||
collision_layer = 8
|
||||
collision_mask = 19
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("RectangleShape2D_pxoj5")
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
Loading…
Add table
Add a link
Reference in a new issue