Wizard Tower and special effects

This commit is contained in:
2025-04-15 20:32:00 +02:00
parent c4c01800dd
commit 08479e83c1
16 changed files with 302 additions and 20 deletions

View File

@ -1,4 +0,0 @@
extends Node2D
func _ready() -> void:
print("ready")

View File

@ -1 +0,0 @@
uid://b3dcdgqfb5nf3

View File

@ -3,6 +3,7 @@ extends Node2D
var target
var speed
var hitpoint
var distancetaken = 0
func set_targe(_target : Node2D) -> void:
target = _target
@ -19,17 +20,32 @@ func _process(delta: float) -> void:
var direction = (target.get_parent().get_parent().get_position() - position).normalized()
# Rotate the bullet to face the target
rotation = direction.angle() + deg_to_rad(90)
if name.contains("Arrow"):
rotation = direction.angle() + deg_to_rad(90)
# Move the bullet towards the target
position += direction * speed * delta
distancetaken += (direction * speed * delta).length()
if position.distance_to(target.get_parent().get_parent().position) <= 5:
target_reached()
if distancetaken > 250:
queue_free()
else:
queue_free()
func target_reached() -> void:
var chance = 0
if name.contains("Arrow"): #special effects here!
if randf() < 0.1:
target.get_parent().set_speed(target.get_parent().get_speed() / 2)
pass
if name.contains("Magic"):
if randf() < 0.5:
target.get_parent().set_progress(max(target.get_parent().get_progress() - 60, 0))
target.get_parent().enemy_hurt(hitpoint)
queue_free()

68
Game/Bullets/magic.tscn Normal file
View File

@ -0,0 +1,68 @@
[gd_scene load_steps=7 format=3 uid="uid://caynrq7jnjlnx"]
[ext_resource type="Texture2D" uid="uid://mmrsjrjxv168" path="res://Assets/Bullets/magic.png" id="1_jjep1"]
[ext_resource type="Script" uid="uid://dqvdgdobuo2rf" path="res://Game/Bullets/bullet.gd" id="1_lj5pp"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lj5pp"]
size = Vector2(18, 16)
[sub_resource type="Animation" id="Animation_lj5pp"]
resource_name = "rotation"
length = 0.5
markers = [{
"color": Color(1, 1, 1, 1),
"name": &"new_marker",
"time": 0.5
}]
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:rotation")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 6.28319]
}
[sub_resource type="Animation" id="Animation_0itbo"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_55qby"]
_data = {
&"RESET": SubResource("Animation_0itbo"),
&"rotation": SubResource("Animation_lj5pp")
}
[node name="Magic" type="Node2D"]
script = ExtResource("1_lj5pp")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource("RectangleShape2D_lj5pp")
[node name="AnimationPlayer" type="AnimationPlayer" parent="CharacterBody2D"]
libraries = {
&"": SubResource("AnimationLibrary_55qby")
}
autoplay = "rotation"
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
scale = Vector2(3, 3)
texture = ExtResource("1_jjep1")