Browse Source

:fire: Remove life container

DricomDragon 3 years ago
parent
commit
195d55bd27
2 changed files with 1 additions and 67 deletions
  1. 1 5
      godot/component/entity/brick/Grid.tscn
  2. 0 62
      godot/component/ui/LifeContainer.gd

+ 1 - 5
godot/component/entity/brick/Grid.tscn

@@ -1,6 +1,5 @@
-[gd_scene load_steps=3 format=2]
+[gd_scene load_steps=2 format=2]
 
-[ext_resource path="res://component/ui/LifeContainer.gd" type="Script" id=1]
 [ext_resource path="res://component/entity/brick/Grid.gd" type="Script" id=3]
 
 [node name="Grid" type="Node2D" groups=[
@@ -8,9 +7,6 @@
 ]]
 script = ExtResource( 3 )
 
-[node name="LifeContainer" type="Node2D" parent="."]
-script = ExtResource( 1 )
-
 [node name="MoveDown" type="Tween" parent="."]
 __meta__ = {
 "_editor_description_": "Move grid to show the new row"

+ 0 - 62
godot/component/ui/LifeContainer.gd

@@ -1,62 +0,0 @@
-extends Node2D
-
-
-var living_cells = {}
-var default_font
-
-
-const label_offset = Vector2(5, 15)
-const cell_size = Vector2(40, 20)
-const rect_pad = Vector2(3, 3)
-
-
-func spawn_brick(x, y, maximum_life):
-	living_cells[Vector2(x, y)] = randi() % maximum_life + 1
-	update()
-
-
-func may_die_by_taking_this(pos, damage):
-	var has_died = false
-
-	if damage > 0 and living_cells.has(pos):
-		living_cells[pos] -= damage
-		update()
-		has_died = living_cells[pos] <= 0
-
-		if has_died:
-			living_cells.erase(pos)
-
-	return has_died
-
-
-func create_font():
-	var label = Label.new()
-	default_font = label.get_font("font")
-
-
-func color_from_life(n):
-	var x = float(n % 256) / 255
-	if (n < 256):
-		return Color(x, 1.0, 1.0 - x)
-	elif (n < 512):
-		return Color(1.0, 1.0 - x, x)
-	elif (n < 768):
-		return Color(1.0, 0.0, 1.0 - x)
-	else:
-		return Color(1.0, 0.0, 0.0)
-
-
-func _ready():
-	create_font()
-
-
-func _draw():
-	var amount
-	var pos
-	var color
-	for cell in living_cells:
-		pos = cell * cell_size
-		amount = living_cells[cell]
-		color = color_from_life(amount)
-		draw_rect(Rect2(pos + rect_pad, cell_size - 2 * rect_pad), color, true)
-		draw_string(default_font, pos + label_offset, str(amount))