Fixed spring impact registration, camera tilemap limit
The incoming velocity of bodies going onto the spring is, now saved in a signal connection. The players camera is now limited to the extends of the tilemap. I also experimented on the viewport a bit. It seems like I can't simply swap out the default viewport with my own configured viewport and use it in the editor normally.
This commit is contained in:
parent
40ac349bf1
commit
9cef352fe2
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,4 +24,7 @@ export_presets.cfg
|
|||||||
# Mono-specific ignores
|
# Mono-specific ignores
|
||||||
.mono/
|
.mono/
|
||||||
data_*/
|
data_*/
|
||||||
|
|
||||||
|
# VSCode specific ignores
|
||||||
|
/.vscode
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
|||||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
|||||||
"name": "GDScript Godot",
|
"name": "GDScript Godot",
|
||||||
"type": "godot",
|
"type": "godot",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"project": "C:\\Users\\Jakob F\\Documents\\Godot\\Wumper",
|
"project": "C:\\Users\\Jakob\\Documents\\Godot\\Wumper",
|
||||||
"port": 6007,
|
"port": 6007,
|
||||||
"address": "127.0.0.1",
|
"address": "127.0.0.1",
|
||||||
"launch_game_instance": true,
|
"launch_game_instance": true,
|
||||||
|
|||||||
@ -56,7 +56,7 @@ window/size/width=1920
|
|||||||
window/size/height=1080
|
window/size/height=1080
|
||||||
window/stretch/mode="2d"
|
window/stretch/mode="2d"
|
||||||
window/stretch/aspect="keep"
|
window/stretch/aspect="keep"
|
||||||
window/stretch/shrink=8.0
|
window/stretch/shrink=3.59
|
||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
@ -141,10 +141,12 @@ boost_move={
|
|||||||
quality/intended_usage/framebuffer_allocation=0
|
quality/intended_usage/framebuffer_allocation=0
|
||||||
quality/intended_usage/framebuffer_allocation.mobile=0
|
quality/intended_usage/framebuffer_allocation.mobile=0
|
||||||
2d/snapping/use_gpu_pixel_snap=true
|
2d/snapping/use_gpu_pixel_snap=true
|
||||||
quality/filters/use_nearest_mipmap_filter=true
|
|
||||||
quality/filters/msaa=1
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
quality/2d/use_pixel_snap=false
|
quality/2d/use_pixel_snap=true
|
||||||
environment/2d/use_nvidia_rect_flicker_workaround=true
|
environment/2d/use_nvidia_rect_flicker_workaround=true
|
||||||
environment/stretch/aspect="ignore"
|
environment/stretch/aspect="ignore"
|
||||||
environment/intended_usage/framebuffer_allocation.mobile=0
|
environment/intended_usage/framebuffer_allocation.mobile=0
|
||||||
|
|
||||||
|
[world]
|
||||||
|
|
||||||
|
2d/cell_size=16
|
||||||
|
|||||||
@ -248,6 +248,8 @@ func calculate_wallslide_velocity(
|
|||||||
linear_velocity.y = PhysicsFunc.two_step_euler(
|
linear_velocity.y = PhysicsFunc.two_step_euler(
|
||||||
0, acceleration_force["walljump"].y * -1, mass, delta
|
0, acceleration_force["walljump"].y * -1, mass, delta
|
||||||
)
|
)
|
||||||
|
# TODO this is done 3 times for different states
|
||||||
|
# TODO make air strafe a portionable boost instead of a one time acceleration
|
||||||
elif is_correct_airstrafe_input():
|
elif is_correct_airstrafe_input():
|
||||||
linear_velocity.x = PhysicsFunc.two_step_euler(
|
linear_velocity.x = PhysicsFunc.two_step_euler(
|
||||||
linear_velocity.x,
|
linear_velocity.x,
|
||||||
|
|||||||
@ -23,18 +23,18 @@ polygon = PoolVector2Array( -6.7, -3.273, -2.676, -7.3, 3.939, -7.3, 8, -1.768,
|
|||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
position = Vector2( 80, 0 )
|
position = Vector2( 80, 0 )
|
||||||
current = true
|
current = true
|
||||||
zoom = Vector2( 2, 2 )
|
|
||||||
limit_left = 0
|
limit_left = 0
|
||||||
limit_top = 0
|
limit_top = 0
|
||||||
|
limit_right = 0
|
||||||
|
limit_bottom = 0
|
||||||
limit_smoothed = true
|
limit_smoothed = true
|
||||||
drag_margin_h_enabled = true
|
drag_margin_h_enabled = true
|
||||||
drag_margin_v_enabled = true
|
drag_margin_v_enabled = true
|
||||||
drag_margin_left = 0.08
|
drag_margin_left = 0.08
|
||||||
drag_margin_top = 0.08
|
drag_margin_top = 0.08
|
||||||
drag_margin_right = 0.08
|
drag_margin_right = 0.08
|
||||||
drag_margin_bottom = 0.07
|
drag_margin_bottom = 0.08
|
||||||
editor_draw_limits = true
|
editor_draw_screen = false
|
||||||
editor_draw_drag_margin = true
|
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="ShiftTween" type="Tween" parent="Camera2D"]
|
[node name="ShiftTween" type="Tween" parent="Camera2D"]
|
||||||
|
|||||||
@ -158,11 +158,6 @@ func _enter_state(new_state, old_state):
|
|||||||
# TODO This may be hard to keep track of if many states are added
|
# TODO This may be hard to keep track of if many states are added
|
||||||
if !["run", "walk", "idle"].has(old_state) && parent.is_on_floor():
|
if !["run", "walk", "idle"].has(old_state) && parent.is_on_floor():
|
||||||
emit_signal("got_grounded")
|
emit_signal("got_grounded")
|
||||||
# if (
|
|
||||||
# (old_state == "run" || "walk" || "idle" || "wallslide")
|
|
||||||
# && ! parent.is_on_floor()
|
|
||||||
# ):
|
|
||||||
# emit_signal("got_ungrounded")
|
|
||||||
|
|
||||||
|
|
||||||
func _exit_state(old_state, new_state):
|
func _exit_state(old_state, new_state):
|
||||||
|
|||||||
@ -6,8 +6,22 @@ var camera_x_shift = 80
|
|||||||
onready var prev_camera_pos = get_camera_position()
|
onready var prev_camera_pos = get_camera_position()
|
||||||
onready var tween = $ShiftTween
|
onready var tween = $ShiftTween
|
||||||
|
|
||||||
|
# Gets the camera limits from the tilemap of the level
|
||||||
|
# Requires "TileMap" to be a sibling of blobby
|
||||||
|
func _ready():
|
||||||
|
# TODO Pass Reference to child and do not traverse the tree upwards
|
||||||
|
# This is ok, because it only happens on initialization
|
||||||
|
# But it is also quite fickle
|
||||||
|
var tilemap = get_node("../../TileMap")
|
||||||
|
var rect = tilemap.get_used_rect()
|
||||||
|
var cell_size = tilemap.cell_size
|
||||||
|
# TODO Change camera zoom when level is smaller than camera
|
||||||
|
limit_right = rect.end.x * cell_size.x
|
||||||
|
limit_left = rect.position.x * cell_size.x
|
||||||
|
limit_top = rect.position.y * cell_size.y
|
||||||
|
limit_bottom = rect.end.y * cell_size.y
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
_check_facing()
|
_check_facing()
|
||||||
prev_camera_pos = get_camera_position()
|
prev_camera_pos = get_camera_position()
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,6 @@ onready var original_rotation = rotation
|
|||||||
onready var rotation_speed_divider = 80
|
onready var rotation_speed_divider = 80
|
||||||
# TODO causes oscilation
|
# TODO causes oscilation
|
||||||
onready var min_rotation_speed = deg2rad(0.3)
|
onready var min_rotation_speed = deg2rad(0.3)
|
||||||
# TODO Bug when dying in the wrong state, missing prey instance
|
|
||||||
var prey_ref = weakref(null)
|
var prey_ref = weakref(null)
|
||||||
# Ray that goes from the turret to the target
|
# Ray that goes from the turret to the target
|
||||||
var target_ray
|
var target_ray
|
||||||
@ -33,12 +32,11 @@ func searching():
|
|||||||
# The collider returns not the area or body it hit, but the parent of them
|
# The collider returns not the area or body it hit, but the parent of them
|
||||||
var collider = sightline.get_collider()
|
var collider = sightline.get_collider()
|
||||||
if collider.is_in_group("player"):
|
if collider.is_in_group("player"):
|
||||||
print_debug(is_tracking_prey())
|
|
||||||
prey_ref = weakref(collider)
|
prey_ref = weakref(collider)
|
||||||
print_debug(is_tracking_prey())
|
|
||||||
|
|
||||||
|
|
||||||
# TODO should this stand still?
|
# TODO should this stand still?
|
||||||
|
# TODO Use yield and coroutine instead
|
||||||
func start_locking():
|
func start_locking():
|
||||||
target_ray = RayCast2D.new()
|
target_ray = RayCast2D.new()
|
||||||
add_child(target_ray)
|
add_child(target_ray)
|
||||||
@ -68,12 +66,12 @@ func aiming():
|
|||||||
rotation, original_rotation, original_rotation + angle_of_freedom
|
rotation, original_rotation, original_rotation + angle_of_freedom
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO simplify/split this method
|
|
||||||
func shooting():
|
func shooting():
|
||||||
aiming()
|
aiming()
|
||||||
if sightline.is_colliding():
|
if sightline.is_colliding():
|
||||||
# The collider returns not the area or body it hit, but the parent of them
|
# The collider returns not the area or body it hit, but the parent of them
|
||||||
# TODO Sight could be a cone instead of a ray
|
# TODO Sight should be a cone instead of a ray
|
||||||
|
# This could be done with a permanent target ray and the angle between it and the sightline
|
||||||
var collider = sightline.get_collider()
|
var collider = sightline.get_collider()
|
||||||
if collider.is_in_group("player"):
|
if collider.is_in_group("player"):
|
||||||
sight_lost_timer.stop()
|
sight_lost_timer.stop()
|
||||||
@ -93,7 +91,7 @@ func shooting():
|
|||||||
|
|
||||||
func spawn_projectile():
|
func spawn_projectile():
|
||||||
var b = Bullet.instance()
|
var b = Bullet.instance()
|
||||||
owner.add_child(b)
|
get_parent().add_child(b)
|
||||||
b.set_collision_mask_bit(1, false)
|
b.set_collision_mask_bit(1, false)
|
||||||
b.transform = $Muzzle.global_transform
|
b.transform = $Muzzle.global_transform
|
||||||
|
|
||||||
|
|||||||
@ -75,6 +75,7 @@ func _enter_state(new_state, old_state):
|
|||||||
# TODO Time for returning to 0 degrees is always the same
|
# TODO Time for returning to 0 degrees is always the same
|
||||||
# Implement this using a tween
|
# Implement this using a tween
|
||||||
parent.get_node("FiringRateTimer").stop()
|
parent.get_node("FiringRateTimer").stop()
|
||||||
|
# TODO Go back to the tutorials and look for where to implement the animation queues and triggers
|
||||||
anim_player.play("Turret Returning")
|
anim_player.play("Turret Returning")
|
||||||
anim_player.queue("Turret Rotation")
|
anim_player.queue("Turret Rotation")
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -4,10 +4,11 @@ const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")
|
|||||||
|
|
||||||
var mass = 1
|
var mass = 1
|
||||||
var coupled_mass = mass
|
var coupled_mass = mass
|
||||||
var spring_k = -660
|
var spring_k = -600
|
||||||
var start_y = 0
|
var start_y = 0
|
||||||
var y_velocity = 0
|
var y_velocity = 0
|
||||||
var friction = 0.91
|
var friction = 0.91
|
||||||
|
# TODO Only store velocity coming to the springs orientation
|
||||||
var stored_incoming_velocity = 0
|
var stored_incoming_velocity = 0
|
||||||
var coupled_body = null
|
var coupled_body = null
|
||||||
var shock_ready = true
|
var shock_ready = true
|
||||||
@ -17,19 +18,16 @@ func _ready() -> void:
|
|||||||
start_y = self.position.y
|
start_y = self.position.y
|
||||||
|
|
||||||
|
|
||||||
# TODO extensively playtest to find problems
|
# TODO Limit spring deformation
|
||||||
# TODO Shock doesn't get triggered when doing some smaller jumps
|
|
||||||
# TODO There is a limit to how high you can go(can't repeatedly increase hight)
|
|
||||||
|
|
||||||
|
|
||||||
# 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 _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
if !_body_contact():
|
var bc = _body_contact()
|
||||||
_store_incoming_velocity()
|
if !bc:
|
||||||
shock_ready = true
|
shock_ready = true
|
||||||
if _body_contact() && shock_ready:
|
if bc && shock_ready:
|
||||||
_Kinematic_Body_on_Spring()
|
_Kinematic_Body_on_Spring()
|
||||||
shock_ready = false
|
|
||||||
|
|
||||||
var spring_force = spring_k * (self.position.y - self.start_y)
|
var spring_force = spring_k * (self.position.y - self.start_y)
|
||||||
if coupled_body != null:
|
if coupled_body != null:
|
||||||
@ -48,14 +46,6 @@ func _physics_process(delta: float) -> void:
|
|||||||
self.position.y += y_velocity * delta
|
self.position.y += y_velocity * delta
|
||||||
|
|
||||||
|
|
||||||
func _store_incoming_velocity():
|
|
||||||
var areas: Array = $EnteringVelocityDetector.get_overlapping_areas()
|
|
||||||
for i in range(0, areas.size()):
|
|
||||||
if areas[i].name == "BlobbySkin":
|
|
||||||
if areas[i].get_parent().velocity.y > 0:
|
|
||||||
stored_incoming_velocity = areas[i].get_parent().velocity.y
|
|
||||||
|
|
||||||
|
|
||||||
func _body_contact() -> bool:
|
func _body_contact() -> bool:
|
||||||
var areas: Array = $SpringSkin.get_overlapping_areas()
|
var areas: Array = $SpringSkin.get_overlapping_areas()
|
||||||
for i in range(0, areas.size()):
|
for i in range(0, areas.size()):
|
||||||
@ -74,9 +64,9 @@ func _Kinematic_Body_on_Spring() -> void:
|
|||||||
y_velocity += PhysicsFunc.complete_unelastic_shock(
|
y_velocity += PhysicsFunc.complete_unelastic_shock(
|
||||||
a_velocity, b_velocity, a_mass, b_mass
|
a_velocity, b_velocity, a_mass, b_mass
|
||||||
)
|
)
|
||||||
if sign(coupled_body.velocity.y) > 0:
|
print(y_velocity)
|
||||||
coupled_body.velocity.y = y_velocity
|
|
||||||
stored_incoming_velocity = 0
|
stored_incoming_velocity = 0
|
||||||
|
shock_ready = false
|
||||||
|
|
||||||
|
|
||||||
func _on_SpringSkin_area_exited(_area: Area2D) -> void:
|
func _on_SpringSkin_area_exited(_area: Area2D) -> void:
|
||||||
@ -94,3 +84,9 @@ func _on_SpringSkin_area_exited(_area: Area2D) -> void:
|
|||||||
)
|
)
|
||||||
if coupled_body != null:
|
if coupled_body != null:
|
||||||
coupled_body.velocity.y += kinetic_energy_in_velocity
|
coupled_body.velocity.y += kinetic_energy_in_velocity
|
||||||
|
|
||||||
|
|
||||||
|
func _on_EnteringVelocityDetector_area_entered(area: Area2D) -> void:
|
||||||
|
if area.name == "BlobbySkin":
|
||||||
|
if area.get_parent().velocity.y > 0:
|
||||||
|
stored_incoming_velocity = area.get_parent().velocity.y
|
||||||
|
|||||||
@ -4,13 +4,13 @@
|
|||||||
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 11.6455, 1.51714 )
|
extents = Vector2( 11.6455, 2.10568 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 11.918, 1.57982 )
|
extents = Vector2( 11.918, 1.57982 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
extents = Vector2( 11.7595, 0.755349 )
|
extents = Vector2( 11.7639, 2.06284 )
|
||||||
|
|
||||||
[node name="Spring" type="Node2D"]
|
[node name="Spring" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
@ -24,7 +24,7 @@ collision_layer = 32
|
|||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpringSkin"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpringSkin"]
|
||||||
position = Vector2( 0.0369902, -1.50376 )
|
position = Vector2( 0, -1.27843 )
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="SpringBody" type="KinematicBody2D" parent="."]
|
[node name="SpringBody" type="KinematicBody2D" parent="."]
|
||||||
@ -36,12 +36,13 @@ position = Vector2( 0.00390673, 0 )
|
|||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="EnteringVelocityDetector" type="Area2D" parent="."]
|
[node name="EnteringVelocityDetector" type="Area2D" parent="."]
|
||||||
position = Vector2( 0, -3.99571 )
|
position = Vector2( 0, -3.04889 )
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
collision_mask = 41
|
collision_mask = 41
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnteringVelocityDetector"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnteringVelocityDetector"]
|
||||||
position = Vector2( 0.0106821, 0.748173 )
|
position = Vector2( 0.00390673, -1.07744 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[connection signal="area_exited" from="SpringSkin" to="." method="_on_SpringSkin_area_exited"]
|
[connection signal="area_exited" from="SpringSkin" to="." method="_on_SpringSkin_area_exited"]
|
||||||
|
[connection signal="area_entered" from="EnteringVelocityDetector" to="." method="_on_EnteringVelocityDetector_area_entered"]
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
[gd_scene load_steps=12 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://src/Contraptions/Platform/Spring.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://src/Contraptions/Platform/Spring.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://src/Environment/Background.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/Environment/Background.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://src/Actors/Enemies/Machines/Turret.tscn" type="PackedScene" id=6]
|
|
||||||
[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7]
|
||||||
|
|
||||||
[sub_resource type="NavigationPolygon" id=1]
|
[sub_resource type="NavigationPolygon" id=1]
|
||||||
@ -43,7 +42,7 @@ points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
|
|||||||
} ]
|
} ]
|
||||||
0/z_index = 0
|
0/z_index = 0
|
||||||
|
|
||||||
[node name="LevelTemplate" type="Node2D"]
|
[node name="PlattformsLevel" type="Node2D"]
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_horizontal_guides_": [ 464.0 ],
|
"_edit_horizontal_guides_": [ 464.0 ],
|
||||||
"_edit_vertical_guides_": [ 2880.0 ]
|
"_edit_vertical_guides_": [ 2880.0 ]
|
||||||
@ -71,6 +70,12 @@ position = Vector2( 50.7867, 604.063 )
|
|||||||
position = Vector2( 170, 600.198 )
|
position = Vector2( 170, 600.198 )
|
||||||
scale = Vector2( 1.88002, 1 )
|
scale = Vector2( 1.88002, 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="Spring4/SpringSkin" index="0"]
|
||||||
|
position = Vector2( 0, -2.09229 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="Spring4/EnteringVelocityDetector" index="0"]
|
||||||
|
position = Vector2( 0, -6.14911 )
|
||||||
|
|
||||||
[node name="Track" parent="." instance=ExtResource( 5 )]
|
[node name="Track" parent="." instance=ExtResource( 5 )]
|
||||||
position = Vector2( 291.104, 535.161 )
|
position = Vector2( 291.104, 535.161 )
|
||||||
scale = Vector2( 2.83999, 0.56 )
|
scale = Vector2( 2.83999, 0.56 )
|
||||||
@ -78,10 +83,5 @@ scale = Vector2( 2.83999, 0.56 )
|
|||||||
[node name="KinematicBody2D" parent="Track" index="0"]
|
[node name="KinematicBody2D" parent="Track" index="0"]
|
||||||
position = Vector2( 25.0812, 0 )
|
position = Vector2( 25.0812, 0 )
|
||||||
|
|
||||||
[node name="Turret" parent="." instance=ExtResource( 6 )]
|
|
||||||
position = Vector2( 479, 466 )
|
|
||||||
scale = Vector2( 0.4, 0.4 )
|
|
||||||
|
|
||||||
[editable path="Spring4"]
|
[editable path="Spring4"]
|
||||||
[editable path="Track"]
|
[editable path="Track"]
|
||||||
[editable path="Turret"]
|
|
||||||
|
|||||||
15
src/Levels/Viewport Test Level.gd
Normal file
15
src/Levels/Viewport Test Level.gd
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
onready var level_viewport_container = $ViewportContainer
|
||||||
|
onready var level_viewport = $ViewportContainer/Viewport
|
||||||
|
onready var screen_res = get_viewport().size
|
||||||
|
|
||||||
|
var scaling = Vector2()
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
scaling = screen_res / level_viewport.size
|
||||||
|
print(screen_res)
|
||||||
|
print(level_viewport.size)
|
||||||
|
print(scaling)
|
||||||
|
level_viewport_container.rect_scale *= scaling
|
||||||
19
src/Levels/Viewport Test Level.tscn
Normal file
19
src/Levels/Viewport Test Level.tscn
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/Levels/Viewport Test Level.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="ViewportTestLevel" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="ViewportContainer" type="ViewportContainer" parent="."]
|
||||||
|
margin_right = 1920.0
|
||||||
|
margin_bottom = 1080.0
|
||||||
|
rect_scale = Vector2( 1.0037, 0.999187 )
|
||||||
|
|
||||||
|
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
|
||||||
|
size = Vector2( 1920, 1080 )
|
||||||
|
handle_input_locally = false
|
||||||
|
disable_3d = true
|
||||||
|
usage = 0
|
||||||
|
render_direct_to_screen = true
|
||||||
|
render_target_update_mode = 3
|
||||||
Loading…
Reference in New Issue
Block a user