Init commit
This commit is contained in:
commit
a4452b69c4
59 changed files with 1259 additions and 0 deletions
37
Scripts/laser.gd
Normal file
37
Scripts/laser.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends Area2D
|
||||
|
||||
var explosion = preload('res://Scenes/explosion.tscn')
|
||||
var pop = preload("res://Sounds/Explosion.wav")
|
||||
var speed = 750
|
||||
|
||||
var half_size: Vector2 # half of sprite dimensions (used for wrapping)
|
||||
|
||||
func _ready() -> void:
|
||||
connect("area_entered", _on_body_entered)
|
||||
|
||||
half_size = Utils.get_half_size(self)
|
||||
|
||||
func _physics_process(delta):
|
||||
position += -transform.y * speed * delta
|
||||
|
||||
var rect = get_viewport_rect()
|
||||
|
||||
if position.x < -half_size.x or position.x > rect.size.x + half_size.x or position.y < -half_size.y or position.y > rect.size.y + half_size.y:
|
||||
#print_debug("FREED")
|
||||
queue_free()
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.is_in_group("enemies"):
|
||||
body.queue_free()
|
||||
|
||||
Utils.play_sound(pop, get_parent())
|
||||
|
||||
var boom = explosion.instantiate()
|
||||
boom.position = body.global_position
|
||||
boom.scale = body.scale
|
||||
get_parent().add_child(boom)
|
||||
|
||||
Game.set_score(Game.score + 100)
|
||||
|
||||
queue_free()
|
||||
#print_debug("KILLED")
|
||||
Loading…
Add table
Add a link
Reference in a new issue