44 lines
		
	
	
		
			1018 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1018 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
| class_name GameController extends Node2D
 | |
| 
 | |
| # Game Data 
 | |
| var totalCrates = 4
 | |
| var cratesDestroyed = 0
 | |
| 
 | |
| 
 | |
| # Called when the node enters the scene tree for the first time.
 | |
| func _ready() -> void:
 | |
| 	pass # Replace with function body.
 | |
| 
 | |
| # Called every frame. 'delta' is the elapsed time since the previous frame.
 | |
| func _process(delta: float) -> void:
 | |
| 	pass
 | |
| 
 | |
| 
 | |
| func _on_trigger_area_trigger(effect, body) -> void:
 | |
| 	print("Do effect "+effect)
 | |
| 	match effect:
 | |
| 		"destroy":
 | |
| 			#write code to destroy
 | |
| 			if body is Crate:
 | |
| 				%SceneManager.destroy(body)
 | |
| 				cratesDestroyed +=1
 | |
| 		"powerup":
 | |
| 			#write code to powerup
 | |
| 			if body is Player:
 | |
| 				print("POWERRRRRR UP")
 | |
| 				#Player.SPEED = 700 
 | |
| 
 | |
| 
 | |
| 
 | |
| func bulletHit(body):
 | |
| 	print("game controller knows bullet hit")
 | |
| 	if body is Crate:
 | |
| 		print("you've hit a crate")
 | |
| 		cratesDestroyed +=1
 | |
| 		%SceneManager.destroy(body)
 | |
| 		print("crates Remaining :: "+str(totalCrates - cratesDestroyed))
 | |
| 		
 | |
| func numberOfCrates(value):
 | |
| 	totalCrates = value 
 | |
| 	print("Game Controller know scrates "+str(totalCrates))
 |