Added first round of graphics
This commit is contained in:
+50
-17
@@ -1,18 +1,18 @@
|
||||
extends StaticBody2D
|
||||
class_name Brick
|
||||
|
||||
enum {
|
||||
NORMAL,
|
||||
SHINY,
|
||||
INVULNERABLE
|
||||
}
|
||||
|
||||
signal brick_destroyed(brick : StaticBody2D)
|
||||
|
||||
@export var hits : int = 1
|
||||
@export var value : int = 100
|
||||
@export var color : Color :
|
||||
set(c):
|
||||
color = c
|
||||
if $Polygon2D != null:
|
||||
$Polygon2D.color = c
|
||||
|
||||
func _init() -> void:
|
||||
name = "Brick"
|
||||
var hits : int = 1
|
||||
var value : int = 100
|
||||
var original_color : Color = Color.WHITE
|
||||
var my_type : int = NORMAL
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
@@ -24,14 +24,47 @@ func hit() -> void:
|
||||
if hits <= 0:
|
||||
return
|
||||
hits -= 1
|
||||
var tween = create_tween()
|
||||
$Polygon2D.color = Color(1, 1, 1)
|
||||
tween.tween_property($Polygon2D, "color", color, 0.25)
|
||||
tween.tween_callback(_hitfade_done)
|
||||
if hits <= 0:
|
||||
collision_layer = 0
|
||||
if my_type == INVULNERABLE:
|
||||
hits = 2
|
||||
visible = false
|
||||
get_tree().create_timer(5).timeout.connect(_show_block)
|
||||
return
|
||||
brick_destroyed.emit(self)
|
||||
|
||||
func _hitfade_done() -> void:
|
||||
if hits <= 0:
|
||||
get_parent().remove_child(self)
|
||||
queue_free()
|
||||
else:
|
||||
var tween = create_tween()
|
||||
$TextureRect.modulate = Color(1, 1, 1)
|
||||
tween.tween_property($TextureRect, "modulate", original_color, 0.25)
|
||||
|
||||
func _show_block() -> void:
|
||||
$TextureRect.modulate = Color(1, 1, 1)
|
||||
var tween = create_tween()
|
||||
tween.tween_property($TextureRect, "modulate", original_color, 0.25)
|
||||
visible = true
|
||||
collision_layer = 1
|
||||
|
||||
|
||||
func type(base : int, color : Color) -> void:
|
||||
my_type = base
|
||||
original_color = color
|
||||
match base:
|
||||
NORMAL:
|
||||
$TextureRect.texture = load("res://Brick/BaseBrick.png")
|
||||
$TextureRect.modulate = color
|
||||
hits = 1
|
||||
value = 100
|
||||
SHINY:
|
||||
$TextureRect.texture = load("res://Brick/ShinyBrick.png")
|
||||
$TextureRect.modulate = color
|
||||
hits = 2
|
||||
value = 200
|
||||
INVULNERABLE:
|
||||
$TextureRect.texture = load("res://Brick/InvulBrick.png")
|
||||
$TextureRect.modulate = color
|
||||
hits = 2
|
||||
value = 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user