-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.gd
More file actions
30 lines (24 loc) · 774 Bytes
/
Bullet.gd
File metadata and controls
30 lines (24 loc) · 774 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
@export var speed = 1000
var timer := Timer.new()
var screen_size
func _ready():
screen_size = get_parent().get_parent().get_viewport_rect().size
add_child(timer)
timer.wait_time = 2
timer.one_shot = true
timer.start()
timer.connect("timeout", _on_timer_timeout)
func _on_timer_timeout():
get_node("..").queue_free()
func _physics_process(delta):
position += transform.x * speed * delta
if get_node("/root/Game").flagExists("wrapbullets"):
position.x = wrapf(position.x, 0, screen_size.x)
position.y = wrapf(position.y, 0, screen_size.y)
#func _on_Bullet_body_entered(body):
#if body.is_in_group("asteroid"):
#body.queue_free()
#get_node("..").queue_free()
func updateScreenSize():
screen_size = $"/root/Game".get_viewport_rect().size