Camera Guide fixes.

This commit is contained in:
Dustin 2025-04-20 21:35:02 -07:00
parent a0d94d6354
commit ecc4c22fe0
4 changed files with 25 additions and 17 deletions

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=1]
[ext_resource path="res://src/Camera2D.gd" type="Script" id=2]
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/Main.gd" type="Script" id=7]
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
@ -24,6 +25,7 @@ extents = Vector2( 160, 90 )
[node name="Main" type="Node2D"]
script = ExtResource( 7 )
starting_level = ExtResource( 3 )
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]

View File

@ -9,11 +9,18 @@ onready var player_start_position := Vector2(50,50)
onready var current_music_track :AudioStream
##TODO: Main can probably be derived from project properties
onready var main = get_node("/root/Main")
onready var viewport_container = get_node("/root/Main/ViewportContainer") #$ViewportContainer
onready var viewport = get_node("/root/Main/ViewportContainer/Viewport") # $ViewportContainer/Viewport
onready var camera_guide :CameraGuide = get_node("/root/Main/ViewportContainer/Viewport/CameraGuide")
func _ready():
assert(main != null, "LevelInfo: No Main Scene found.")
assert(viewport_container != null, "LevelInfo: No Viewport Container")
assert(viewport != null, "LevelInfo: No Viewport node found.")
assert(camera_guide != null, "LevelInfo: No CameraGuide node found.")
NetworkManager.connect("game_started", self, "_on_game_started")
NetworkManager.connect("game_ended", self, "_on_game_ended")

View File

@ -10,7 +10,7 @@ export var debug_singletons :bool = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
assert(starting_level != null, "Main: starting level not specified.")
# Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@ -6,6 +6,7 @@ export var debug_camera_guide :bool = false
var game_size :Vector2
onready var window_scale :float
onready var viewport = $"%Viewport"
onready var camera_2d = $"%Camera2D"
var _is_tracking :bool = true
@ -14,6 +15,8 @@ func _ready():
game_size = viewport.size
window_scale = (OS.window_size / game_size).x
assert(game_size != Vector2(0,0), str(get_path()) + " : No game_size set.")
assert(camera_2d != null, str(get_path()) + " : No Camera Node Found.")
if debug_camera_guide:
print(get_path(), "\n",
"\tSize:", game_size,
@ -57,21 +60,17 @@ func _physics_process(_delta):
elif !(is_on_wall() or is_on_floor() or is_on_ceiling()) and abs(diff_to.y) > 10:
dir_to = pos.direction_to(player_position)
# UiManager.debug_text = ( UiManager.debug_text +
# # str(PlayerInfo.player_position.snapped(Vector2(0.01,0.01))) +
# "\n" + str(is_on_ceiling()) + str(is_on_floor()) + str(is_on_wall()) +
# "\nPP: {0}, {1}".format({"0":"%7.2f" % PlayerInfo.player_position.x, "1":"%7.2f" % PlayerInfo.player_position.y}) +
# #"\nKB: " + str(global_position.snapped(Vector2(0.01,0.01))) +
# "\nKB: {0}, {1}".format({"0":"%7.2f" % global_position.x, "1":"%7.2f" % global_position.y}) +
# "\nDir to: {0}, {1}".format({"0":"%7.2f" % dir_to.x, "1":"%7.2f" % dir_to.y}) +
# "\nPoint to: {0}, {1}".format({"0":"%7.2f" % diff_to.x, "1":"%7.2f" % diff_to.y})
# #"\nDT: %7.2f" % dist_to
# )
# "Hi, {0} v{version}".format({0:"Godette", "version":"%0.2f" % 3.114})
#"Hi, {0} v{1}".format(["Godette", "3.0"], "{_}")
if debug_camera_guide:
UiManager.debug_text = ( "-Camera Guide-" +
# str(PlayerInfo.player_position.snapped(Vector2(0.01,0.01))) +
"\n" + str(is_on_ceiling()) + str(is_on_floor()) + str(is_on_wall()) +
"\nPP: {0}, {1}".format({"0":"%7.2f" % PlayerInfo.player_position.x, "1":"%7.2f" % PlayerInfo.player_position.y}) +
#"\nKB: " + str(global_position.snapped(Vector2(0.01,0.01))) +
"\nKB: {0}, {1}".format({"0":"%7.2f" % global_position.x, "1":"%7.2f" % global_position.y}) +
"\nDir to: {0}, {1}".format({"0":"%7.2f" % dir_to.x, "1":"%7.2f" % dir_to.y}) +
"\nPoint to: {0}, {1}".format({"0":"%7.2f" % diff_to.x, "1":"%7.2f" % diff_to.y})
#"\nDT: %7.2f" % dist_to
)
move_and_slide(dir_to * 180.0 )
# flip_tracker += delta