boss update

This commit is contained in:
Ultrablob 2024-04-25 15:27:00 -04:00
parent c885095bc1
commit 0c0cc1d5f1
16 changed files with 201 additions and 295 deletions

View file

@ -1,76 +1,52 @@
extends Marker2D
extends Node2D
@export var item: PackedScene
@export var waves: Array[Wave]
var portal = preload("res://portal.tscn")
@export var portal_texture: SpriteFrames
@export var random_off_screen = false
@export var radius = 100
var enemies_previous = false
func project_ray_to_screen_edge(player_position: Vector2) -> Vector2:
var screen_size = get_viewport().size
func _ready():
spawn_loop()
# Generate a random point on the screen
var random_point = Vector2(randf_range(0, screen_size.x), randf_range(0, screen_size.y))
# Calculate the direction vector from the player to the random point
var direction = (random_point - player_position).normalized()
# Calculate the intersection points with the screen edges
var intersection_points = []
# Check intersection with the left edge
var left_intersection = Vector2(0, player_position.y + direction.y * (0 - player_position.x) / direction.x)
if left_intersection.y >= 0 and left_intersection.y <= screen_size.y:
intersection_points.append(left_intersection)
# Check intersection with the right edge
var right_intersection = Vector2(screen_size.x, player_position.y + direction.y * (screen_size.x - player_position.x) / direction.x)
if right_intersection.y >= 0 and right_intersection.y <= screen_size.y:
intersection_points.append(right_intersection)
# Check intersection with the top edge
var top_intersection = Vector2(player_position.x + direction.x * (0 - player_position.y) / direction.y, 0)
if top_intersection.x >= 0 and top_intersection.x <= screen_size.x:
intersection_points.append(top_intersection)
# Check intersection with the bottom edge
var bottom_intersection = Vector2(player_position.x + direction.x * (screen_size.y - player_position.y) / direction.y, screen_size.y)
if bottom_intersection.x >= 0 and bottom_intersection.x <= screen_size.x:
intersection_points.append(bottom_intersection)
# Find the closest intersection point to the player
var closest_intersection = intersection_points[0]
var min_distance = player_position.distance_to(closest_intersection)
for point in intersection_points:
var distance = player_position.distance_to(point)
if distance < min_distance:
closest_intersection = point
min_distance = distance
return closest_intersection
signal all_enemies_perished
func check_enemies_loop():
var has_enemies = len(get_tree().get_nodes_in_group("enemy")) > 0
if enemies_previous and not has_enemies:
all_enemies_perished.emit()
enemies_previous = has_enemies
func spawn_loop():
for wave in waves:
print("Starting Next Wave")
for i in range(len(wave.enemies)):
spawn_enemies(wave.quantities[i], wave.spawning_duration, wave.enemies[i])
if wave.wait_for_killed:
await all_enemies_perished
await get_tree().create_timer(wave.spawning_duration + wave.wait).timeout
func spawn_enemies(count: int, duration: float, enemy: WaveEnemy):
var delay = duration / count
for i in range(count):
await get_tree().create_timer(delay).timeout
spawn(enemy)
func spawn(item: WaveEnemy):
func spawn():
if get_tree().paused:
return
var spawn_loc = Vector2.ZERO
if random_off_screen:
spawn_loc = project_ray_to_screen_edge($"../Player".global_position)
#print(spawn_loc)
for i in range(10):
var test_pos = Vector2(randf(), randf()) * Vector2(1920, 1080)
if not $"../CollisionCheck".is_clear(test_pos, radius):
if not $"../CollisionCheck".is_clear(test_pos, item.check_distance):
continue
spawn_loc = test_pos
break
if spawn_loc != Vector2.ZERO:
var portal_effect = portal.instantiate()
portal_effect.global_position = spawn_loc
portal_effect.sprite_frames = portal_texture
$/root/Node2D.add_child(portal_effect)
await get_tree().create_timer(0.6).timeout
var node = item.instantiate()
node.global_position = spawn_loc
node.rotation_degrees = 360 * randf()
$/root/Node2D.add_child(node)
var portal_effect = portal.instantiate()
portal_effect.global_position = spawn_loc
portal_effect.sprite_frames = item.portal_texture
$/root/Node2D.add_child(portal_effect)
await get_tree().create_timer(0.6).timeout
var node = item.enemy.instantiate()
node.global_position = spawn_loc
node.rotation_degrees = 360 * randf()
$/root/Node2D.add_child(node)

View file

@ -6,7 +6,7 @@
[ext_resource type="Texture2D" uid="uid://djfjdlri5xdkn" path="res://dotted line.png" id="4_vixiu"]
[ext_resource type="Script" path="res://TrajectoryDisplay.gd" id="5_w6b4q"]
[node name="Entagon" type="RigidBody2D"]
[node name="Entagon" type="RigidBody2D" groups=["enemy"]]
physics_material_override = ExtResource("1_pvpk5")
gravity_scale = 1.66533e-16
max_contacts_reported = 2

View file

@ -9,7 +9,7 @@
[sub_resource type="CircleShape2D" id="CircleShape2D_yns8h"]
radius = 128.0
[node name="Ircle" type="StaticBody2D" groups=["destructible"]]
[node name="Ircle" type="StaticBody2D" groups=["destructible", "enemy"]]
scale = Vector2(0.2, 0.2)
script = ExtResource("2_lyi2i")

11
ircle_enemy.tres Normal file
View file

@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="WaveEnemy" load_steps=4 format=3 uid="uid://du12lm5aq7g7f"]
[ext_resource type="PackedScene" uid="uid://4lc6bvf7b8a0" path="res://ircle.tscn" id="1_rot3q"]
[ext_resource type="SpriteFrames" uid="uid://dh2kuw87g8lsx" path="res://ircle_portal.tres" id="2_7xiki"]
[ext_resource type="Script" path="res://wave_enemy.gd" id="3_0eg7c"]
[resource]
script = ExtResource("3_0eg7c")
enemy = ExtResource("1_rot3q")
portal_texture = ExtResource("2_7xiki")
check_distance = 100

239
main.tscn

File diff suppressed because one or more lines are too long

View file

@ -161,6 +161,7 @@ popup/item_1/text = "Absolute"
popup/item_1/id = 1
[node name="Tutorial Text" type="Label" parent="."]
visible = false
z_index = 2
layout_mode = 1
anchors_preset = -1
@ -247,8 +248,8 @@ text = "[center][wave]LOADING..."
[connection signal="pressed" from="Layout/Play" to="." method="play"]
[connection signal="pressed" from="Layout/Settings" to="Settings Panel" method="show"]
[connection signal="pressed" from="Layout/Tutorial" to="Tutorial Text" method="show"]
[connection signal="pressed" from="Settings Panel/Close" to="Settings Panel" method="hide"]
[connection signal="pressed" from="Settings Panel/Close" to="Settings Panel" method="save"]
[connection signal="pressed" from="Settings Panel/Close" to="Settings Panel" method="hide"]
[connection signal="text_changed" from="Settings Panel/Menu/Username" to="Settings Panel" method="check_valid"]
[connection signal="text_changed" from="Settings Panel/Menu/Username" to="Settings Panel/Menu/Username" method="check"]
[connection signal="pressed" from="Tutorial Text/Close" to="Tutorial Text" method="hide"]

BIN
riangle-tar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

34
riangle-tar.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c562ut0sxn6we"
path="res://.godot/imported/riangle-tar.png-85282abe49c8b4b5e10a25bc605b68de.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://riangle-tar.png"
dest_files=["res://.godot/imported/riangle-tar.png-85282abe49c8b4b5e10a25bc605b68de.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -5,7 +5,7 @@
[ext_resource type="Script" path="res://Gun.gd" id="3_kffl0"]
[ext_resource type="PackedScene" uid="uid://c6ybtahxwpukd" path="res://bullet.tscn" id="4_tfncc"]
[node name="Riangle" type="StaticBody2D" groups=["destructible"]]
[node name="Riangle" type="StaticBody2D" groups=["destructible", "enemy"]]
scale = Vector2(0.25, 0.25)
script = ExtResource("1_0404b")

11
riangle_enemy.tres Normal file
View file

@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="WaveEnemy" load_steps=4 format=3 uid="uid://3gxjbodh4fwe"]
[ext_resource type="PackedScene" uid="uid://yu50iyftoyaj" path="res://riangle.tscn" id="1_y74g3"]
[ext_resource type="SpriteFrames" uid="uid://tu8xwjkn0wrj" path="res://riangle_portal.tres" id="2_1rl0g"]
[ext_resource type="Script" path="res://wave_enemy.gd" id="3_nyiux"]
[resource]
script = ExtResource("3_nyiux")
enemy = ExtResource("1_y74g3")
portal_texture = ExtResource("2_1rl0g")
check_distance = 200

View file

@ -1,57 +1,57 @@
[gd_resource type="SpriteFrames" load_steps=15 format=3 uid="uid://tu8xwjkn0wrj"]
[ext_resource type="Texture2D" uid="uid://bu70lwr6f3igy" path="res://riangle-portal.png" id="1_feams"]
[ext_resource type="Texture2D" uid="uid://bu70lwr6f3igy" path="res://riangle-portal.png" id="1_eu7lo"]
[sub_resource type="AtlasTexture" id="AtlasTexture_thlf3"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_k8fir"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_ef8n0"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_b4r12"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_m80wu"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(256, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_bgag0"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(320, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_x8g3t"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(384, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_bc75a"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(448, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_7mie0"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(512, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_lny5u"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(576, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_oc8gy"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(640, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_dy0eq"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(704, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_hgt5f"]
atlas = ExtResource("1_feams")
atlas = ExtResource("1_eu7lo")
region = Rect2(768, 0, 64, 64)
[resource]

View file

@ -13,3 +13,15 @@ func spawn():
node.global_rotation = zone.global_rotation
node.global_position = global_position
tween.tween_property(node, "position", Vector2.ZERO, 1)
func eject():
var tween = get_tree().create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
for spawner in get_children():
var riangle = spawner.get_child(0)
tween.tween_property(riangle, "position", Vector2(200, 0), 1)
tween.tween_property(spawner, "process_mode", PROCESS_MODE_PAUSABLE, 0)
await tween.finished
for spawner in get_children():
spawner.process_mode = Node.PROCESS_MODE_INHERIT

1
tar.gd
View file

@ -5,3 +5,4 @@ func phase():
$"Riangle Zone".spawn()
await get_tree().create_timer(1).timeout
$Sprite.play("idle")
$"Riangle Zone".eject()

View file

@ -1,13 +1,9 @@
[gd_scene load_steps=24 format=3 uid="uid://4sdwatj6up8i"]
[gd_scene load_steps=21 format=3 uid="uid://4sdwatj6up8i"]
[ext_resource type="Script" path="res://tar.gd" id="1_7s3by"]
[ext_resource type="Texture2D" uid="uid://d4cjh2d7wxdyp" path="res://tar_body.png" id="1_pwibo"]
[ext_resource type="Script" path="res://riangle_spawner.gd" id="2_h2r2l"]
[sub_resource type="AtlasTexture" id="AtlasTexture_sh8vt"]
atlas = ExtResource("1_pwibo")
region = Rect2(0, 0, 128, 128)
[sub_resource type="AtlasTexture" id="AtlasTexture_8xl5i"]
atlas = ExtResource("1_pwibo")
region = Rect2(128, 0, 128, 128)
@ -16,14 +12,6 @@ region = Rect2(128, 0, 128, 128)
atlas = ExtResource("1_pwibo")
region = Rect2(256, 0, 128, 128)
[sub_resource type="AtlasTexture" id="AtlasTexture_ygsgt"]
atlas = ExtResource("1_pwibo")
region = Rect2(384, 0, 128, 128)
[sub_resource type="AtlasTexture" id="AtlasTexture_poiv0"]
atlas = ExtResource("1_pwibo")
region = Rect2(1408, 0, 128, 128)
[sub_resource type="AtlasTexture" id="AtlasTexture_vc7mr"]
atlas = ExtResource("1_pwibo")
region = Rect2(1536, 0, 128, 128)
@ -84,21 +72,12 @@ region = Rect2(1536, 0, 128, 128)
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_sh8vt")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8xl5i")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xmge8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ygsgt")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_poiv0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vc7mr")
}],
"loop": true,
@ -151,16 +130,17 @@ animations = [{
}]
[node name="Tar" type="Node2D"]
position = Vector2(386, 292)
script = ExtResource("1_7s3by")
[node name="Sprite" type="AnimatedSprite2D" parent="."]
z_index = 1
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_ufq3r")
animation = &"idle"
animation = &"spawn"
autoplay = "idle"
frame = 1
frame_progress = 0.467855
frame = 2
frame_progress = 0.819547
[node name="StaticBody2D" type="StaticBody2D" parent="."]

9
wave.gd Normal file
View file

@ -0,0 +1,9 @@
extends Resource
class_name Wave
@export var enemies: Array[WaveEnemy]
@export var quantities: Array[int]
@export var spawning_duration: float = 1
@export var wait: float = 1
@export var wait_for_killed = false

8
wave_enemy.gd Normal file
View file

@ -0,0 +1,8 @@
extends Resource
class_name WaveEnemy
@export var enemy: PackedScene = null
@export var portal_texture: SpriteFrames = null
@export var check_distance = 100