FINALNY KOD PIERWSZA GRA

 avatar
Kandif
plain_text
7 months ago
701 B
38
Indexable
Never
extends Node2D

var projectile_scene = preload("res://projectile.tscn")
var score = 0	

func _on_timer_timeout():
	var projectile = projectile_scene.instantiate()
	add_child(projectile)
	projectile.position.x = randf_range(5,1100)
	projectile.get_node("RigidBody2D").body_entered.connect(body_entered.bind(projectile))
	
func _on_button_pressed():
	$Timer.start()
	score = 0
	$Label.text = "Punkty: "+str(score)
	$Button.visible = false
	
func body_entered(body,projectile):
	if body is StaticBody2D:
		if not $Button.visible:
			score += 1
		$Label.text = "Punkty: "+str(score)	
		projectile.queue_free()
	if body is CharacterBody2D:
		$Button.visible = true
		$Timer.stop()
		projectile.queue_free()
Leave a Comment