Optimized scene tree and debugged some area detection

This commit is contained in:
VoidTwo
2021-11-30 23:06:42 -06:00
parent 34f7407d6a
commit 34d4e0454e
27 changed files with 380 additions and 481 deletions

View File

@@ -1,27 +0,0 @@
extends Control
export (int) var minutes =0
export (int) var seconds = 0
var dsec = 0
func _physics_process(delta: float) -> void:
if seconds > 0 and dsec <= 0:
seconds -=1
dsec = 10
if minutes > 0 and seconds <= 0:
minutes -= 1
seconds = 60
if seconds >= 10:
$sec.set_text(str(seconds))
else:
$sec.set_text("0"+str(seconds))
if dsec >=10:
$dsec.set_text(str(dsec))
else:
$dsec.set_text("0" + str(dsec))
func _on_Timer_timeout() -> void:
dsec-=1
pass # Replace with function body.

View File

@@ -1,10 +1,9 @@
extends Area2D
func _ready() -> void:
pass # Replace with function body.
signal coin_collected
func _on_Node2D_body_entered(body: Node) -> void:
if body.get_name() == "Player":
queue_free() # Replace with function body.
if body.get_name() == 'Player':
emit_signal('coin_collected')
queue_free()

View File

@@ -1,20 +1,19 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Sprites/Assets/coin.png" type="Texture" id=1]
[ext_resource path="res://Levels/Interactives/coin.gd" type="Script" id=2]
[ext_resource path="res://Levels/Interactives/Coin.gd" type="Script" id=1]
[ext_resource path="res://Sprites/Assets/coin.png" type="Texture" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 6.38067
[node name="coin" type="Area2D"]
script = ExtResource( 2 )
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 28.3217, 41.6257 )
texture = ExtResource( 1 )
position = Vector2( 0, 1 )
texture = ExtResource( 2 )
[node name="coin" type="CollisionShape2D" parent="."]
position = Vector2( 28.4389, 40.6703 )
shape = SubResource( 1 )
[connection signal="body_entered" from="." to="." method="_on_Node2D_body_entered"]

View File

@@ -1,6 +1,6 @@
extends Node2D
onready var coin = preload("res://Levels/Interactives/coin.tscn")
onready var coin = preload("res://Levels/Interactives/Coin.tscn")
#onready var coin_container = get_node("YSort/coin_container")
#have event for timer to run out
@@ -10,21 +10,15 @@ var screensize
var score = 0
func _ready() -> void:
$YSort/Player.load_hud($HUD)
$YSort/Player.position = get_viewport_rect().size / 2
randomize()
screensize = get_viewport_rect().size
set_process(true)
spawn_coins(5)
return
$YSort/Player.load_hud($HUD)
screensize = get_viewport_rect().size
spawn_coins(5)
return
func _process(delta):
if $AudioStreamPlayer.playing == false:
$AudioStreamPlayer.play()
func spawn_coins(num):
for i in range(num):
var g = coin.instance()
$'YSort/coin_container'.add_child(g)
#g.set_pos(Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40)))
g.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))
for i in range(num):
var g = coin.instance()
$'coin_container'.add_child(g)
#g.set_pos(Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40)))
g.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))

View File

@@ -1,20 +1,16 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Levels/Level 3.gd" type="Script" id=2]
[ext_resource path="res://Resources/tileSet.tres" type="TileSet" id=3]
[ext_resource path="res://Enemies/snowmen_enemy.tscn" type="PackedScene" id=4]
[ext_resource path="res://Sprites/Assets/forestTreeBig.png" type="Texture" id=5]
[ext_resource path="res://Enemies/snowmen_enemy_blue.tscn" type="PackedScene" id=6]
[ext_resource path="res://Enemies/snowmen_enemy_blue.gd" type="Script" id=7]
[ext_resource path="res://Levels/Interactives/Countdown.gd" type="Script" id=8]
[ext_resource path="res://Enemies/Snowman Enemy.tscn" type="PackedScene" id=4]
[ext_resource path="res://Levels/Objects/Tree.tscn" type="PackedScene" id=5]
[ext_resource path="res://Enemies/Snowman Enemy Blue.tscn" type="PackedScene" id=6]
[ext_resource path="res://Enemies/Snowman Enemy Blue.gd" type="Script" id=7]
[ext_resource path="res://GUI/HUD.tscn" type="PackedScene" id=9]
[ext_resource path="res://GUI/Pause Screen.tscn" type="PackedScene" id=10]
[ext_resource path="res://Music/Level_3.mp3" type="AudioStream" id=11]
[sub_resource type="CapsuleShape2D" id=1]
radius = 9.0515
height = 0.0
[ext_resource path="res://GUI/Countdown Timer.tscn" type="PackedScene" id=12]
[sub_resource type="SegmentShape2D" id=2]
a = Vector2( 3.84175, -99.0063 )
@@ -28,7 +24,7 @@ b = Vector2( 309.792, 29.724 )
a = Vector2( 369.611, 141.974 )
b = Vector2( 49.76, 142.724 )
[node name="World" type="Node2D"]
[node name="Level 3" type="Node2D"]
script = ExtResource( 2 )
[node name="TileMap" type="TileMap" parent="."]
@@ -42,191 +38,93 @@ tile_data = PoolIntArray( 0, 0, 65537, 1, 0, 65538, 2, 0, 65538, 3, 0, 65538, 4,
[node name="YSort" type="YSort" parent="."]
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 20, 26 )
position = Vector2( 120, 60 )
ACCELERATION = 500
FRICTION = 100
[node name="tree6" type="StaticBody2D" parent="YSort"]
[node name="Tree 1" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 35.7089, 147.785 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree6"]
position = Vector2( 71.8801, 91.6645 )
shape = SubResource( 1 )
[node name="Tree 2" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 59.3969, 96.8735 )
[node name="forestTreeBig2" type="Sprite" parent="YSort/tree6"]
position = Vector2( 72.0738, 92.0067 )
texture = ExtResource( 5 )
[node name="Tree 3" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 74.5997, 42.7799 )
[node name="blue_snowman2" parent="YSort" groups=[
"enemies",
] instance=ExtResource( 6 )]
[node name="Tree 4" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 153.442, 160.867 )
[node name="Tree 5" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 155.563, 93.6916 )
[node name="Tree 6" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 211.071, 43.1335 )
[node name="Tree 7" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 262.336, 86.2669 )
[node name="Tree 8" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 231.224, 137.179 )
[node name="Enemies" type="YSort" parent="YSort"]
[node name="Snowman 1" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 4 )]
position = Vector2( 190.316, 146.569 )
[node name="Snowman 2" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 4 )]
position = Vector2( 67.4812, 153.194 )
[node name="Blue Snowman 1" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 6 )]
position = Vector2( 259.084, 49.7897 )
script = ExtResource( 7 )
[node name="blue_snowman" parent="YSort" groups=[
"enemies",
] instance=ExtResource( 6 )]
[node name="Blue Snowman 2" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 6 )]
position = Vector2( 261.1, 142.19 )
script = ExtResource( 7 )
[node name="snowmen_enemy2" parent="YSort" groups=[
"enemies",
] instance=ExtResource( 4 )]
position = Vector2( 190.316, 146.569 )
[node name="snowmen_enemy" parent="YSort" groups=[
"enemies",
] instance=ExtResource( 4 )]
position = Vector2( 67.4812, 153.194 )
[node name="tree5" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree5"]
position = Vector2( 265.396, 85.2148 )
shape = SubResource( 1 )
[node name="forestTreeBig" type="Sprite" parent="YSort/tree5"]
position = Vector2( 265.238, 84.0492 )
texture = ExtResource( 5 )
[node name="tree8" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree8"]
position = Vector2( 85.1921, 39.1628 )
shape = SubResource( 1 )
[node name="forestTreeBig5" type="Sprite" parent="YSort/tree8"]
position = Vector2( 84.7548, 38.2794 )
texture = ExtResource( 5 )
[node name="tree7" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree7"]
position = Vector2( 38.4727, 145.283 )
shape = SubResource( 1 )
[node name="forestTreeBig6" type="Sprite" parent="YSort/tree7"]
position = Vector2( 38.7028, 144.733 )
texture = ExtResource( 5 )
[node name="tree4" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree4"]
position = Vector2( 211.334, 36.8269 )
shape = SubResource( 1 )
[node name="forestTreeBig7" type="Sprite" parent="YSort/tree4"]
position = Vector2( 210.897, 36.2771 )
texture = ExtResource( 5 )
[node name="tree" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree"]
position = Vector2( 235.362, 138.275 )
shape = SubResource( 1 )
[node name="forestTreeBig" type="Sprite" parent="YSort/tree/CollisionShape2D"]
position = Vector2( -0.103607, -0.883423 )
texture = ExtResource( 5 )
[node name="tree3" type="StaticBody2D" parent="YSort"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree3"]
position = Vector2( 153.603, 158.631 )
shape = SubResource( 1 )
[node name="forestTreeBig3" type="Sprite" parent="YSort/tree3"]
position = Vector2( 153.165, 157.748 )
texture = ExtResource( 5 )
[node name="tree2" type="StaticBody2D" parent="YSort"]
position = Vector2( 2.47487, 0.707108 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/tree2"]
position = Vector2( 157.273, 93.2238 )
shape = SubResource( 1 )
[node name="forestTreeBig4" type="Sprite" parent="YSort/tree2"]
position = Vector2( 156.836, 92.3404 )
texture = ExtResource( 5 )
[node name="wall" type="StaticBody2D" parent="YSort"]
[node name="wall" type="StaticBody2D" parent="."]
position = Vector2( -17.4614, 141.279 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/wall"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall"]
position = Vector2( 329.803, -41.5425 )
shape = SubResource( 2 )
[node name="wall1" type="StaticBody2D" parent="YSort"]
[node name="wall1" type="StaticBody2D" parent="."]
position = Vector2( 15.874, -26.1921 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/wall1"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall1"]
position = Vector2( -3.71627, -0.261772 )
shape = SubResource( 3 )
[node name="wall2" type="StaticBody2D" parent="YSort"]
[node name="wall2" type="StaticBody2D" parent="."]
position = Vector2( -7.93701, 71.8299 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/wall2"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall2"]
position = Vector2( 8.36367, 26.9858 )
shape = SubResource( 2 )
[node name="wall3" type="StaticBody2D" parent="YSort"]
[node name="wall3" type="StaticBody2D" parent="."]
position = Vector2( -49.6063, 34.526 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSort/wall3"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="wall3"]
position = Vector2( 0, -4.25 )
shape = SubResource( 4 )
[node name="coin_container" type="Control" parent="YSort"]
[node name="coin_container" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Countdown" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 8 )
__meta__ = {
"_edit_use_anchors_": false
}
minutes = 3
[node name="sec" type="RichTextLabel" parent="Countdown"]
modulate = Color( 0.25098, 0.0431373, 0.411765, 1 )
self_modulate = Color( 0.25098, 0.0431373, 0.411765, 1 )
margin_left = 139.114
margin_top = 5.0
margin_right = 169.114
margin_bottom = 26.0
text = "00"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="dsec" type="RichTextLabel" parent="Countdown"]
modulate = Color( 0.25098, 0.0431373, 0.411765, 1 )
self_modulate = Color( 0.25098, 0.0431373, 0.411765, 1 )
margin_left = 158.512
margin_top = 4.7622
margin_right = 198.512
margin_bottom = 44.7622
text = "0"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Timer" type="Timer" parent="Countdown"]
process_mode = 0
wait_time = 0.1
autostart = true
[node name="Countdown Timer" parent="." instance=ExtResource( 12 )]
[node name="HUD" parent="." instance=ExtResource( 9 )]
[node name="Pause Screen" parent="." instance=ExtResource( 10 )]
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
[node name="BGM" type="AudioStreamPlayer" parent="."]
pause_mode = 2
stream = ExtResource( 11 )
[connection signal="timeout" from="Countdown/Timer" to="Countdown" method="_on_Timer_timeout"]
volume_db = -12.0
autoplay = true

View File

@@ -2,5 +2,5 @@ extends Node2D
func _ready() -> void:
$YSort/Player.load_hud($HUD)
return
$YSort/Player.load_hud($HUD)
return

View File

@@ -15,7 +15,6 @@
script = ExtResource( 2 )
[node name="CanvasModulate" type="CanvasModulate" parent="."]
visible = false
color = Color( 0, 0, 0, 1 )
[node name="Floor" type="TileMap" parent="."]