Fixes and tweaks for cameras, main functions, and loading in game scenes.
This commit is contained in:
parent
3ffcf7ca59
commit
94302003d8
|
|
@ -1,9 +1,10 @@
|
||||||
[gd_scene load_steps=10 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=1]
|
[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/Camera2D.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://src/levels/CloneBox.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
||||||
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
|
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
|
||||||
|
|
||||||
|
|
@ -26,6 +27,7 @@ extents = Vector2( 160, 90 )
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
script = ExtResource( 7 )
|
script = ExtResource( 7 )
|
||||||
starting_level = ExtResource( 3 )
|
starting_level = ExtResource( 3 )
|
||||||
|
player_hud = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
||||||
|
|
@ -39,6 +41,7 @@ rect_scale = Vector2( 2, 2 )
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
size = Vector2( 320, 180 )
|
size = Vector2( 320, 180 )
|
||||||
handle_input_locally = false
|
handle_input_locally = false
|
||||||
|
usage = 0
|
||||||
render_target_update_mode = 3
|
render_target_update_mode = 3
|
||||||
|
|
||||||
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ func _on_state_change(old_state_name:String, new_state :State):
|
||||||
## this has been working fine but could cause issues if I assume otherwise.
|
## this has been working fine but could cause issues if I assume otherwise.
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
|
## Confirmed that I do neet to update the current_state with the passed state.
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
if has_method('_on_state_change_' + current_state.name):
|
if has_method('_on_state_change_' + current_state.name):
|
||||||
call('_on_state_change_' + current_state.name)
|
call('_on_state_change_' + current_state.name)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ func _physics_process(delta):
|
||||||
func _on_state_change(old_state_name:String, new_state :State):
|
func _on_state_change(old_state_name:String, new_state :State):
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
|
## Confirmed that I do neet to update the current_state with the passed state.
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
if has_method('_on_state_change_' + current_state.name):
|
if has_method('_on_state_change_' + current_state.name):
|
||||||
call('_on_state_change_' + current_state.name)
|
call('_on_state_change_' + current_state.name)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ func get_climb_shape_location() -> Vector2:
|
||||||
func _on_state_change(old_state_name:String, new_state :State):
|
func _on_state_change(old_state_name:String, new_state :State):
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
|
## Confirmed that I do neet to update the current_state with the passed state.
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
if has_method('_on_state_change_' + current_state.name):
|
if has_method('_on_state_change_' + current_state.name):
|
||||||
call('_on_state_change_' + current_state.name)
|
call('_on_state_change_' + current_state.name)
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,15 @@ remote func load_scene_on_all_clients(_scene :String, _node_path :NodePath, _glo
|
||||||
|
|
||||||
remote func pre_start_game(spawn_points):
|
remote func pre_start_game(spawn_points):
|
||||||
# Change scene.
|
# Change scene.
|
||||||
var world :Node = load("res://src/levels/TestBox.tscn").instance()
|
var _game_starting_level_scene = get_tree().get_root().get_node("/root/Main").starting_level
|
||||||
var ui :Node = load("res://src/ui/HUD.tscn").instance()
|
var _in_game_player_hud = get_tree().get_root().get_node("/root/Main").player_hud
|
||||||
world.set_name("World")
|
#var world :Node = load("res://src/levels/TestBox.tscn").instance()
|
||||||
|
var world :Node = _game_starting_level_scene.instance()
|
||||||
|
#var ui :Node = load("res://src/ui/HUD.tscn").instance()
|
||||||
|
var ui :Node = _in_game_player_hud.instance()
|
||||||
|
|
||||||
|
## No need to name world anymore
|
||||||
|
#world.set_name("World")
|
||||||
world.add_to_group('world')
|
world.add_to_group('world')
|
||||||
ui.add_to_group('world')
|
ui.add_to_group('world')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ extends Camera2D
|
||||||
# var b = "text"
|
# var b = "text"
|
||||||
export var debug_component :bool = false
|
export var debug_component :bool = false
|
||||||
|
|
||||||
var game_size := Vector2(320,180)
|
|
||||||
onready var window_scale :float = (OS.window_size / game_size).x
|
|
||||||
|
|
||||||
onready var actual_cam_pos := global_position
|
onready var actual_cam_pos := global_position
|
||||||
|
|
||||||
export var acceleration := 2
|
export var acceleration := 2
|
||||||
|
|
@ -21,6 +18,7 @@ var _tracking_node :KinematicBody2D
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
_tracking_node = get_node(tracking_node_path)
|
_tracking_node = get_node(tracking_node_path)
|
||||||
|
assert(is_instance_valid(_tracking_node), "Camera2D has no tracking object.")
|
||||||
|
|
||||||
var velocity :float = 0
|
var velocity :float = 0
|
||||||
var tracking_pos := Vector2(0,0)
|
var tracking_pos := Vector2(0,0)
|
||||||
|
|
|
||||||
18
src/Main.gd
18
src/Main.gd
|
|
@ -1,17 +1,31 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
##TODO Would really like to adjust the viewports, cameras, and
|
||||||
|
# overall scale from here.
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
# Declare member variables here. Examples:
|
||||||
# var a = 2
|
# var a = 2
|
||||||
# var b = "text"
|
# var b = "text"
|
||||||
export var starting_level: PackedScene
|
|
||||||
export var debug_singletons :bool = false
|
export var debug_singletons :bool = false
|
||||||
|
|
||||||
|
export var starting_level: PackedScene
|
||||||
|
export var player_hud: PackedScene
|
||||||
|
export var start_screen: PackedScene
|
||||||
|
|
||||||
|
onready var viewport_container = $ViewportContainer
|
||||||
|
onready var viewport = $"%Viewport"
|
||||||
|
|
||||||
|
var game_size :Vector2
|
||||||
|
onready var window_scale :float
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
game_size = viewport.size
|
||||||
|
window_scale = (OS.window_size / game_size).x
|
||||||
assert(starting_level != null, "Main: starting level not specified.")
|
assert(starting_level != null, "Main: starting level not specified.")
|
||||||
|
assert(player_hud != null, "Main: player HUD not specified.")
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ func _ready():
|
||||||
player_data.player_inventory = player_inventory
|
player_data.player_inventory = player_inventory
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
else:
|
else:
|
||||||
|
## puppets cannot get hurt, only network master.
|
||||||
$Hurtbox_Component.hurtbox_entered_function = ''
|
$Hurtbox_Component.hurtbox_entered_function = ''
|
||||||
|
|
||||||
# Set initial player position in world.
|
# Set initial player position in world.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ export var debug_camera_guide :bool = false
|
||||||
var game_size :Vector2
|
var game_size :Vector2
|
||||||
onready var window_scale :float
|
onready var window_scale :float
|
||||||
onready var viewport = $"%Viewport"
|
onready var viewport = $"%Viewport"
|
||||||
onready var camera_2d = $"%Camera2D"
|
## Camera guide doesn't really need to care if there's a camera
|
||||||
|
#onready var camera_2d = $"%Camera2D"
|
||||||
|
|
||||||
var _is_tracking :bool = true
|
var _is_tracking :bool = true
|
||||||
|
|
||||||
|
|
@ -15,7 +16,8 @@ func _ready():
|
||||||
game_size = viewport.size
|
game_size = viewport.size
|
||||||
window_scale = (OS.window_size / game_size).x
|
window_scale = (OS.window_size / game_size).x
|
||||||
assert(game_size != Vector2(0,0), str(get_path()) + " : No game_size set.")
|
assert(game_size != Vector2(0,0), str(get_path()) + " : No game_size set.")
|
||||||
assert(camera_2d != null, str(get_path()) + " : No Camera Node Found.")
|
## Camera guide doesn't really need to care if there's a camera
|
||||||
|
#assert(camera_2d != null, str(get_path()) + " : No Camera Node Found.")
|
||||||
|
|
||||||
if debug_camera_guide:
|
if debug_camera_guide:
|
||||||
print(get_path(), "\n",
|
print(get_path(), "\n",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user