Level_first

mail@pastecode.io avatar
unknown
plain_text
2 years ago
428 B
12
Indexable
Never
extends Node2D

var score = 0
var lives = 3

var ball = preload("res://Ball.tscn")

func _on_Area2D_body_entered(body):
	if body is RigidBody2D:
		lives -= 1
		$GameLabel/Lives.text = "LIVES: "+str(lives)
		var ballx = ball.instance()
		add_child(ballx)
		ballx.global_position = $Paddle.global_position + Vector2(0,-20)
		body.queue_free()
		if lives==0:
			get_tree().change_scene("res://Game/GameOver.tscn")