ADD: lose screen.

main
bog 2023-09-30 17:09:31 +02:00
parent b913e87654
commit 407e12fd38
4 changed files with 87 additions and 2 deletions

View File

@ -0,0 +1,26 @@
[gd_scene format=3 uid="uid://ch3n607i8yqy8"]
[node name="LoseMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 473.0
offset_top = 54.0
offset_right = 551.0
offset_bottom = 77.0
text = "YOU LOSE"

View File

@ -0,0 +1,18 @@
[gd_scene format=3 uid="uid://sj7j3yxfjkko"]
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 518.0
offset_top = 184.0
offset_right = 565.0
offset_bottom = 215.0
text = "PLAY
"

View File

@ -2,18 +2,26 @@ extends Node2D
var m_broken_timer = 0.0 var m_broken_timer = 0.0
var m_broken_time = 0.2 var m_broken_time = 0.2
var process_state = null
var m_death_timer = 0.0
var m_death_time = 1.0
func _ready(): func _ready():
for bear in get_tree().get_nodes_in_group('bears'): for bear in get_tree().get_nodes_in_group('bears'):
bear.m_target = $Player bear.m_target = $Player
bear.m_world = self bear.m_world = self
$Player.m_world = self $Player.m_world = self
self.process_state = self.process
func _process(delta): func _process(delta):
if self.process_state:
self.process_state.call(delta)
func process(delta):
for actor in get_tree().get_nodes_in_group('actors'): for actor in get_tree().get_nodes_in_group('actors'):
if is_outside(actor) and actor.is_normal(): if is_outside(actor) and actor.is_normal():
actor.to_falling() actor.to_falling()
if m_broken_timer >= m_broken_time: if m_broken_timer >= m_broken_time:
var k = 0 var k = 0
var N = 2 var N = 2
@ -31,6 +39,18 @@ func _process(delta):
m_broken_timer += delta m_broken_timer += delta
if $Player/Actor.is_dead():
self.process_state = self.process_death
m_death_timer = 0.0
func process_death(delta):
var f = m_death_timer/m_death_time
$CanvasLayer/ColorRect.modulate = Color(0, 0, 0, f)
if m_death_timer >= m_death_time:
get_tree().change_scene_to_file("res://LoseMenu/lose_menu.tscn")
m_death_timer += delta
func is_outside(actor): func is_outside(actor):
var coord = $TileMap.local_to_map(actor.global_position) var coord = $TileMap.local_to_map(actor.global_position)
var tile : TileData = $TileMap.get_cell_tile_data(0, coord) var tile : TileData = $TileMap.get_cell_tile_data(0, coord)

File diff suppressed because one or more lines are too long