forked from team-sg/hero-mark-2
cheat code entry
This commit is contained in:
parent
dcca66620e
commit
349a46b8fa
11 changed files with 50 additions and 8 deletions
37
scripts/code_entry.gd
Normal file
37
scripts/code_entry.gd
Normal file
|
@ -0,0 +1,37 @@
|
|||
extends Node
|
||||
|
||||
const ENTRY_SEQUENCE = ["4", "1", "5"]
|
||||
|
||||
var entry_index = 0
|
||||
var entry = false
|
||||
var code = ""
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey && event.is_pressed():
|
||||
var character = OS.get_scancode_string(event.scancode)
|
||||
|
||||
if entry:
|
||||
if event.scancode == KEY_ENTER:
|
||||
_enter_code()
|
||||
entry = false
|
||||
code = ""
|
||||
else:
|
||||
code += character
|
||||
else:
|
||||
if character == ENTRY_SEQUENCE[entry_index]:
|
||||
entry_index += 1
|
||||
if entry_index >= ENTRY_SEQUENCE.size():
|
||||
entry = true
|
||||
entry_index = 0
|
||||
_on_entry()
|
||||
|
||||
func _on_entry():
|
||||
Game.play_sound(Game.a_die, Game.ac_cheat)
|
||||
|
||||
func _enter_code():
|
||||
match code:
|
||||
"30385":
|
||||
Debug.print("Woohoo crystals!")
|
||||
"1989":
|
||||
for enemy in get_tree().get_nodes_in_group("enemy"):
|
||||
enemy.queue_free()
|
|
@ -26,7 +26,7 @@ func _ready():
|
|||
|
||||
func _physics_process(delta):
|
||||
#DEBUG
|
||||
if debug == true:
|
||||
if debug == true && !CodeEntry.entry && !CodeEntry.entry_index > 0:
|
||||
#Show console
|
||||
if Input.is_action_just_pressed("debug_show"):
|
||||
console.visible = !console.visible
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue