Init commit
This commit is contained in:
commit
a4452b69c4
59 changed files with 1259 additions and 0 deletions
28
Enemies/Scripts/asteroid.gd
Normal file
28
Enemies/Scripts/asteroid.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends Area2D
|
||||
|
||||
var velocity = Vector2(0, 0)
|
||||
var rot_velocity = 0
|
||||
var explosion = preload('res://Scenes/explosion.tscn')
|
||||
var pop = preload("res://Sounds/Explosion5.wav")
|
||||
|
||||
func _ready() -> void:
|
||||
connect("body_entered", _on_body_entered)
|
||||
|
||||
func _physics_process(delta):
|
||||
position += velocity * delta
|
||||
rotation += rot_velocity * delta
|
||||
|
||||
Utils.wrap_position(self)
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.name == "Ship":
|
||||
Game.set_lives(Game.lives - 1)
|
||||
|
||||
Utils.play_sound(pop, get_parent())
|
||||
|
||||
var boom = explosion.instantiate()
|
||||
boom.position = body.global_position
|
||||
boom.scale = Vector2(6, 6)
|
||||
get_parent().add_child(boom)
|
||||
body.reset()
|
||||
queue_free()
|
||||
Loading…
Add table
Add a link
Reference in a new issue