mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-26 06:24:18 +00:00
18 lines
502 B
GDScript3
18 lines
502 B
GDScript3
|
extends Position2D
|
||
|
|
||
|
# Items
|
||
|
onready var bullet = preload("res://src/entities/Bullet.tscn")
|
||
|
onready var spawner = get_node("/root/Game/PhaseOne/PhaseOneContainer/Player")
|
||
|
|
||
|
func _process(_delta):
|
||
|
if Input.is_action_just_pressed("shoot"):
|
||
|
_on_Click()
|
||
|
|
||
|
func _on_Click():
|
||
|
var newBullet = bullet.instance()
|
||
|
newBullet.set_position(spawner.position)
|
||
|
var bulletRotation = rad2deg(newBullet.get_angle_to(get_global_mouse_position()))
|
||
|
newBullet.set_rotation_degrees(bulletRotation)
|
||
|
add_child(newBullet)
|
||
|
|