because of viewport weirdness had to completely redo the main game scene

updated physics layer names
updated all existing physics body layers
sticky cameras now work, showing a remote camera feed before self destructing
master
Zachary Epps 4 years ago
parent 5eae948ebf
commit 3711c50bff
  1. 6
      project.godot
  2. 82
      scenes/1CamWorld.tscn
  3. 223
      scenes/CombinedWorld.tscn
  4. 144
      scenes/GameWorld.tscn
  5. 24
      scenes/InGameHUD.tscn
  6. 37
      scenes/StickyCam.tscn
  7. 4
      scenes/blocker.tscn
  8. 33
      scenes/player.tscn
  9. 10
      scripts/CameraManager.gd
  10. 24
      scripts/NewPlayer.gd
  11. 20
      scripts/Player/PlayerCamera.gd
  12. 18
      scripts/StickyCam.gd

@ -25,6 +25,12 @@ fire=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","
2d_physics/layer_3="player points"
2d_physics/layer_4="camera vision"
2d_physics/layer_5="projectiles"
2d_physics/layer_11="enemies"
2d_physics/layer_15="bullets"
[physics]
2d/thread_model=2
[rendering]

@ -1,82 +0,0 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://images/wall.png" type="Texture" id=1]
[ext_resource path="res://scenes/blocker.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=4]
[node name="world" type="Node2D" index="0"]
__meta__ = {
"_edit_horizontal_guides_": [ ],
"_edit_vertical_guides_": [ ]
}
[node name="BG" type="Sprite" parent="." index="0"]
self_modulate = Color( 0.472656, 0.273254, 0.273254, 1 )
position = Vector2( 296.637, 200.305 )
scale = Vector2( 10.2699, 7.25954 )
texture = ExtResource( 1 )
[node name="BulletHolder" type="Node2D" parent="." index="1"]
scale = Vector2( 1, 1 )
[node name="Walls" type="Node2D" parent="." index="2"]
scale = Vector2( 1, 1 )
[node name="blocker3" parent="Walls" index="0" instance=ExtResource( 2 )]
position = Vector2( 229.243, 60.4224 )
scale = Vector2( 4.1055, 0.320292 )
collision_layer = 2
collision_mask = 1
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker4" parent="Walls" index="1" instance=ExtResource( 2 )]
position = Vector2( 229.243, 210.849 )
scale = Vector2( 4.1055, 0.320292 )
collision_layer = 2
collision_mask = 1
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker5" parent="Walls" index="2" instance=ExtResource( 2 )]
position = Vector2( 102.655, 142.244 )
rotation = 1.5708
scale = Vector2( 4.1055, 0.320292 )
collision_layer = 2
collision_mask = 1
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker6" parent="Walls" index="3" instance=ExtResource( 2 )]
position = Vector2( 358.349, 142.244 )
rotation = 1.5708
scale = Vector2( 4.1055, 0.320292 )
collision_layer = 2
collision_mask = 1
_sections_unfolded = [ "Collision", "Transform" ]
[node name="player" parent="." index="3" instance=ExtResource( 3 )]
position = Vector2( 230.081, 135.338 )
[node name="blocker" parent="." index="4" instance=ExtResource( 2 )]
position = Vector2( 194.043, 131.413 )
scale = Vector2( 0.320292, 0.320292 )
[node name="blocker2" parent="." index="5" instance=ExtResource( 2 )]
position = Vector2( 171.298, 161.534 )
scale = Vector2( 0.320292, 0.320292 )
[node name="Camera" parent="." index="6" instance=ExtResource( 4 )]
position = Vector2( 182.58, 101.129 )

@ -0,0 +1,223 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://scripts/CameraManager.gd" type="Script" id=1]
[ext_resource path="res://scenes/InGameHUD.tscn" type="PackedScene" id=2]
[ext_resource path="res://default_env.tres" type="Environment" id=3]
[ext_resource path="res://scripts/Player/PlayerCamera.gd" type="Script" id=4]
[ext_resource path="res://scenes/GameWorld.tscn" type="PackedScene" id=5]
[sub_resource type="World" id=1]
environment = ExtResource( 3 )
fallback_environment = ExtResource( 3 )
[node name="Game" type="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 1 )
__meta__ = {
"_edit_horizontal_guides_": [ ],
"_edit_vertical_guides_": [ ]
}
[node name="InGameHUD" parent="." index="0" instance=ExtResource( 2 )]
scale = Vector2( 1, 1 )
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
[node name="PlayerViewport" type="ViewportContainer" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
stretch = true
stretch_shrink = 1
_sections_unfolded = [ "Grow Direction", "Size Flags" ]
[node name="MainGame" type="Viewport" parent="PlayerViewport" index="0"]
arvr = false
size = Vector2( 1023, 599 )
own_world = true
world = SubResource( 1 )
transparent_bg = false
msaa = 1
hdr = true
disable_3d = false
usage = 0
debug_draw = 0
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 3
audio_listener_enable_2d = true
audio_listener_enable_3d = false
physics_object_picking = true
gui_disable_input = false
gui_snap_controls_to_pixels = true
shadow_atlas_size = 0
shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
_sections_unfolded = [ "Render Target", "Rendering" ]
[node name="PlayerCam" type="Camera2D" parent="PlayerViewport/MainGame" index="0"]
anchor_mode = 1
rotating = false
current = true
zoom = Vector2( 0.25, 0.25 )
limit_left = -2147483647
limit_top = -2147483647
limit_right = 2147483647
limit_bottom = 2147483647
limit_smoothed = true
drag_margin_h_enabled = true
drag_margin_v_enabled = true
smoothing_enabled = true
smoothing_speed = 5.0
offset_v = 0.0
offset_h = 0.0
drag_margin_left = 0.01
drag_margin_top = 0.01
drag_margin_right = 0.01
drag_margin_bottom = 0.01
editor_draw_screen = true
editor_draw_limits = false
editor_draw_drag_margin = false
script = ExtResource( 4 )
_sections_unfolded = [ "Smoothing" ]
Stationary = false
[node name="World" parent="PlayerViewport/MainGame" index="1" instance=ExtResource( 5 )]
[node name="Container" type="Container" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 52.0
margin_top = 403.0
margin_right = 293.0
margin_bottom = 569.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
_sections_unfolded = [ "Rect" ]
[node name="RemoteCamera" type="ViewportContainer" parent="Container" index="0"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 1.0
anchor_right = 0.0
anchor_bottom = 1.0
margin_top = -166.0
margin_right = 241.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
stretch = true
stretch_shrink = 1
_sections_unfolded = [ "Rect", "Visibility" ]
[node name="ColorRect" type="ColorRect" parent="Container/RemoteCamera" index="0"]
show_behind_parent = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -5.0
margin_top = -4.0
margin_right = 247.0
margin_bottom = 169.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
color = Color( 1, 1, 1, 1 )
_sections_unfolded = [ "Visibility" ]
[node name="Viewport" type="Viewport" parent="Container/RemoteCamera" index="1"]
arvr = false
size = Vector2( 240, 165 )
own_world = false
world = null
transparent_bg = false
msaa = 0
hdr = true
disable_3d = true
usage = 0
debug_draw = 0
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 0
audio_listener_enable_2d = false
audio_listener_enable_3d = false
physics_object_picking = false
gui_disable_input = false
gui_snap_controls_to_pixels = false
shadow_atlas_size = 0
shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
[node name="StickyCamFeed" type="Camera2D" parent="Container/RemoteCamera/Viewport" index="0"]
scale = Vector2( 1, 1 )
anchor_mode = 0
rotating = false
current = true
zoom = Vector2( 0.1, 0.1 )
limit_left = -10000000
limit_top = -10000000
limit_right = 10000000
limit_bottom = 10000000
limit_smoothed = false
drag_margin_h_enabled = false
drag_margin_v_enabled = false
smoothing_enabled = false
smoothing_speed = 5.0
offset_v = 0.0
offset_h = 0.0
drag_margin_left = 0.2
drag_margin_top = 0.2
drag_margin_right = 0.2
drag_margin_bottom = 0.2
editor_draw_screen = true
editor_draw_limits = false
editor_draw_drag_margin = false
script = ExtResource( 4 )
_sections_unfolded = [ "Offset" ]
Stationary = true

@ -0,0 +1,144 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://images/wall.png" type="Texture" id=1]
[ext_resource path="res://scenes/blocker.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=3]
[ext_resource path="res://scripts/NewPlayer.gd" type="Script" id=4]
[ext_resource path="res://scenes/StickyCam.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/NewNewCamera.gd" type="Script" id=7]
[node name="World" type="Node2D"]
editor/display_folded = true
[node name="BG" type="Sprite" parent="." index="0"]
self_modulate = Color( 0.472656, 0.273254, 0.273254, 1 )
position = Vector2( 296.637, 200.305 )
scale = Vector2( 10.2699, 7.25954 )
texture = ExtResource( 1 )
[node name="BulletHolder" type="Node2D" parent="." index="1"]
scale = Vector2( 1, 1 )
[node name="Walls" type="Node2D" parent="." index="2"]
editor/display_folded = true
scale = Vector2( 1, 1 )
[node name="blocker3" type="StaticBody2D" parent="Walls" index="0" instance=ExtResource( 2 )]
position = Vector2( 229.243, 60.4224 )
scale = Vector2( 4.1055, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker4" type="StaticBody2D" parent="Walls" index="1" instance=ExtResource( 2 )]
position = Vector2( 229.243, 210.849 )
scale = Vector2( 4.1055, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker5" type="StaticBody2D" parent="Walls" index="2" instance=ExtResource( 2 )]
position = Vector2( 102.655, 142.244 )
rotation = 1.5708
scale = Vector2( 4.1055, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision", "Transform" ]
[node name="blocker6" type="StaticBody2D" parent="Walls" index="3" instance=ExtResource( 2 )]
position = Vector2( 358.349, 142.244 )
rotation = 1.5708
scale = Vector2( 4.1055, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision", "Transform" ]
[node name="player" type="KinematicBody2D" parent="." index="3" groups=[
"player",
] instance=ExtResource( 3 )]
position = Vector2( 230.081, 135.338 )
scale = Vector2( 1, 1 )
input_pickable = false
collision_layer = 1
collision_mask = 17410
collision/safe_margin = 0.08
script = ExtResource( 4 )
_sections_unfolded = [ "Collision" ]
__meta__ = {
"_edit_vertical_guides_": [ 7.25047, -7.23965 ]
}
Speed = 10
StickyCam = ExtResource( 5 )
[node name="blocker" type="StaticBody2D" parent="." index="4" instance=ExtResource( 2 )]
position = Vector2( 194.043, 131.413 )
scale = Vector2( 0.320292, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 17425
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision" ]
[node name="blocker2" type="StaticBody2D" parent="." index="5" instance=ExtResource( 2 )]
position = Vector2( 171.298, 161.534 )
scale = Vector2( 0.320292, 0.320292 )
input_pickable = false
collision_layer = 2
collision_mask = 17425
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Collision" ]
[node name="Camera" type="Node2D" parent="." index="6" instance=ExtResource( 6 )]
position = Vector2( 182.58, 101.129 )
scale = Vector2( 1, 1 )
script = ExtResource( 7 )
_sections_unfolded = [ "Transform" ]
__meta__ = {
"_edit_group_": true,
"_edit_horizontal_guides_": [ 62.818, 67.316, 69.1151 ],
"_edit_vertical_guides_": [ -19.0452, 19.2515, -42.0488, 42.1266 ]
}
rotating = false
rotate_degrees = 30
rot_speed = 0.1

@ -0,0 +1,24 @@
[gd_scene format=2]
[node name="InGameHUD" type="CanvasLayer"]
layer = 1
offset = Vector2( 0, 0 )
rotation = 0.0
scale = Vector2( 1, 1 )
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
[node name="Layout" type="Container" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1

@ -12,11 +12,11 @@ radius = 0.456815
input_pickable = false
collision_layer = 16
collision_mask = 3
collision_mask = 2
collision/safe_margin = 0.08
script = ExtResource( 1 )
_sections_unfolded = [ "Collision" ]
Speed = 20
Speed = 15
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
@ -24,33 +24,18 @@ shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="." index="1"]
self_modulate = Color( 0.476059, 1, 0.858467, 1 )
scale = Vector2( 0.01, 0.01 )
texture = ExtResource( 2 )
_sections_unfolded = [ "Transform", "Visibility" ]
[node name="Camera2D" type="Camera2D" parent="." index="2"]
anchor_mode = 1
rotating = false
current = false
zoom = Vector2( 1, 1 )
limit_left = -10000000
limit_top = -10000000
limit_right = 10000000
limit_bottom = 10000000
limit_smoothed = false
drag_margin_h_enabled = true
drag_margin_v_enabled = true
smoothing_enabled = false
smoothing_speed = 5.0
offset_v = 0.0
offset_h = 0.0
drag_margin_left = 0.2
drag_margin_top = 0.2
drag_margin_right = 0.2
drag_margin_bottom = 0.2
editor_draw_screen = true
editor_draw_limits = false
editor_draw_drag_margin = false
[node name="SelfDestruct" type="Timer" parent="." index="2"]
process_mode = 1
wait_time = 25.0
one_shot = true
autostart = false
[connection signal="timeout" from="SelfDestruct" to="." method="_on_SelfDestruct_timeout"]

@ -16,8 +16,8 @@ polygon = PoolVector2Array( 31.9955, -31.9852, 32.0034, 31.9901, -31.9978, 32.00
[node name="blocker" type="StaticBody2D"]
input_pickable = false
collision_layer = 4
collision_mask = 3
collision_layer = 2
collision_mask = 17425
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0

@ -26,7 +26,7 @@ extents = Vector2( 0.803516, 0.825516 )
input_pickable = false
collision_layer = 1
collision_mask = 18
collision_mask = 17410
collision/safe_margin = 0.08
script = ExtResource( 1 )
_sections_unfolded = [ "Collision" ]
@ -50,33 +50,7 @@ texture = ExtResource( 3 )
shape = SubResource( 2 )
[node name="Camera2D" type="Camera2D" parent="." index="3"]
anchor_mode = 1
rotating = false
current = true
zoom = Vector2( 0.25, 0.25 )
limit_left = -2147483647
limit_top = -2147483647
limit_right = 2147483647
limit_bottom = 2147483647
limit_smoothed = true
drag_margin_h_enabled = true
drag_margin_v_enabled = true
smoothing_enabled = false
smoothing_speed = 5.0
offset_v = 0.0
offset_h = 0.0
drag_margin_left = 0.01
drag_margin_top = 0.01
drag_margin_right = 0.01
drag_margin_bottom = 0.01
editor_draw_screen = true
editor_draw_limits = false
editor_draw_drag_margin = false
_sections_unfolded = [ "Drag Margin", "Editor", "Limit" ]
[node name="Points" type="Node2D" parent="." index="4"]
[node name="Points" type="Node2D" parent="." index="3"]
editor/display_folded = true
@ -179,13 +153,12 @@ _sections_unfolded = [ "Collision", "Transform" ]
shape = SubResource( 3 )
[node name="FirePoint" type="Node2D" parent="." index="5"]
[node name="FirePoint" type="Node2D" parent="." index="4"]
_sections_unfolded = [ "Transform" ]
[node name="GunPoint" type="Position2D" parent="FirePoint" index="0"]
position = Vector2( 0, -8.28708 )
scale = Vector2( 1, 1 )

@ -0,0 +1,10 @@
extends Node
onready var PlayerViewport = $"PlayerViewport/MainGame"
onready var AuxViewport = $"Container/RemoteCamera/Viewport"
onready var PlayerCam = $"PlayerViewport/MainGame/PlayerCam"
func _ready():
AuxViewport.world_2d = PlayerViewport.world_2d
PlayerCam.target = get_tree().get_nodes_in_group("player")[0]

@ -14,12 +14,13 @@ onready var BulletParent = get_tree().root.find_node("BulletHolder", true, false
onready var GunEnd = get_node("FirePoint/GunPoint")
onready var Gun = GunEnd.get_node("..")
var Velocity = Vector2()
var CurrentDirection = UP
func _process(delta):
# if we set up velocity to be 0 then we stop as soon as the player
# stops giving input
var velocity = Vector2()
var vel = Vector2()
# an action is defined in Project->Project Settings->Input Map
# it allows us to set up multiple keys to strings so we don't
@ -29,35 +30,40 @@ func _process(delta):
if Input.is_action_pressed('ui_left'):
Gun.set_rotation_degrees(-90)
CurrentDirection = LEFT
velocity.x -= Speed
vel.x -= Speed
elif Input.is_action_pressed('ui_right'):
Gun.set_rotation_degrees(90)
CurrentDirection = RIGHT
velocity.x += Speed
vel.x += Speed
# going up and down
if Input.is_action_pressed('ui_up'):
Gun.set_rotation_degrees(0)
CurrentDirection = UP
velocity.y -= Speed
vel.y -= Speed
elif Input.is_action_pressed('ui_down'):
Gun.set_rotation_degrees(180)
CurrentDirection = DOWN
velocity.y += Speed
vel.y += Speed
# if the player is holding shift, give us a speedboost
if Input.is_key_pressed(KEY_SHIFT):
velocity *= 2
vel *= 2
# if the player presses the fire action, we fire our weapon
if Input.is_action_just_pressed("fire"):
fire()
# and finally, we move and collide!
move_and_slide(velocity)
# and finally, we set our velocity to our calculated one
Velocity = vel
func _physics_process(delta):
# move and collide, based off of our calculated velocity
move_and_slide(Velocity)
# right now this just makes a sticky camera
func fire():
var sc = StickyCam.instance()
sc.set_direction(CurrentDirection)
sc.set_position(to_global(GunEnd.position))
sc.set_position(Gun.to_global(GunEnd.position))
BulletParent.add_child(sc)

@ -0,0 +1,20 @@
extends Camera2D
const DirOffsets = [
Vector2(-7, -8),
Vector2(-17, -8),
Vector2(-11, -4),
Vector2(-11, -13)
]
export var Stationary = false
var target
func _physics_process(delta):
if target != null:
if Stationary:
position = target.position
offset = DirOffsets[target.Direction]
else:
position = target.position

@ -9,8 +9,13 @@ const DirVectors = [
export var Speed = 20
onready var Timer = $SelfDestruct
onready var RemoteViewport = weakref(get_tree().root \
.find_node("StickyCamFeed", true, false))
var Direction setget set_direction
var Collided = false
var Displaying = false
func _enter_tree():
position = $"..".to_local(position)
@ -19,9 +24,20 @@ func _physics_process(delta):
if not Collided:
var col = move_and_collide(DirVectors[Direction] * Speed)
Collided = col != null
elif not Displaying:
Displaying = true
Timer.start()
RemoteViewport.get_ref().target = self
RemoteViewport.get_ref().get_node("../..").show()
func set_position(pos):
position = pos
func set_direction(dir):
Direction = dir
Direction = dir
func _on_SelfDestruct_timeout():
RemoteViewport.get_ref().target = null
RemoteViewport.get_ref().get_node("../..").hide()
queue_free()

Loading…
Cancel
Save