added a speed ball and buttons to add them to the level
This commit is contained in:
+12
-6
@@ -1,14 +1,20 @@
|
||||
extends Node2D
|
||||
|
||||
var _current_level = 1
|
||||
var ball_scene = preload("res://balls/basic/ball_basic.tscn")
|
||||
|
||||
func _on_button_pressed():
|
||||
var new_ball = ball_scene.instantiate()
|
||||
new_ball.global_position = $GameContent/BallSpawn.global_position
|
||||
$GameContent/Balls.add_child(new_ball)
|
||||
var ball_basic_scene = preload("res://balls/basic/ball_basic.tscn")
|
||||
var ball_speed_scene = preload("res://balls/speed/ball_speed.tscn")
|
||||
|
||||
func _physics_process(delta):
|
||||
if $GameContent/Blocks.get_children().size() == 0:
|
||||
_current_level += 1
|
||||
print("DONE")
|
||||
|
||||
func _on_button_basic_ball_pressed():
|
||||
var new_ball = ball_basic_scene.instantiate()
|
||||
new_ball.global_position = $GameContent/BallSpawn.global_position
|
||||
$GameContent/Balls.add_child(new_ball)
|
||||
|
||||
func _on_button_speed_ball_pressed():
|
||||
var new_ball = ball_speed_scene.instantiate()
|
||||
new_ball.global_position = $GameContent/BallSpawn.global_position
|
||||
$GameContent/Balls.add_child(new_ball)
|
||||
|
||||
+49
-7
@@ -1,12 +1,17 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://bmscox3qtwvs2"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://bmscox3qtwvs2"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/level.gd" id="1_3qps3"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7wvhwsys1ll4" path="res://resources/backgrounds/levelbg.webp" id="1_7ct6t"]
|
||||
[ext_resource type="FontFile" uid="uid://dxgnofummhosw" path="res://fonts/play_bold.ttf" id="2_musvo"]
|
||||
[ext_resource type="PackedScene" uid="uid://sl3jbnopo0yh" path="res://balls/basic/ball_basic.tscn" id="3_14yi2"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbygje4vi2rkv" path="res://boundaries/world_boundary.tscn" id="4_455ct"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxi0fqy5sajh5" path="res://balls/basic/basic.webp" id="4_phqmb"]
|
||||
[ext_resource type="Texture2D" uid="uid://dsqcbd2cffw6e" path="res://balls/speed/speed.webp" id="5_mxuen"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1i1fp3xbp6ly" path="res://blocks/block.tscn" id="7_7fnx3"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3mf1b"]
|
||||
bg_color = Color(0.341176, 0.392157, 0.564706, 1)
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ybmo2"]
|
||||
normal = Vector2(0, 1)
|
||||
distance = -510.0
|
||||
@@ -33,7 +38,9 @@ offset_right = 1920.0
|
||||
offset_bottom = 1080.0
|
||||
texture = ExtResource("1_7ct6t")
|
||||
|
||||
[node name="GUI" type="VBoxContainer" parent="."]
|
||||
[node name="GUI" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 20.0
|
||||
offset_top = 20.0
|
||||
offset_right = 360.0
|
||||
@@ -41,6 +48,8 @@ offset_bottom = 1060.0
|
||||
|
||||
[node name="Title0" type="Label" parent="GUI"]
|
||||
layout_mode = 2
|
||||
offset_right = 340.0
|
||||
offset_bottom = 179.0
|
||||
theme_override_fonts/font = ExtResource("2_musvo")
|
||||
theme_override_font_sizes/font_size = 154
|
||||
text = "IDLE"
|
||||
@@ -48,16 +57,48 @@ horizontal_alignment = 1
|
||||
|
||||
[node name="Title1" type="Label" parent="GUI"]
|
||||
layout_mode = 2
|
||||
offset_top = 183.0
|
||||
offset_right = 340.0
|
||||
offset_bottom = 258.0
|
||||
theme_override_fonts/font = ExtResource("2_musvo")
|
||||
theme_override_font_sizes/font_size = 64
|
||||
text = "BREAKOUT"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Button" type="Button" parent="GUI"]
|
||||
[node name="Panel" type="PanelContainer" parent="GUI"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_musvo")
|
||||
theme_override_font_sizes/font_size = 50
|
||||
text = "ADD BALL"
|
||||
offset_top = 260.0
|
||||
offset_right = 340.0
|
||||
offset_bottom = 1040.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_3mf1b")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="GUI/Panel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="GUI/Panel/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="GUI/Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ButtonBasicBall" type="TextureButton" parent="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("4_phqmb")
|
||||
stretch_mode = 0
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="GUI/Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ButtonSpeedBall" type="TextureButton" parent="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("5_mxuen")
|
||||
stretch_mode = 0
|
||||
|
||||
[node name="GameContent" type="Node2D" parent="."]
|
||||
|
||||
@@ -128,4 +169,5 @@ position = Vector2(1635, 293)
|
||||
[node name="BallSpawn" type="Node2D" parent="GameContent"]
|
||||
position = Vector2(1140, 540)
|
||||
|
||||
[connection signal="pressed" from="GUI/Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer/ButtonBasicBall" to="." method="_on_button_basic_ball_pressed"]
|
||||
[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer2/ButtonSpeedBall" to="." method="_on_button_speed_ball_pressed"]
|
||||
|
||||
Reference in New Issue
Block a user