3 Commits e97249e220 ... 811bb59894

Author SHA1 Message Date
  Brigham Henry Keys, Esq 811bb59894 Limited amounts of paper, paper stacks are in game 1 year ago
  Brigham Henry Keys, Esq 86e122db64 signals are now in editor, added victory noise at end of level 1 year ago
  Brigham Henry Keys, Esq 9f3f132d8e Keeping track of delivered houses now 1 year ago
10 changed files with 209 additions and 77 deletions
  1. BIN
      assets/victory.ogg
  2. 3 2
      scenes/finish.tscn
  3. 65 23
      scenes/hud.tscn
  4. 51 15
      scenes/level.tscn
  5. 15 3
      scenes/mailbox.tscn
  6. 35 0
      scenes/paper_stack.tscn
  7. 2 13
      scenes/player.tscn
  8. 27 14
      scripts/hud.gd
  9. 11 7
      scripts/level.gd
  10. 0 0
      scripts/paper.gd

BIN
assets/victory.ogg


+ 3 - 2
scenes/finish.tscn

@@ -12,7 +12,7 @@ rotation = 0.785398
 input_pickable = false
 collision_layer = 1
 collision_mask = 1
-mode = 0
+mode = 1
 mass = 1.0
 gravity_scale = 1.0
 custom_integrator = false
@@ -28,8 +28,9 @@ angular_damp = -1.0
 _sections_unfolded = [ "Transform" ]
 
 [node name="Sprite" type="Sprite" parent="."]
+z_index = -6
 texture = ExtResource( 1 )
-_sections_unfolded = [ "Transform" ]
+_sections_unfolded = [ "Transform", "Z Index" ]
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 shape = SubResource( 1 )

+ 65 - 23
scenes/hud.tscn

@@ -1,30 +1,19 @@
-[gd_scene load_steps=4 format=2]
+[gd_scene load_steps=5 format=2]
 
 [ext_resource path="res://scripts/hud.gd" type="Script" id=1]
 [ext_resource path="res://assets/skull.webp" type="Texture" id=2]
 [ext_resource path="res://assets/game_over.webp" type="Texture" id=3]
+[ext_resource path="res://assets/paper.webp" type="Texture" id=4]
 
-[node name="Control" type="Control"]
-anchor_left = 0.0
-anchor_top = 0.0
-anchor_right = 0.0
-anchor_bottom = 0.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 )
-
-[node name="CanvasLayer" type="CanvasLayer" parent="."]
+[node name="Control" type="CanvasLayer"]
 layer = 1
 offset = Vector2( 0, 0 )
 rotation = 0.0
 scale = Vector2( 1, 1 )
 transform = Transform2D( 1, 0, 0, 1, 0, 0 )
+script = ExtResource( 1 )
 
-[node name="score" type="Label" parent="CanvasLayer"]
+[node name="score" type="Label" parent="."]
 anchor_left = 0.0
 anchor_top = 0.0
 anchor_right = 0.0
@@ -44,20 +33,73 @@ percent_visible = 1.0
 lines_skipped = 0
 max_lines_visible = -1
 
-[node name="life1" type="Sprite" parent="CanvasLayer"]
-position = Vector2( 57.76, 110.105 )
+[node name="life1" type="Sprite" parent="."]
+position = Vector2( 42.5766, 110.105 )
 texture = ExtResource( 2 )
 
-[node name="life2" type="Sprite" parent="CanvasLayer"]
-position = Vector2( 95.665, 110.105 )
+[node name="life2" type="Sprite" parent="."]
+position = Vector2( 80.4816, 110.105 )
 texture = ExtResource( 2 )
 
-[node name="life3" type="Sprite" parent="CanvasLayer"]
-position = Vector2( 133.57, 109.986 )
+[node name="life3" type="Sprite" parent="."]
+position = Vector2( 118.387, 109.986 )
 texture = ExtResource( 2 )
 
-[node name="game_over" type="Sprite" parent="CanvasLayer"]
+[node name="game_over" type="Sprite" parent="."]
 visible = false
 position = Vector2( 504.571, 309.423 )
 texture = ExtResource( 3 )
 
+[node name="ammo_group" type="Node2D" parent="."]
+editor/display_folded = true
+
+[node name="ammo1" type="Sprite" parent="ammo_group"]
+position = Vector2( 36.5192, 58.7908 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo2" type="Sprite" parent="ammo_group"]
+position = Vector2( 57.8344, 58.7908 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo3" type="Sprite" parent="ammo_group"]
+position = Vector2( 78.5656, 58.7908 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo4" type="Sprite" parent="ammo_group"]
+position = Vector2( 99.8808, 58.7908 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo5" type="Sprite" parent="ammo_group"]
+position = Vector2( 120.32, 58.7908 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo6" type="Sprite" parent="ammo_group"]
+position = Vector2( 36.5192, 80.6899 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo7" type="Sprite" parent="ammo_group"]
+position = Vector2( 58.0374, 80.6899 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo8" type="Sprite" parent="ammo_group"]
+position = Vector2( 78.5126, 80.6899 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo9" type="Sprite" parent="ammo_group"]
+position = Vector2( 100.143, 80.6899 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+
+[node name="ammo10" type="Sprite" parent="ammo_group"]
+position = Vector2( 121.418, 80.6899 )
+scale = Vector2( 0.436393, 0.436393 )
+texture = ExtResource( 4 )
+

+ 51 - 15
scenes/level.tscn

@@ -1,21 +1,33 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=11 format=2]
 
 [ext_resource path="res://scripts/level.gd" type="Script" id=1]
-[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=2]
-[ext_resource path="res://scenes/trash_can.tscn" type="PackedScene" id=3]
-[ext_resource path="res://assets/Street_1_TEX.webp" type="Texture" id=4]
-[ext_resource path="res://assets/grass03.webp" type="Texture" id=5]
-[ext_resource path="res://scenes/mailbox.tscn" type="PackedScene" id=6]
+[ext_resource path="res://assets/victory.ogg" type="AudioStream" id=2]
+[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=3]
+[ext_resource path="res://scenes/trash_can.tscn" type="PackedScene" id=4]
+[ext_resource path="res://assets/Street_1_TEX.webp" type="Texture" id=5]
+[ext_resource path="res://assets/grass03.webp" type="Texture" id=6]
 [ext_resource path="res://scenes/finish.tscn" type="PackedScene" id=7]
+[ext_resource path="res://scenes/mailbox.tscn" type="PackedScene" id=8]
+[ext_resource path="res://scenes/hud.tscn" type="PackedScene" id=9]
+[ext_resource path="res://scenes/paper_stack.tscn" type="PackedScene" id=10]
 
 [node name="level" type="Node2D"]
 position = Vector2( -235.496, -155.617 )
 script = ExtResource( 1 )
 
-[node name="player" parent="." instance=ExtResource( 2 )]
+[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 2 )
+volume_db = 0.0
+pitch_scale = 1.0
+autoplay = false
+stream_paused = false
+mix_target = 0
+bus = "Master"
+
+[node name="player" parent="." instance=ExtResource( 3 )]
 position = Vector2( 537.542, 598.796 )
 
-[node name="trash_can" parent="." instance=ExtResource( 3 )]
+[node name="trash_can" parent="." instance=ExtResource( 4 )]
 position = Vector2( 561.804, 356.715 )
 
 [node name="Sprite" type="Sprite" parent="."]
@@ -23,22 +35,17 @@ position = Vector2( 1174.04, -44.377 )
 rotation = 0.785398
 scale = Vector2( 0.251031, 0.251031 )
 z_index = -5
-texture = ExtResource( 4 )
+texture = ExtResource( 5 )
 region_enabled = true
 region_rect = Rect2( 0, 0, 1024, 10240 )
-_sections_unfolded = [ "Region", "Transform", "Z Index", "texture" ]
 
 [node name="Sprite2" type="Sprite" parent="."]
 position = Vector2( 1196.06, -47.2254 )
 scale = Vector2( 2.23851, 0.226453 )
 z_index = -6
-texture = ExtResource( 5 )
+texture = ExtResource( 6 )
 region_enabled = true
 region_rect = Rect2( 0, 0, 1024, 10240 )
-_sections_unfolded = [ "Region", "Transform", "Z Index", "texture" ]
-
-[node name="mailbox" parent="." instance=ExtResource( 6 )]
-position = Vector2( 699.512, 169.184 )
 
 [node name="checkpoint" type="Node2D" parent="."]
 position = Vector2( 535.147, 620.425 )
@@ -46,3 +53,32 @@ position = Vector2( 535.147, 620.425 )
 [node name="finish" parent="." instance=ExtResource( 7 )]
 position = Vector2( 2141.91, -1011.26 )
 
+[node name="mailbox_group" type="Node2D" parent="."]
+editor/display_folded = true
+
+[node name="mailbox1" parent="mailbox_group" instance=ExtResource( 8 )]
+position = Vector2( 699.512, 169.184 )
+
+[node name="mailbox4" parent="mailbox_group" instance=ExtResource( 8 )]
+position = Vector2( 1678.63, -941.039 )
+
+[node name="mailbox2" parent="mailbox_group" instance=ExtResource( 8 )]
+position = Vector2( 879.96, -15.3648 )
+
+[node name="mailbox3" parent="mailbox_group" instance=ExtResource( 8 )]
+position = Vector2( 1535.49, -723.899 )
+
+[node name="hud" parent="." instance=ExtResource( 9 )]
+
+[node name="paper_stack" parent="." instance=ExtResource( 10 )]
+position = Vector2( 1213.92, -346.839 )
+
+[connection signal="level_finished" from="player" to="." method="_on_player_level_finished"]
+[connection signal="paper_tossed" from="player" to="hud" method="_on_player_paper_tossed"]
+[connection signal="player_died" from="player" to="hud" method="_on_player_player_died"]
+[connection signal="player_died" from="player" to="." method="_on_player_player_died"]
+[connection signal="reload_papers" from="player" to="hud" method="_on_player_reload_papers"]
+[connection signal="game_over" from="hud" to="." method="_on_hud_game_over"]
+[connection signal="out_of_papers" from="hud" to="player" method="_on_hud_out_of_papers"]
+
+[editable path="player"]

+ 15 - 3
scenes/mailbox.tscn

@@ -7,12 +7,23 @@
 custom_solver_bias = 0.0
 radius = 66.3189
 
-[node name="mailbox" type="StaticBody2D"]
+[node name="mailbox" type="RigidBody2D"]
 input_pickable = false
 collision_layer = 1
 collision_mask = 1
-constant_linear_velocity = Vector2( 0, 0 )
-constant_angular_velocity = 0.0
+mode = 1
+mass = 1.0
+gravity_scale = 1.0
+custom_integrator = false
+continuous_cd = 0
+contacts_reported = 0
+contact_monitor = false
+sleeping = false
+can_sleep = false
+linear_velocity = Vector2( 0, 0 )
+linear_damp = -1.0
+angular_velocity = 0.0
+angular_damp = -1.0
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 shape = SubResource( 1 )
@@ -22,4 +33,5 @@ _sections_unfolded = [ "shape" ]
 position = Vector2( 0.23164, 1.62151 )
 scale = Vector2( 1.77456, 1.77456 )
 texture = ExtResource( 1 )
+_sections_unfolded = [ "Material", "Visibility" ]
 

+ 35 - 0
scenes/paper_stack.tscn

@@ -0,0 +1,35 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://assets/paper_stack.webp" type="Texture" id=1]
+
+[sub_resource type="RectangleShape2D" id=1]
+
+custom_solver_bias = 0.0
+extents = Vector2( 27.5338, 14.3775 )
+
+[node name="paper_stack" type="RigidBody2D"]
+input_pickable = false
+collision_layer = 1
+collision_mask = 1
+mode = 1
+mass = 1.0
+gravity_scale = 1.0
+custom_integrator = false
+continuous_cd = 0
+contacts_reported = 1
+contact_monitor = true
+sleeping = false
+can_sleep = true
+linear_velocity = Vector2( 0, 0 )
+linear_damp = -1.0
+angular_velocity = 0.0
+angular_damp = -1.0
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+position = Vector2( 1.6022, -1.53322 )
+shape = SubResource( 1 )
+
+[node name="Sprite" type="Sprite" parent="."]
+position = Vector2( 1.67247, -9.61673 )
+texture = ExtResource( 1 )
+

+ 2 - 13
scenes/player.tscn

@@ -1,8 +1,7 @@
-[gd_scene load_steps=5 format=2]
+[gd_scene load_steps=4 format=2]
 
 [ext_resource path="res://scripts/player.gd" type="Script" id=1]
 [ext_resource path="res://assets/bike.webp" type="Texture" id=2]
-[ext_resource path="res://scenes/hud.tscn" type="PackedScene" id=3]
 
 [sub_resource type="CapsuleShape2D" id=1]
 
@@ -14,7 +13,7 @@ height = 30.823
 input_pickable = false
 collision_layer = 1
 collision_mask = 1
-mode = 0
+mode = 3
 mass = 1.0
 gravity_scale = 1.0
 custom_integrator = false
@@ -28,13 +27,11 @@ linear_damp = -1.0
 angular_velocity = 0.0
 angular_damp = -1.0
 script = ExtResource( 1 )
-_sections_unfolded = [ "Angular", "Linear" ]
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 position = Vector2( -1.51596, 21.4682 )
 rotation = 0.785398
 shape = SubResource( 1 )
-_sections_unfolded = [ "Transform" ]
 
 [node name="Camera2D" type="Camera2D" parent="."]
 position = Vector2( 209.783, -144.403 )
@@ -65,13 +62,5 @@ editor_draw_drag_margin = false
 position = Vector2( 0.357361, 2.00603 )
 scale = Vector2( 0.215951, 0.215951 )
 texture = ExtResource( 2 )
-_sections_unfolded = [ "Region" ]
-
-[node name="hud" parent="." instance=ExtResource( 3 )]
-margin_left = 669.0
-margin_top = 19.0
-margin_right = 1035.0
-margin_bottom = 304.0
-_sections_unfolded = [ "Rect" ]
 
 [connection signal="body_shape_entered" from="." to="." method="_on_RigidBody2D_body_shape_entered"]

+ 27 - 14
scripts/hud.gd

@@ -1,23 +1,36 @@
-extends Control
+extends CanvasLayer
 
 signal game_over
-signal mailbox_hit
+signal out_of_papers
 
 func _ready():
-	connect("game_over", get_parent().get_parent(), "game_over_handler")
-	connect("game_over", get_parent(), "game_over_handler")
+	pass
 
-func deduct_life():
-	if has_node("CanvasLayer/life3"):
-		get_node("CanvasLayer/life3").queue_free()
+func _on_player_player_died():
+	if has_node("life3"):
+		get_node("life3").queue_free()
 		return
-	if has_node("CanvasLayer/life2"):
-		get_node("CanvasLayer/life2").queue_free()
+	if has_node("life2"):
+		get_node("life2").queue_free()
 		return
-	if has_node("CanvasLayer/life1"):
-		get_node("CanvasLayer/life1").queue_free()
-	get_node("CanvasLayer/game_over").visible = true
+	if has_node("life1"):
+		get_node("life1").queue_free()
+	get_node("game_over").visible = true
 	emit_signal("game_over")
 
-func mailbox_hit_handler():
-	get_node("CanvasLayer/score").text = str(int(get_node("CanvasLayer/score").text) + 1000)
+func mailbox_hit_handler(name):
+	get_node("score").text = str(int(get_node("score").text) + 1000)
+
+func _on_player_reload_papers():
+	for x in range(1, 11):
+		get_node("ammo_group/ammo" + str(x)).visible = true
+
+
+func _on_player_paper_tossed():
+	var ammo_amount : int = 0
+	for x in range(1, 11):
+		if get_node("ammo_group/ammo" + str(x)).visible:
+			ammo_amount += 1
+	get_node("ammo_group/ammo" + str(ammo_amount)).visible = false
+	if ammo_amount == 1: # just spent your last paper
+		emit_signal("out_of_papers")

+ 11 - 7
scripts/level.gd

@@ -1,16 +1,20 @@
 extends Node2D
 
-onready var death_timer : float = 0
-onready var game_over : bool = false
+onready var delivered_houses = []
 
 func _ready():
 	pass
 
-func death_handler():
+func mailbox_hit_handler(name):
+	delivered_houses.append(name)
+
+func _on_player_level_finished():
+	# get_node("AudioStreamPlayer").play()
+	# yield(get_node("AudioStreamPlayer"), "finished")
 	get_node("player").position = get_node("checkpoint").position
 
-func game_over_handler():
-	print("Game over! Now return to main menu")
+func _on_player_player_died():
+	get_node("player").position = get_node("checkpoint").position
 
-func level_finished_handler():
-	print("Level is finished!")
+func _on_hud_game_over():
+	print("Game over! Now return to main menu")

+ 0 - 0
scripts/paper.gd


Some files were not shown because too many files changed in this diff