Pārlūkot izejas kodu

Add a game over screen

Bug with not detecting TileMap (still work if you manually put a bloc at
the last line).
DricomDragon 3 gadi atpakaļ
vecāks
revīzija
57d66ff193
4 mainītis faili ar 47 papildinājumiem un 7 dzēšanām
  1. 33 4
      godot/scenes/main.tscn
  2. 6 1
      godot/scripts/Catcher.gd
  3. 3 2
      godot/scripts/Launcher.gd
  4. 5 0
      godot/scripts/UI.gd

+ 33 - 4
godot/scenes/main.tscn

@@ -1,4 +1,4 @@
-[gd_scene load_steps=13 format=2]
+[gd_scene load_steps=14 format=2]
 
 [ext_resource path="res://image/launcher.png" type="Texture" id=1]
 [ext_resource path="res://image/brik.png" type="Texture" id=2]
@@ -6,6 +6,7 @@
 [ext_resource path="res://scripts/Launcher.gd" type="Script" id=4]
 [ext_resource path="res://image/visor.png" type="Texture" id=5]
 [ext_resource path="res://scripts/Grid.gd" type="Script" id=6]
+[ext_resource path="res://scripts/UI.gd" type="Script" id=7]
 
 [sub_resource type="PhysicsMaterial" id=1]
 friction = 0.0
@@ -41,7 +42,7 @@ points = PoolVector2Array( 0, 0, 40, 0, 40, 20, 0, 20 )
 } ]
 0/z_index = 0
 
-[node name="Root" type="Node2D"]
+[node name="Root" type="Node"]
 
 [node name="Walls" type="StaticBody2D" parent="."]
 physics_material_override = SubResource( 1 )
@@ -59,7 +60,7 @@ position = Vector2( 200, -50 )
 shape = SubResource( 3 )
 
 [node name="Catcher" type="Area2D" parent="."]
-position = Vector2( 200, 470 )
+position = Vector2( 200, 460 )
 script = ExtResource( 3 )
 
 [node name="Area" type="CollisionShape2D" parent="Catcher"]
@@ -68,7 +69,9 @@ shape = SubResource( 4 )
 [node name="Launcher" type="Node2D" parent="."]
 script = ExtResource( 4 )
 
-[node name="Grid" type="TileMap" parent="Launcher"]
+[node name="Grid" type="TileMap" parent="Launcher" groups=[
+"grid",
+]]
 mode = 2
 tile_set = SubResource( 6 )
 cell_size = Vector2( 40, 20 )
@@ -87,7 +90,33 @@ texture = ExtResource( 1 )
 [node name="ShootDelay" type="Timer" parent="Launcher"]
 wait_time = 0.3
 one_shot = true
+
+[node name="UI" type="Control" parent="."]
+visible = false
+margin_right = 40.0
+margin_bottom = 40.0
+script = ExtResource( 7 )
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="Panel" type="Panel" parent="UI"]
+margin_left = 100.0
+margin_top = 175.0
+margin_right = 300.0
+margin_bottom = 225.0
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="GameOver" type="Label" parent="UI"]
+margin_right = 400.0
+margin_bottom = 400.0
+text = "Game Over"
+align = 1
+valign = 1
 [connection signal="body_entered" from="Catcher" to="Catcher" method="_on_Catcher_body_entered"]
+[connection signal="game_over" from="Catcher" to="UI" method="_on_Catcher_game_over"]
 [connection signal="get_firing" from="Launcher" to="Launcher" method="_on_Launcher_get_firing"]
 [connection signal="is_full" from="Launcher" to="Launcher/Grid" method="_on_Launcher_is_full"]
 [connection signal="has_moved" from="Launcher/Grid" to="Launcher" method="_on_Grid_has_moved"]

+ 6 - 1
godot/scripts/Catcher.gd

@@ -2,8 +2,13 @@ class_name Catcher
 extends Area2D
 
 signal kace_catch
+signal game_over
 
 func _on_Catcher_body_entered(body):
-	if (body.is_in_group("ball")):
+	# TODO Debug game over signal
+	if body.is_in_group("ball"):
 		body.queue_free()
 		emit_signal("kace_catch")
+	elif body.is_in_group("grid"):
+		emit_signal("game_over")
+

+ 3 - 2
godot/scripts/Launcher.gd

@@ -9,7 +9,7 @@ enum State {
 	WAITING,
 }
 
-const BULLET_SPEED = 300.0
+const BULLET_SPEED = 600.0
 
 var _ballScene = preload("res://scenes/Ball.tscn")
 
@@ -85,4 +85,5 @@ func _on_Grid_has_moved():
 
 
 func _on_Grid_kace_broken():
-	load_bullet(1)
+	#load_bullet(1)
+	print("Not loading")

+ 5 - 0
godot/scripts/UI.gd

@@ -0,0 +1,5 @@
+extends Control
+
+
+func _on_Catcher_game_over():
+	show()