-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBush.gd
More file actions
30 lines (25 loc) · 689 Bytes
/
Copy pathBush.gd
File metadata and controls
30 lines (25 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extends Area2D
var life = 25
func _ready():
rotate(randf()*PI)
modulate = Color(0.4+randf()*0.2, 0.4+randf()*0.2, 0.4+randf()*0.2)
$Sprite.frame = randi() % 3
var r = int($CollisionShape2D.shape.radius * randf())
$CollisionShape2D.shape.radius = r
func hit(damage, source):
life -= damage
if life < 0:
destroy()
source.addPoints(-2)
func destroy():
$Sprite.hide()
$Particles2D.restart()
if $CollisionShape2D != null:
$CollisionShape2D.remove_and_skip()
if $Area2D/CollisionShape2D != null:
$Area2D/CollisionShape2D.remove_and_skip()
func _on_Bush1_body_entered(body):
if body.is_in_group("heavy"):
destroy()
if body.is_in_group("tank"):
body.addPoints(-2)