 34c7746815
			
		
	
	34c7746815
	
	
	
		
			
			On repart sur des bases simples le but étant de construire des niveaux qui commencent à avoir un game play progressif et qui mettent en place une vraie grammaire.
		
			
				
	
	
		
			95 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			GDScript
		
	
	
	
	
	
| class_name Game extends Node
 | |
| 
 | |
| @onready var hud := $HUD as HUD
 | |
| 
 | |
| var current_scene : Node
 | |
| 
 | |
| 
 | |
| var destination_map = {
 | |
|     "level_0":preload("res://levels/level_0.tscn"),
 | |
|     "level_1":preload("res://levels/level_1.tscn"),
 | |
|     "level_2":preload("res://levels/level_2.tscn")
 | |
| }
 | |
| 
 | |
| var scene_name = "level_0"
 | |
| var current_scence
 | |
| var prev_scene
 | |
| var last_spawn_point = null
 | |
| 
 | |
| var princesse : Princess = null
 | |
| 
 | |
| var goto_destination
 | |
| var goto_spawn_point
 | |
| 
 | |
| # Called when the node enters the scene tree for the first time.
 | |
| func _ready() -> void:
 | |
|     go_to(scene_name, null)
 | |
| 
 | |
| func reload_current_scene() -> void:
 | |
|     go_to(scene_name, last_spawn_point)
 | |
|     hud.reset()
 | |
| 
 | |
| func enter_door(destination : String, other_side_position : Vector2):
 | |
|     call_deferred("go_to", destination, other_side_position)
 | |
| 
 | |
| func go_to(destination : String, spawn_point):
 | |
|     goto_destination = destination
 | |
|     goto_spawn_point = spawn_point
 | |
|     hud.begin_scene_transition()
 | |
| 
 | |
| func _on_hud_screen_is_black() -> void:
 | |
|     var destination = goto_destination
 | |
|     var spawn_point = goto_spawn_point
 | |
| 
 | |
|     var old_princesse :Princess = null
 | |
|     if current_scence:
 | |
|         old_princesse = current_scence.find_child("Princesse")
 | |
|         old_princesse.disconnect("cheese_collected", hud_load_cheese)
 | |
|         old_princesse.disconnect("dash_fart", hud_unload_cheese)
 | |
|         #old_princesse.disconnect("princess_is_dead", princess_death)
 | |
|         remove_child(current_scence)
 | |
| 
 | |
| 
 | |
|     current_scence = destination_map[destination].instantiate()
 | |
|     scene_name = destination
 | |
| 
 | |
|     current_scence.connect("reload_me", reload_current_scene, ConnectFlags.CONNECT_ONE_SHOT)
 | |
|     var doors :Node = current_scence.find_child("Doors")
 | |
|     if doors:
 | |
|         for door in doors.get_children():
 | |
|             door.connect("door_openned", enter_door, ConnectFlags.CONNECT_ONE_SHOT)
 | |
|     add_child(current_scence)
 | |
| 
 | |
|     princesse= current_scence.find_child("Princesse")
 | |
|     if spawn_point:
 | |
|         princesse.position = spawn_point
 | |
|         last_spawn_point = spawn_point
 | |
|         if old_princesse:
 | |
|             princesse.copy_from(old_princesse)
 | |
|     princesse.connect("cheese_collected", hud_load_cheese)
 | |
|     princesse.connect("lactase_collected", hud_reset_cheese)
 | |
|     princesse.connect("dash_fart", hud_unload_cheese)
 | |
|     #princesse.connect("princess_is_dead", princess_death)
 | |
|     hud.end_scene_transition()
 | |
| 
 | |
| # vient de la princesse quand elle a ramassé du lactase
 | |
| func hud_reset_cheese():
 | |
|     Input.start_joy_vibration(0, 0.1, 0.1, 0.1)
 | |
|     hud.reset()
 | |
| 
 | |
| # vient de la princesse quand elle a ramassé un fromage
 | |
| func hud_load_cheese(speed):
 | |
|     Input.start_joy_vibration(0, 0, 1, 0.1)
 | |
|     hud.load_cheese(speed)
 | |
| 
 | |
| # vient de la princesse quand elle ^ète
 | |
| func hud_unload_cheese():
 | |
|     hud.dash_fart()
 | |
| 
 | |
| # quand le fromage est chargé, le jeu le signale à la princesse
 | |
| func _on_hud_fart_reloaded() -> void:
 | |
|     princesse.reload_fart()
 | |
| 
 | |
| func _on_hud_screen_is_ready() -> void:
 | |
|     princesse.go_out_and_play()
 |