midori-school/sprites/common/bullet/snowflake.gd

50 lines
1.2 KiB
GDScript3
Raw Permalink Normal View History

2024-01-30 04:05:17 +01:00
extends Area2D
var velocity: Vector2 = Vector2()
var direction
var speed = 100
var btype
2024-03-24 19:23:12 +01:00
var isvisible
2024-01-30 04:05:17 +01:00
# Called when the node enters the scene tree for the first time.
func _ready():
2024-03-24 19:23:12 +01:00
isvisible = $VisibleOnScreenNotifier2D
2024-01-30 04:05:17 +01:00
add_to_group(btype)
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _physics_process(delta):
2024-03-24 19:23:12 +01:00
if isvisible.is_on_screen():
if direction == null:
position += velocity * delta
else:
position += speed * delta * direction
2024-01-30 04:05:17 +01:00
func _on_body_entered(body):
2024-04-23 00:19:53 +02:00
if !body.is_in_group(btype) && Global.live == 1:
if body.is_in_group("players"):
2024-01-30 04:05:17 +01:00
if body.weakness == 0:
2024-04-23 00:19:53 +02:00
print("weakness")
Input.start_joy_vibration(0,0,1,3)
else:
Input.start_joy_vibration(0,1,0,2)
elif body.is_in_group("boss") || body.is_in_group("enemies"):
if body.weakness == 0:
print("weakness")
2024-01-30 04:05:17 +01:00
#if body.is_in_group("players"):
# Global.live = 2
#elif body.is_in_group("enemies"):
# Global.live = 3
#elif body.is_in_group("boss"):
# Global.live = 3
queue_free()
func _on_area_entered(area):
if !area.is_in_group(btype):
queue_free()
#pass # Replace with function body.