mirror of
				https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
				synced 2025-10-26 09:20:49 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			506 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			506 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
| class_name KeyItem
 | |
| extends Node2D
 | |
| 
 | |
| static var total_collected := 0
 | |
| const SMOKE_PARTICLE = preload("uid://d08nv4qtfouv1")
 | |
| func _ready() -> void:
 | |
| 	$AnimationPlayer.play("Float")
 | |
| 
 | |
| func on_area_entered(area: Area2D) -> void:
 | |
| 	if area.owner is Player:
 | |
| 		total_collected += 1
 | |
| 		AudioManager.play_sfx("key_collect", global_position)
 | |
| 		summon_smoke_particle()
 | |
| 		queue_free()
 | |
| 
 | |
| func summon_smoke_particle() -> void:
 | |
| 	var node = SMOKE_PARTICLE.instantiate()
 | |
| 	node.global_position = global_position
 | |
| 	add_sibling(node)
 | 
