forked from team-sg/hero-mark-2
Made autoload and ui folders to clean things up
This commit is contained in:
parent
212b49de56
commit
8cfe971e06
26 changed files with 50 additions and 43 deletions
130
autoloads/debug.gd
Normal file
130
autoloads/debug.gd
Normal file
|
@ -0,0 +1,130 @@
|
|||
extends CanvasLayer
|
||||
|
||||
#Console by hazel
|
||||
#Const
|
||||
const ENTRY_SEQUENCE = ["4", "1", "5"]
|
||||
#Export
|
||||
export var max_lines: int = 10
|
||||
export var opacity: float = 0.5
|
||||
#Onready
|
||||
onready var console = $Console
|
||||
onready var code_label = get_parent().get_node("Main/Control/ViewportContainer/Viewport/CheatLayer/CheatLabel")
|
||||
##Runtime
|
||||
var lines: int = 0
|
||||
var time: float = 0.0
|
||||
var n: int = 0
|
||||
var debug = false
|
||||
var allow_sword = false
|
||||
var moon_jump = false
|
||||
# cheat code entry
|
||||
var entry_index = 0
|
||||
var entry = false
|
||||
var code = ""
|
||||
|
||||
|
||||
func _ready():
|
||||
#Auto do debug when playtesting
|
||||
if not OS.is_debug_build():
|
||||
console.visible = false
|
||||
debug = false
|
||||
else:
|
||||
console.visible = false
|
||||
debug = true
|
||||
$Console/Panel.modulate.a = opacity
|
||||
console.modulate.a = opacity
|
||||
|
||||
func _physics_process(delta):
|
||||
#DEBUG
|
||||
if debug == true && !entry && !entry_index > 0:
|
||||
#Show console
|
||||
if Input.is_action_just_pressed("debug_show"):
|
||||
console.visible = !console.visible
|
||||
#Move player to mouse
|
||||
if Input.is_action_pressed("debug_move_player"):
|
||||
Game.get_map().get_node("Player").position = get_viewport().get_mouse_position()
|
||||
Debug.print(get_viewport().get_mouse_position())
|
||||
#Test room
|
||||
if Input.is_action_just_pressed("debug_testroom"):
|
||||
Game.change_map(load("res://maps/test_room.tscn"))
|
||||
#Debug 1
|
||||
if Input.is_action_just_pressed("debug_1"):
|
||||
Game.change_map(load("res://maps/level_select.tscn"))
|
||||
#Debug 2
|
||||
if Input.is_action_just_pressed("debug_2"):
|
||||
Game.freeze_frame(1.0)
|
||||
|
||||
func print(text):
|
||||
lines += 1
|
||||
if lines > 1:
|
||||
console.text += "\n"
|
||||
if lines > 10:
|
||||
var n = console.text.find("\n")
|
||||
var t = console.text
|
||||
t.erase(0, n+1)
|
||||
lines -= 1
|
||||
console.text = t + str(text)
|
||||
else:
|
||||
console.text += str(text)
|
||||
|
||||
func _on_visible_toggled(button_pressed):
|
||||
if button_pressed:
|
||||
console.visible = true
|
||||
else:
|
||||
console.visible = false
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey && event.is_pressed():
|
||||
var character = OS.get_scancode_string(event.scancode)
|
||||
if character.length() > 1:
|
||||
character = ""
|
||||
|
||||
if entry:
|
||||
if event.scancode == KEY_ENTER:
|
||||
_enter_code()
|
||||
Game.set_deferred("can_pause",true)
|
||||
entry = false
|
||||
code = ""
|
||||
elif event.scancode == KEY_BACKSPACE:
|
||||
code.erase(code.length() - 1, 1)
|
||||
else:
|
||||
code += character
|
||||
code_label.text = code
|
||||
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_star, Game.ac_cheat)
|
||||
Game.can_pause = false
|
||||
|
||||
func _enter_code():
|
||||
match code:
|
||||
"30385":
|
||||
for gold in get_tree().get_nodes_in_group("gold"):
|
||||
var goldsprite = gold.get_node("AnimatedSprite")
|
||||
goldsprite.frames = preload("res://graphics/collectibles/30385_frames.tres")
|
||||
goldsprite.position.y -= 2
|
||||
#goldsprite.material.set_shader_param("palette",load("res://graphics/collectibles/pal_star_green.png"))
|
||||
"1989":
|
||||
for enemy in get_tree().get_nodes_in_group("enemy"):
|
||||
enemy.die()
|
||||
"DGSTEEZY":
|
||||
debug = true
|
||||
"6DOUBLOONS":
|
||||
Debug.print(get_tree().get_nodes_in_group("gold").size())
|
||||
"EVILSBANE":
|
||||
allow_sword = true
|
||||
Input.action_press("sword")
|
||||
"REDFEATHER":
|
||||
moon_jump = true
|
||||
"NIGHTCORE":
|
||||
Engine.time_scale = 10
|
||||
"UPUPANDAWAY":
|
||||
get_tree().call_group("mountain_easter_egg","play","liftoff")
|
||||
"MACOSX":
|
||||
var player = get_tree().get_nodes_in_group("player")[0]
|
||||
Game.instance_node(load("res://objects/environment/beach_ball/beach_ball.tscn"),player.global_position.x,player.global_position.y - 8,Game.get_map())
|
Loading…
Add table
Add a link
Reference in a new issue