mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-23 07:58:09 +00:00
added the game
This commit is contained in:
33
Scripts/Classes/Blocks/BooOnOffSwitch.gd
Normal file
33
Scripts/Classes/Blocks/BooOnOffSwitch.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends Block
|
||||
|
||||
var active := false
|
||||
|
||||
static var has_hit := false
|
||||
|
||||
func _ready() -> void:
|
||||
can_hit = true
|
||||
has_hit = false
|
||||
|
||||
func on_block_hit() -> void:
|
||||
if can_hit == false or has_hit:
|
||||
return
|
||||
has_hit = true
|
||||
AudioManager.play_sfx("switch", global_position)
|
||||
can_hit = false
|
||||
get_tree().call_group("BooBlocks", "on_switch_hit")
|
||||
await get_tree().create_timer(0.25, false).timeout
|
||||
can_hit = true
|
||||
has_hit = false
|
||||
|
||||
func on_switch_hit() -> void:
|
||||
active = not active
|
||||
if active:
|
||||
$Sprite.play("On")
|
||||
else:
|
||||
$Sprite.play("Off")
|
||||
|
||||
func on_boo_hit() -> void:
|
||||
if active:
|
||||
return
|
||||
AudioManager.play_global_sfx("switch")
|
||||
get_tree().call_group("BooBlocks", "on_switch_hit")
|
Reference in New Issue
Block a user