Added homing shuriken and fixed Viewport
parent
09266bd67a
commit
27aa1afce3
|
|
@ -49,5 +49,7 @@ script = ExtResource("1_1gl40")
|
||||||
shape = SubResource("CircleShape2D_7kba2")
|
shape = SubResource("CircleShape2D_7kba2")
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1117029857]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1117029857]
|
||||||
|
texture_filter = 1
|
||||||
sprite_frames = SubResource("SpriteFrames_mi4h5")
|
sprite_frames = SubResource("SpriteFrames_mi4h5")
|
||||||
|
autoplay = "default"
|
||||||
frame_progress = 0.02371424
|
frame_progress = 0.02371424
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
[gd_scene format=3 uid="uid://ddfdsj38deof6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d0vbrag76qoil" path="res://scripts/shuriken.gd" id="1_k18gy"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dimo6wv81xev4" path="res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_02.png" id="2_0rvwh"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jr3c8"]
|
||||||
|
atlas = ExtResource("2_0rvwh")
|
||||||
|
region = Rect2(496, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_yvn8i"]
|
||||||
|
atlas = ExtResource("2_0rvwh")
|
||||||
|
region = Rect2(512, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_tacqd"]
|
||||||
|
atlas = ExtResource("2_0rvwh")
|
||||||
|
region = Rect2(528, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_c2qga"]
|
||||||
|
atlas = ExtResource("2_0rvwh")
|
||||||
|
region = Rect2(544, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_r3mqu"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_jr3c8")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_yvn8i")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_tacqd")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_c2qga")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 20.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_bgiul"]
|
||||||
|
radius = 8.0
|
||||||
|
|
||||||
|
[node name="Shuriken" type="Area2D" unique_id=1854090943]
|
||||||
|
script = ExtResource("1_k18gy")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1281987394]
|
||||||
|
texture_filter = 1
|
||||||
|
sprite_frames = SubResource("SpriteFrames_r3mqu")
|
||||||
|
autoplay = "default"
|
||||||
|
frame_progress = 0.3453456
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=572140399]
|
||||||
|
shape = SubResource("CircleShape2D_bgiul")
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
extends ProjectileBase
|
||||||
|
|
||||||
|
var enemies_hit = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
speed = 500
|
||||||
|
super()
|
||||||
|
var first = get_nearest_enemy(global_position)
|
||||||
|
if first == null:
|
||||||
|
queue_free()
|
||||||
|
return
|
||||||
|
launch(first.global_position)
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
|
if body.is_in_group("enemies"):
|
||||||
|
enemies_hit += 1
|
||||||
|
body.die()
|
||||||
|
if enemies_hit == 20:
|
||||||
|
queue_free()
|
||||||
|
else:
|
||||||
|
var next = get_nearest_enemy(global_position, body)
|
||||||
|
if next == null:
|
||||||
|
queue_free()
|
||||||
|
else:
|
||||||
|
launch(next.global_position)
|
||||||
|
|
||||||
|
func get_nearest_enemy(from: Vector2, exclude: Node = null) -> Node:
|
||||||
|
var nearest = null
|
||||||
|
var min_distance = INF
|
||||||
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||||
|
if enemy == exclude or enemy.is_dying:
|
||||||
|
continue
|
||||||
|
var dist = from.distance_to(enemy.global_position)
|
||||||
|
if dist < min_distance:
|
||||||
|
min_distance = dist
|
||||||
|
nearest = enemy
|
||||||
|
return nearest
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d0vbrag76qoil
|
||||||
|
|
@ -7,20 +7,15 @@ var down_left
|
||||||
var viewport_rect
|
var viewport_rect
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
viewport_rect = get_viewport_rect()
|
var camera: Camera2D = get_parent().get_node("Camera2D")
|
||||||
|
var viewport_size = get_viewport_rect().size
|
||||||
|
var world_size = viewport_size / camera.zoom
|
||||||
|
var world_origin = camera.global_position # anchor_mode = 0 → top-left corner
|
||||||
|
|
||||||
print(get_viewport_rect())
|
up_left = world_origin
|
||||||
|
down_right = world_origin + world_size
|
||||||
up_left = viewport_rect.position
|
up_right = Vector2(down_right.x, up_left.y)
|
||||||
down_right = viewport_rect.end
|
down_left = Vector2(up_left.x, down_right.y)
|
||||||
up_right = Vector2(viewport_rect.end.x, viewport_rect.position.y)
|
|
||||||
down_left = Vector2(viewport_rect.position.x, viewport_rect.end.y)
|
|
||||||
print(up_left)
|
|
||||||
print(up_right)
|
|
||||||
print(down_left)
|
|
||||||
print(down_right)
|
|
||||||
print(get_spawn_position())
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
func get_spawn_position() -> Vector2:
|
func get_spawn_position() -> Vector2:
|
||||||
var side = randi() % 4
|
var side = randi() % 4
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ var camera
|
||||||
var bar_progress = 0
|
var bar_progress = 0
|
||||||
var is_casting = false
|
var is_casting = false
|
||||||
var fireball = preload("res://scenes/fireball.tscn")
|
var fireball = preload("res://scenes/fireball.tscn")
|
||||||
|
var shuriken = preload("res://scenes/shuriken.tscn")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
camera = get_node("/root/Game/Camera2D")
|
camera = get_node("/root/Game/Camera2D")
|
||||||
|
|
||||||
|
|
@ -20,7 +22,7 @@ func _on_collect(DropsBase):
|
||||||
bar_progress = 0
|
bar_progress = 0
|
||||||
is_casting = true
|
is_casting = true
|
||||||
await $CauldronBar.ignite_cauldrons()
|
await $CauldronBar.ignite_cauldrons()
|
||||||
shoot_fireballs()
|
shoot_shuriken()
|
||||||
camera.shake(0.3,0.8)
|
camera.shake(0.3,0.8)
|
||||||
$CauldronBar.reset_texture()
|
$CauldronBar.reset_texture()
|
||||||
is_casting = false
|
is_casting = false
|
||||||
|
|
@ -32,3 +34,18 @@ func shoot_fireballs():
|
||||||
fb.global_position = global_position
|
fb.global_position = global_position
|
||||||
get_parent().add_child(fb)
|
get_parent().add_child(fb)
|
||||||
fb.launch(enemy.global_position)
|
fb.launch(enemy.global_position)
|
||||||
|
|
||||||
|
func shoot_shuriken():
|
||||||
|
var sh = shuriken.instantiate()
|
||||||
|
sh.global_position = global_position
|
||||||
|
get_parent().add_child(sh)
|
||||||
|
|
||||||
|
func get_nearest_enemy(from: Vector2) -> Node:
|
||||||
|
var nearest = null
|
||||||
|
var min_distance = INF
|
||||||
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||||
|
var dist = from.distance_to(enemy.global_position)
|
||||||
|
if dist < min_distance:
|
||||||
|
min_distance = dist
|
||||||
|
nearest = enemy
|
||||||
|
return nearest
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue