Decoupled player and background scenes

- The player has been decoupled from the world scene and made it's own separate scene that can now be instanced.
- The parallax backgrounds that were apart of the player are also decoupled from the player and made independent each other.

Despite these recent changes, the game continues to function as if it did before the decoupling.
This commit is contained in:
Anthony Foxclaw 2020-06-26 18:28:15 -04:00
parent e9d4432937
commit 6ce7d58163
4 changed files with 205 additions and 187 deletions

View file

@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Backgrounds/bkMountains.png" type="Texture" id=1]
[node name="Mountains" type="ParallaxBackground"]
[node name="ParallaxLayer" type="ParallaxLayer" parent="."]
scale = Vector2( 0.75, 0.75 )
motion_scale = Vector2( 0.09, 0.07 )
motion_offset = Vector2( 0, -90 )
motion_mirroring = Vector2( 240, 0 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="bk_mountain" type="Sprite" parent="ParallaxLayer"]
texture = ExtResource( 1 )
centered = false
__meta__ = {
"_edit_lock_": true
}
[node name="bk_mountain2" type="Sprite" parent="ParallaxLayer"]
texture = ExtResource( 1 )
centered = false
offset = Vector2( 240, 0 )
__meta__ = {
"_edit_lock_": true
}

125
world_scenes/Player.tscn Normal file
View file

@ -0,0 +1,125 @@
[gd_scene load_steps=40 format=2]
[ext_resource path="res://Sprites/polo_sprites/poloright_0.png" type="Texture" id=3]
[ext_resource path="res://Sprites/polo_sprites/poloright_2.png" type="Texture" id=4]
[ext_resource path="res://Sprites/polo_sprites/polorightdown_0.png" type="Texture" id=5]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_9.png" type="Texture" id=6]
[ext_resource path="res://Sprites/polo_sprites/polorightup_0.png" type="Texture" id=7]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_8.png" type="Texture" id=8]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_10.png" type="Texture" id=9]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_3.png" type="Texture" id=10]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_1.png" type="Texture" id=11]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_13.png" type="Texture" id=12]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_7.png" type="Texture" id=13]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_0.png" type="Texture" id=14]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_3.png" type="Texture" id=15]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_2.png" type="Texture" id=16]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_3.png" type="Texture" id=17]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_9.png" type="Texture" id=18]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_6.png" type="Texture" id=19]
[ext_resource path="res://Sounds/snd_jump2.wav" type="AudioStream" id=20]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_6.png" type="Texture" id=21]
[ext_resource path="res://Sounds/snd_respawn.wav" type="AudioStream" id=22]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_2.png" type="Texture" id=23]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_8.png" type="Texture" id=24]
[ext_resource path="res://scripts/player.gd" type="Script" id=25]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_12.png" type="Texture" id=26]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_11.png" type="Texture" id=27]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_5.png" type="Texture" id=28]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_4.png" type="Texture" id=29]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_4.png" type="Texture" id=30]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_5.png" type="Texture" id=31]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_7.png" type="Texture" id=32]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_0.png" type="Texture" id=33]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_1.png" type="Texture" id=34]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_14.png" type="Texture" id=35]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_2.png" type="Texture" id=36]
[ext_resource path="res://Sprites/polo_sprites/poloright_1.png" type="Texture" id=37]
[ext_resource path="res://Sprites/polo_sprites/poloright_3.png" type="Texture" id=38]
[ext_resource path="res://misc/fonts/playertext.tres" type="DynamicFont" id=39]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 33 ), ExtResource( 23 ), ExtResource( 15 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ) ],
"loop": true,
"name": "Idle",
"speed": 20.0
}, {
"frames": [ ExtResource( 14 ), ExtResource( 11 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 29 ), ExtResource( 31 ), ExtResource( 19 ), ExtResource( 13 ), ExtResource( 24 ), ExtResource( 6 ) ],
"loop": false,
"name": "Spawn",
"speed": 5.0
}, {
"frames": [ ExtResource( 5 ) ],
"loop": true,
"name": "Fall",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ), ExtResource( 37 ), ExtResource( 4 ), ExtResource( 38 ) ],
"loop": true,
"name": "Run",
"speed": 20.0
}, {
"frames": [ ExtResource( 7 ) ],
"loop": true,
"name": "Jump",
"speed": 5.0
}, {
"frames": [ ExtResource( 9 ), ExtResource( 27 ), ExtResource( 26 ), ExtResource( 12 ), ExtResource( 35 ), ExtResource( 34 ), ExtResource( 36 ), ExtResource( 10 ), ExtResource( 30 ), ExtResource( 28 ), ExtResource( 21 ), ExtResource( 32 ), ExtResource( 8 ), ExtResource( 18 ) ],
"loop": true,
"name": "Warp",
"speed": 20.0
} ]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 5.0126, 5.32944 )
[node name="Player" type="KinematicBody2D"]
script = ExtResource( 25 )
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="."]
margin_left = -25.041
margin_top = -16.584
margin_right = 25.959
margin_bottom = -5.58401
custom_fonts/font = ExtResource( 39 )
text = "p1"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="AnimatedSprite" parent="."]
frames = SubResource( 1 )
animation = "Spawn"
frame = 9
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0.128571, 0.706848 )
shape = SubResource( 2 )
one_way_collision_margin = 0.0
[node name="Camera2D" type="Camera2D" parent="."]
current = true
zoom = Vector2( 0.5, 0.5 )
smoothing_speed = 2.0
drag_margin_left = 0.01
drag_margin_top = 0.05
drag_margin_right = 0.01
drag_margin_bottom = 0.05
editor_draw_limits = true
[node name="SndJump" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 20 )
volume_db = -25.0
pitch_scale = 0.8
mix_target = 2
[node name="SndSpawn" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 22 )
volume_db = -15.0
mix_target = 2

42
world_scenes/Stars.tscn Normal file
View file

@ -0,0 +1,42 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Backgrounds/bk_clouds.png" type="Texture" id=1]
[node name="Stars" type="ParallaxBackground"]
[node name="ColorRect" type="ColorRect" parent="."]
margin_left = -58.2606
margin_top = -48.236
margin_right = 1861.74
margin_bottom = 503.764
color = Color( 0.137255, 0.152941, 0.262745, 1 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="ParallaxLayer" type="ParallaxLayer" parent="."]
scale = Vector2( 0.5, 0.5 )
motion_scale = Vector2( 0.02, 0.01 )
motion_offset = Vector2( 200, -100 )
motion_mirroring = Vector2( 480, 0 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="bk_clouds" type="Sprite" parent="ParallaxLayer"]
texture = ExtResource( 1 )
centered = false
offset = Vector2( 0, -16 )
__meta__ = {
"_edit_lock_": true
}
[node name="bk_clouds2" type="Sprite" parent="ParallaxLayer"]
texture = ExtResource( 1 )
centered = false
offset = Vector2( 240, -16 )
__meta__ = {
"_edit_lock_": true
}

View file

@ -1,84 +1,12 @@
[gd_scene load_steps=46 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Sounds/3dgalax.ogg" type="AudioStream" id=1]
[ext_resource path="res://Sprites/polo_sprites/polorightdown_0.png" type="Texture" id=2]
[ext_resource path="res://Backgrounds/bkMountains.png" type="Texture" id=3]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_1.png" type="Texture" id=4]
[ext_resource path="res://Sprites/polo_sprites/poloright_2.png" type="Texture" id=5]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_14.png" type="Texture" id=6]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_2.png" type="Texture" id=7]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_9.png" type="Texture" id=8]
[ext_resource path="res://Sprites/polo_sprites/polorightup_0.png" type="Texture" id=9]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_8.png" type="Texture" id=10]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_8.png" type="Texture" id=11]
[ext_resource path="res://Sounds/snd_respawn.wav" type="AudioStream" id=12]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_6.png" type="Texture" id=13]
[ext_resource path="res://Sprites/polo_sprites/poloright_0.png" type="Texture" id=14]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_7.png" type="Texture" id=15]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_1.png" type="Texture" id=16]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_0.png" type="Texture" id=17]
[ext_resource path="res://Sprites/polo_sprites/poloright_1.png" type="Texture" id=18]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_10.png" type="Texture" id=19]
[ext_resource path="res://Sprites/polo_sprites/poloright_3.png" type="Texture" id=20]
[ext_resource path="res://Backgrounds/bk_clouds.png" type="Texture" id=21]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_5.png" type="Texture" id=22]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_7.png" type="Texture" id=23]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_0.png" type="Texture" id=24]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_3.png" type="Texture" id=25]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_13.png" type="Texture" id=26]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_3.png" type="Texture" id=27]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_2.png" type="Texture" id=28]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_3.png" type="Texture" id=29]
[ext_resource path="res://Sounds/snd_jump2.wav" type="AudioStream" id=30]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_9.png" type="Texture" id=31]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_6.png" type="Texture" id=32]
[ext_resource path="res://Sprites/polo_sprites/Idle/polo_r_blink_2.png" type="Texture" id=33]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_12.png" type="Texture" id=34]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_11.png" type="Texture" id=35]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_5.png" type="Texture" id=36]
[ext_resource path="res://Sprites/polo_sprites/Spawn/spr_poloSpawn_4.png" type="Texture" id=37]
[ext_resource path="res://Sprites/polo_sprites/Warp/polowarp_4.png" type="Texture" id=38]
[ext_resource path="res://world_scenes/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://world_scenes/Mountains.tscn" type="PackedScene" id=3]
[ext_resource path="res://world_scenes/Stars.tscn" type="PackedScene" id=4]
[ext_resource path="res://tilsets/tileset_data/ForestTileset.tres" type="TileSet" id=39]
[ext_resource path="res://tilsets/tileset_data/Details_NF.tres" type="TileSet" id=40]
[ext_resource path="res://tilsets/tileset_data/DecorTileset.tres" type="TileSet" id=41]
[ext_resource path="res://scripts/player.gd" type="Script" id=42]
[ext_resource path="res://misc/fonts/playertext.tres" type="DynamicFont" id=43]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 9 ) ],
"loop": true,
"name": "Jump",
"speed": 5.0
}, {
"frames": [ ExtResource( 14 ), ExtResource( 18 ), ExtResource( 5 ), ExtResource( 20 ) ],
"loop": true,
"name": "Run",
"speed": 20.0
}, {
"frames": [ ExtResource( 19 ), ExtResource( 35 ), ExtResource( 34 ), ExtResource( 26 ), ExtResource( 6 ), ExtResource( 4 ), ExtResource( 7 ), ExtResource( 25 ), ExtResource( 38 ), ExtResource( 36 ), ExtResource( 32 ), ExtResource( 23 ), ExtResource( 10 ), ExtResource( 31 ) ],
"loop": true,
"name": "Warp",
"speed": 20.0
}, {
"frames": [ ExtResource( 17 ), ExtResource( 16 ), ExtResource( 28 ), ExtResource( 29 ), ExtResource( 37 ), ExtResource( 22 ), ExtResource( 13 ), ExtResource( 15 ), ExtResource( 11 ), ExtResource( 8 ) ],
"loop": false,
"name": "Spawn",
"speed": 5.0
}, {
"frames": [ ExtResource( 24 ), ExtResource( 33 ), ExtResource( 27 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ), ExtResource( 24 ) ],
"loop": true,
"name": "Idle",
"speed": 20.0
}, {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "Fall",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 5.0126, 5.32944 )
[node name="World" type="Node"]
@ -112,116 +40,9 @@ __meta__ = {
"_edit_lock_": true
}
[node name="Player" type="KinematicBody2D" parent="."]
position = Vector2( 257.041, 352.584 )
script = ExtResource( 42 )
[node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( 281.658, 353.565 )
[node name="Label" type="Label" parent="Player"]
margin_left = -25.041
margin_top = -16.584
margin_right = 25.959
margin_bottom = -5.58401
custom_fonts/font = ExtResource( 43 )
text = "p1"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Stars" parent="." instance=ExtResource( 4 )]
[node name="Sprite" type="AnimatedSprite" parent="Player"]
frames = SubResource( 1 )
animation = "Spawn"
frame = 9
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
position = Vector2( 0.128571, 0.706848 )
shape = SubResource( 2 )
one_way_collision_margin = 0.0
[node name="Camera2D" type="Camera2D" parent="Player"]
current = true
zoom = Vector2( 0.5, 0.5 )
smoothing_speed = 2.0
drag_margin_left = 0.01
drag_margin_top = 0.05
drag_margin_right = 0.01
drag_margin_bottom = 0.05
editor_draw_limits = true
[node name="Stars" type="ParallaxBackground" parent="Player"]
[node name="ColorRect" type="ColorRect" parent="Player/Stars"]
margin_left = -58.2606
margin_top = -48.236
margin_right = 1861.74
margin_bottom = 503.764
color = Color( 0.137255, 0.152941, 0.262745, 1 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="ParallaxLayer" type="ParallaxLayer" parent="Player/Stars"]
scale = Vector2( 0.5, 0.5 )
motion_scale = Vector2( 0.02, 0.01 )
motion_offset = Vector2( 200, -100 )
motion_mirroring = Vector2( 480, 0 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="bk_clouds" type="Sprite" parent="Player/Stars/ParallaxLayer"]
texture = ExtResource( 21 )
centered = false
offset = Vector2( 0, -16 )
__meta__ = {
"_edit_lock_": true
}
[node name="bk_clouds2" type="Sprite" parent="Player/Stars/ParallaxLayer"]
texture = ExtResource( 21 )
centered = false
offset = Vector2( 240, -16 )
__meta__ = {
"_edit_lock_": true
}
[node name="Mountains" type="ParallaxBackground" parent="Player"]
[node name="ParallaxLayer" type="ParallaxLayer" parent="Player/Mountains"]
scale = Vector2( 0.75, 0.75 )
motion_scale = Vector2( 0.09, 0.07 )
motion_offset = Vector2( 0, -90 )
motion_mirroring = Vector2( 240, 0 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="bk_mountain" type="Sprite" parent="Player/Mountains/ParallaxLayer"]
texture = ExtResource( 3 )
centered = false
__meta__ = {
"_edit_lock_": true
}
[node name="bk_mountain2" type="Sprite" parent="Player/Mountains/ParallaxLayer"]
texture = ExtResource( 3 )
centered = false
offset = Vector2( 240, 0 )
__meta__ = {
"_edit_lock_": true
}
[node name="SndJump" type="AudioStreamPlayer" parent="Player"]
stream = ExtResource( 30 )
volume_db = -25.0
pitch_scale = 0.8
mix_target = 2
[node name="SndSpawn" type="AudioStreamPlayer" parent="Player"]
stream = ExtResource( 12 )
volume_db = -15.0
mix_target = 2
[node name="Mountains" parent="." instance=ExtResource( 3 )]