diff --git a/pong_game/ball.gd b/pong_game/ball.gd new file mode 100644 index 00000000..ff108d6a --- /dev/null +++ b/pong_game/ball.gd @@ -0,0 +1,39 @@ +@tool +class_name Ball +extends RigidBody2D + +const _INITIAL_RADIUS: int = 64 + +## This is how fast your ball moves. +@export_range(0.0, 10000.0, 0.5, "suffix:px/s") var initial_speed: float = 500.0 + +## This is the initial angle of the ball. +@export_range(-180, 180, 0.5, "radians_as_degrees") var initial_direction: float = PI / 4 + +## How big is this ball? +@export_range(0.1, 5.0, 0.1) var size: float = 1.0: + set = _set_size + +@onready var _shape: CollisionShape2D = %CollisionShape2D +@onready var _sprite: Sprite2D = %Sprite2D + + +func _set_size(new_size: float): + size = new_size + if not is_node_ready(): + await ready + _shape.shape.radius = _INITIAL_RADIUS * size + _sprite.scale = Vector2(size, size) + + +func _ready(): + if Engine.is_editor_hint(): + set_process(false) + set_physics_process(false) + reset() + + +func reset(): + linear_velocity = Vector2.from_angle(initial_direction) * initial_speed + angular_velocity = 0.0 + _set_size(size) diff --git a/pong_game/ball.png b/pong_game/ball.png new file mode 100644 index 00000000..157995c2 Binary files /dev/null and b/pong_game/ball.png differ diff --git a/pong_game/ball.png.import b/pong_game/ball.png.import new file mode 100644 index 00000000..efad73c2 --- /dev/null +++ b/pong_game/ball.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcgr5amsq3jfl" +path="res://.godot/imported/ball.png-207b87d36613f4458c4a15d56cdcf75a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://pong_game/ball.png" +dest_files=["res://.godot/imported/ball.png-207b87d36613f4458c4a15d56cdcf75a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/pong_game/ball.tscn b/pong_game/ball.tscn new file mode 100644 index 00000000..2a640af9 --- /dev/null +++ b/pong_game/ball.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=7 format=3 uid="uid://c7l70grmkauij"] + +[ext_resource type="Script" path="res://pong_game/ball.gd" id="1_vdrab"] +[ext_resource type="Texture2D" uid="uid://bcgr5amsq3jfl" path="res://pong_game/ball.png" id="2_xkrmm"] +[ext_resource type="AudioStream" uid="uid://bc7jd3d8m5spt" path="res://pong_game/wall_hit.ogg" id="3_mjbsd"] +[ext_resource type="AudioStream" uid="uid://jk0oapxjw354" path="res://pong_game/paddle_hit.ogg" id="4_skr8k"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_c3m63"] +friction = 0.0 +bounce = 1.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_sntrn"] +radius = 64.0 + +[node name="Ball" type="RigidBody2D" groups=["balls"]] +collision_layer = 2 +collision_mask = 15 +physics_material_override = SubResource("PhysicsMaterial_c3m63") +continuous_cd = 1 +max_contacts_reported = 1 +contact_monitor = true +linear_velocity = Vector2(353.553, 353.553) +script = ExtResource("1_vdrab") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +unique_name_in_owner = true +shape = SubResource("CircleShape2D_sntrn") + +[node name="Sprite2D" type="Sprite2D" parent="."] +unique_name_in_owner = true +texture = ExtResource("2_xkrmm") + +[node name="WallAudioStreamPlayer" type="AudioStreamPlayer" parent="."] +stream = ExtResource("3_mjbsd") + +[node name="PaddleAudioStreamPlayer" type="AudioStreamPlayer" parent="."] +stream = ExtResource("4_skr8k") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/pong_game/hud.gd b/pong_game/hud.gd new file mode 100644 index 00000000..2eb5ede0 --- /dev/null +++ b/pong_game/hud.gd @@ -0,0 +1,19 @@ +extends CanvasLayer + +@onready var _score_labels = { + "left": %PlayerLeftScore, + "right": %PlayerRightScore, +} + + +## Sets the score for one player. +func set_player_score(player: String, score: int): + var text = _score_labels[player].text + if str(score) != text: + _score_labels[player].text = str(score) + + +## Sets the score for each player. +func set_players_scores(left_score: int, right_score: int): + set_player_score("left", left_score) + set_player_score("right", right_score) diff --git a/pong_game/hud.tscn b/pong_game/hud.tscn new file mode 100644 index 00000000..b5449a0c --- /dev/null +++ b/pong_game/hud.tscn @@ -0,0 +1,57 @@ +[gd_scene load_steps=3 format=3 uid="uid://bis7afjjuwypq"] + +[ext_resource type="Script" path="res://pong_game/hud.gd" id="1_yyb01"] +[ext_resource type="Texture2D" uid="uid://dijemw7iilr2m" path="res://pong_game/line.png" id="2_jon51"] + +[node name="HUD" type="CanvasLayer" groups=["hud"]] +script = ExtResource("1_yyb01") + +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Lines" type="Sprite2D" parent="Control/HBoxContainer"] +unique_name_in_owner = true +texture_repeat = 2 +position = Vector2(960, 536) +texture = ExtResource("2_jon51") +region_enabled = true +region_rect = Rect2(0, 0, 20, 1100) + +[node name="PlayerLeftScore" type="Label" parent="Control"] +unique_name_in_owner = true +layout_mode = 2 +offset_left = 240.0 +offset_right = 717.0 +offset_bottom = 1080.0 +pivot_offset = Vector2(240, 176) +size_flags_horizontal = 3 +size_flags_vertical = 1 +theme_override_font_sizes/font_size = 200 +text = "0" +horizontal_alignment = 1 + +[node name="PlayerRightScore" type="Label" parent="Control"] +unique_name_in_owner = true +layout_mode = 2 +offset_left = 1200.0 +offset_right = 1677.0 +offset_bottom = 1080.0 +pivot_offset = Vector2(240, 176) +size_flags_horizontal = 3 +size_flags_vertical = 1 +theme_override_font_sizes/font_size = 200 +text = "0" +horizontal_alignment = 1 diff --git a/pong_game/line.png b/pong_game/line.png new file mode 100644 index 00000000..9ce5b41f Binary files /dev/null and b/pong_game/line.png differ diff --git a/pong_game/line.png.import b/pong_game/line.png.import new file mode 100644 index 00000000..9264e7d6 --- /dev/null +++ b/pong_game/line.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dijemw7iilr2m" +path="res://.godot/imported/line.png-452af046907249a8ef12695e48447ab1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://pong_game/line.png" +dest_files=["res://.godot/imported/line.png-452af046907249a8ef12695e48447ab1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/pong_game/paddle.gd b/pong_game/paddle.gd new file mode 100644 index 00000000..7d073e89 --- /dev/null +++ b/pong_game/paddle.gd @@ -0,0 +1,33 @@ +@tool +class_name Paddle +extends CharacterBody2D + + +func get_custom_class(): + return "Paddle" + + +static func get_exposed_properties() -> Array[String]: + return ["position"] + + +static func get_custom_blocks() -> Array[BlockCategory]: + var b: Block + + # Movement + var movement_list: Array[Block] = [] + b = CategoryFactory.BLOCKS["statement_block"].instantiate() + b.block_type = Types.BlockType.EXECUTE + b.block_format = "Move with player 1 buttons, speed {speed: VECTOR2}" + b.statement = 'velocity = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")*{speed}\n' + "move_and_slide()" + movement_list.append(b) + + b = CategoryFactory.BLOCKS["statement_block"].instantiate() + b.block_type = Types.BlockType.EXECUTE + b.block_format = "Move with player 2 buttons, speed {speed: VECTOR2}" + b.statement = 'velocity = Input.get_vector("player_2_left", "player_2_right", "player_2_up", "player_2_down")*{speed}\n' + "move_and_slide()" + movement_list.append(b) + + var movement_category: BlockCategory = BlockCategory.new("Movement", movement_list, Color("4a86d5")) + + return [movement_category] diff --git a/pong_game/paddle.png b/pong_game/paddle.png new file mode 100644 index 00000000..3ea6181c Binary files /dev/null and b/pong_game/paddle.png differ diff --git a/pong_game/paddle.png.import b/pong_game/paddle.png.import new file mode 100644 index 00000000..e7956273 --- /dev/null +++ b/pong_game/paddle.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://tplpgtnfeda0" +path="res://.godot/imported/paddle.png-2fbcaaf37bbbddd482a4ad5b20dde0a2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://pong_game/paddle.png" +dest_files=["res://.godot/imported/paddle.png-2fbcaaf37bbbddd482a4ad5b20dde0a2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/pong_game/paddle.tscn b/pong_game/paddle.tscn new file mode 100644 index 00000000..b5ed8a81 --- /dev/null +++ b/pong_game/paddle.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://s7enbp56f256"] + +[ext_resource type="Script" path="res://pong_game/paddle.gd" id="1_74lee"] +[ext_resource type="Texture2D" uid="uid://tplpgtnfeda0" path="res://pong_game/paddle.png" id="1_eucti"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_bbbjr"] +size = Vector2(128, 384) + +[node name="Paddle" type="CharacterBody2D" groups=["paddles"]] +collision_mask = 68 +motion_mode = 1 +script = ExtResource("1_74lee") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_bbbjr") + +[node name="Sprite2D" type="Sprite2D" parent="."] +unique_name_in_owner = true +texture = ExtResource("1_eucti") diff --git a/pong_game/paddle_hit.ogg b/pong_game/paddle_hit.ogg new file mode 100644 index 00000000..692386de Binary files /dev/null and b/pong_game/paddle_hit.ogg differ diff --git a/pong_game/paddle_hit.ogg.import b/pong_game/paddle_hit.ogg.import new file mode 100644 index 00000000..17035730 --- /dev/null +++ b/pong_game/paddle_hit.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://jk0oapxjw354" +path="res://.godot/imported/paddle_hit.ogg-78978cea7a35465f97568c50bd227ec1.oggvorbisstr" + +[deps] + +source_file="res://pong_game/paddle_hit.ogg" +dest_files=["res://.godot/imported/paddle_hit.ogg-78978cea7a35465f97568c50bd227ec1.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/pong_game/pong_game.gd b/pong_game/pong_game.gd new file mode 100644 index 00000000..e88a8a87 --- /dev/null +++ b/pong_game/pong_game.gd @@ -0,0 +1,29 @@ +@tool +class_name Pong +extends Node2D + + +func get_custom_class(): + return "Pong" + + +static func get_custom_blocks() -> Array[BlockCategory]: + var b: Block + + # TODO: Only for testing. Move these blocks where they belong. + var score_list: Array[Block] = [] + b = CategoryFactory.BLOCKS["statement_block"].instantiate() + b.block_type = Types.BlockType.EXECUTE + b.block_format = "Change player 1 score by {score: INT}" + b.statement = 'get_tree().call_group("hud", "set_player_score", "right", {score})' + score_list.append(b) + + b = CategoryFactory.BLOCKS["statement_block"].instantiate() + b.block_type = Types.BlockType.EXECUTE + b.block_format = "Change player 2 score by {score: INT}" + b.statement = 'get_tree().call_group("hud", "set_player_score", "left", {score})' + score_list.append(b) + + var score_category: BlockCategory = BlockCategory.new("Scoring", score_list, Color("4a86d5")) + + return [score_category] diff --git a/pong_game/pong_game.tscn b/pong_game/pong_game.tscn new file mode 100644 index 00000000..f3565ace --- /dev/null +++ b/pong_game/pong_game.tscn @@ -0,0 +1,178 @@ +[gd_scene load_steps=31 format=3 uid="uid://tf7b8c64ecc0"] + +[ext_resource type="PackedScene" uid="uid://s7enbp56f256" path="res://pong_game/paddle.tscn" id="1_1k5k2"] +[ext_resource type="Script" path="res://pong_game/pong_game.gd" id="1_bjkc8"] +[ext_resource type="PackedScene" uid="uid://cg8ibi18um3vg" path="res://pong_game/space.tscn" id="1_y56ac"] +[ext_resource type="Script" path="res://addons/block_code/block_code_node/block_code.gd" id="3_6jaq8"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node.gd" id="4_qtggh"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block.gd" id="5_wr38c"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="6_ppdc3"] +[ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="7_uuuue"] +[ext_resource type="PackedScene" uid="uid://bis7afjjuwypq" path="res://pong_game/hud.tscn" id="8_yg457"] +[ext_resource type="PackedScene" uid="uid://c7l70grmkauij" path="res://pong_game/ball.tscn" id="9_xrqll"] + +[sub_resource type="Resource" id="Resource_535fl"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.290196, 0.52549, 0.835294, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["block_format", "Move with player 2 buttons, speed {speed: VECTOR2}"], ["statement", "velocity = Input.get_vector(\"player_2_left\", \"player_2_right\", \"player_2_up\", \"player_2_down\")*{speed} +move_and_slide()"], ["param_input_strings", { +"speed": "0, 1000" +}]] + +[sub_resource type="Resource" id="Resource_qwdfx"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_535fl") +path_child_pairs = [] + +[sub_resource type="Resource" id="Resource_ob4a5"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", "process_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 1], ["position", Vector2(53, 164)], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_53uyg"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_ob4a5") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_qwdfx")]] + +[sub_resource type="Resource" id="Resource_85hm7"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_53uyg")]) + +[sub_resource type="Resource" id="Resource_t7nl4"] +script = ExtResource("7_uuuue") +script_inherits = "Paddle" +block_trees = SubResource("Resource_85hm7") +generated_script = "extends Paddle + +var VAR_DICT := {} + +func _process(delta): + velocity = Input.get_vector(\"player_2_left\", \"player_2_right\", \"player_2_up\", \"player_2_down\")*Vector2(0, 1000) + move_and_slide() + +" + +[sub_resource type="Resource" id="Resource_jkl87"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.290196, 0.52549, 0.835294, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["block_format", "Move with player 1 buttons, speed {speed: VECTOR2}"], ["statement", "velocity = Input.get_vector(\"ui_left\", \"ui_right\", \"ui_up\", \"ui_down\")*{speed} +move_and_slide()"], ["param_input_strings", { +"speed": "0, 1000" +}]] + +[sub_resource type="Resource" id="Resource_dsoim"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_jkl87") +path_child_pairs = [] + +[sub_resource type="Resource" id="Resource_1xs00"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", "process_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 1], ["position", Vector2(90, 95)], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_lgfia"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_1xs00") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_dsoim")]] + +[sub_resource type="Resource" id="Resource_w0goe"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_lgfia")]) + +[sub_resource type="Resource" id="Resource_52r02"] +script = ExtResource("7_uuuue") +script_inherits = "Paddle" +block_trees = SubResource("Resource_w0goe") +generated_script = "extends Paddle + +var VAR_DICT := {} + +func _process(delta): + velocity = Input.get_vector(\"ui_left\", \"ui_right\", \"ui_up\", \"ui_down\")*Vector2(0, 1000) + move_and_slide() + +" + +[sub_resource type="Resource" id="Resource_ve47i"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.290196, 0.52549, 0.835294, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["block_format", "Change player 1 score by {score: INT}"], ["statement", "get_tree().call_group(\"hud\", \"set_player_score\", \"right\", {score})"], ["param_input_strings", { +"score": "2" +}]] + +[sub_resource type="Resource" id="Resource_asygo"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_ve47i") +path_child_pairs = [] + +[sub_resource type="Resource" id="Resource_xnfno"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.290196, 0.52549, 0.835294, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["block_format", "Change player 2 score by {score: INT}"], ["statement", "get_tree().call_group(\"hud\", \"set_player_score\", \"left\", {score})"], ["param_input_strings", { +"score": "4" +}]] + +[sub_resource type="Resource" id="Resource_6ul1j"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_xnfno") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_asygo")]] + +[sub_resource type="Resource" id="Resource_6o8ws"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 1], ["position", Vector2(54, 47)], ["block_format", "On Ready"], ["statement", "func _ready():"], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_tceso"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_6o8ws") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_6ul1j")]] + +[sub_resource type="Resource" id="Resource_jvpy2"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_tceso")]) + +[sub_resource type="Resource" id="Resource_f070g"] +script = ExtResource("7_uuuue") +script_inherits = "Pong" +block_trees = SubResource("Resource_jvpy2") +generated_script = "extends Pong + +var VAR_DICT := {} + +func _ready(): + get_tree().call_group(\"hud\", \"set_player_score\", \"left\", 4) + get_tree().call_group(\"hud\", \"set_player_score\", \"right\", 2) + +" + +[node name="Pong" type="Node2D"] +script = ExtResource("1_bjkc8") + +[node name="Space" parent="." instance=ExtResource("1_y56ac")] + +[node name="PaddleLeft" parent="." instance=ExtResource("1_1k5k2")] +modulate = Color(0.511, 0.362, 0.972, 1) +position = Vector2(64, 576) + +[node name="BlockCode" type="Node" parent="PaddleLeft"] +script = ExtResource("3_6jaq8") +bsd = SubResource("Resource_t7nl4") + +[node name="PaddleRight" parent="." instance=ExtResource("1_1k5k2")] +modulate = Color(0.511, 0.362, 0.972, 1) +position = Vector2(1856, 576) + +[node name="BlockCode" type="Node" parent="PaddleRight"] +script = ExtResource("3_6jaq8") +bsd = SubResource("Resource_52r02") + +[node name="Ball" parent="." instance=ExtResource("9_xrqll")] +modulate = Color(0.511, 0.362, 0.972, 1) +position = Vector2(960, 576) +linear_velocity = Vector2(353.553, 353.553) + +[node name="HUD" parent="." instance=ExtResource("8_yg457")] + +[node name="BlockCode" type="Node" parent="."] +script = ExtResource("3_6jaq8") +bsd = SubResource("Resource_f070g") diff --git a/pong_game/score.ogg b/pong_game/score.ogg new file mode 100644 index 00000000..66858bd7 Binary files /dev/null and b/pong_game/score.ogg differ diff --git a/pong_game/score.ogg.import b/pong_game/score.ogg.import new file mode 100644 index 00000000..d422c2e0 --- /dev/null +++ b/pong_game/score.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://kr166je3cyj7" +path="res://.godot/imported/score.ogg-4f0a6fc2761f0318eef7ef1a2afe3707.oggvorbisstr" + +[deps] + +source_file="res://pong_game/score.ogg" +dest_files=["res://.godot/imported/score.ogg-4f0a6fc2761f0318eef7ef1a2afe3707.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/pong_game/space.png b/pong_game/space.png new file mode 100644 index 00000000..2c44d172 Binary files /dev/null and b/pong_game/space.png differ diff --git a/pong_game/space.png.import b/pong_game/space.png.import new file mode 100644 index 00000000..b348001d --- /dev/null +++ b/pong_game/space.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ceiq8wmlnnnif" +path="res://.godot/imported/space.png-c14c9aa7839fab1f6152227ec9686ae5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://pong_game/space.png" +dest_files=["res://.godot/imported/space.png-c14c9aa7839fab1f6152227ec9686ae5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/pong_game/space.tscn b/pong_game/space.tscn new file mode 100644 index 00000000..0f7326f9 --- /dev/null +++ b/pong_game/space.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=5 format=3 uid="uid://cg8ibi18um3vg"] + +[ext_resource type="Texture2D" uid="uid://ceiq8wmlnnnif" path="res://pong_game/space.png" id="1_un3yo"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_q267f"] +size = Vector2(2688, 512) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_bqkwh"] +size = Vector2(64, 1080) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_lyev5"] +size = Vector2(256, 1080) + +[node name="Space" type="Node2D"] + +[node name="NinePatchRect" type="NinePatchRect" parent="."] +unique_name_in_owner = true +offset_right = 1920.0 +offset_bottom = 1080.0 +texture = ExtResource("1_un3yo") +patch_margin_left = 64 +patch_margin_top = 64 +patch_margin_right = 64 +patch_margin_bottom = 64 +axis_stretch_horizontal = 2 +axis_stretch_vertical = 2 + +[node name="Walls" type="RigidBody2D" parent="."] +collision_layer = 4 +collision_mask = 3 +collision_priority = 10.0 +mass = 9999.0 +lock_rotation = true +freeze = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls"] +position = Vector2(960, -256) +shape = SubResource("RectangleShape2D_q267f") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="Walls"] +position = Vector2(960, 1336) +shape = SubResource("RectangleShape2D_q267f") + +[node name="PaddleBounds" type="RigidBody2D" parent="."] +collision_layer = 64 +collision_mask = 0 +mass = 9999.0 +lock_rotation = true +freeze = true + +[node name="CollisionShape2D3" type="CollisionShape2D" parent="PaddleBounds"] +position = Vector2(-32, 540) +shape = SubResource("RectangleShape2D_bqkwh") + +[node name="CollisionShape2D4" type="CollisionShape2D" parent="PaddleBounds"] +position = Vector2(1952, 540) +shape = SubResource("RectangleShape2D_bqkwh") + +[node name="CollisionShape2D5" type="CollisionShape2D" parent="PaddleBounds"] +position = Vector2(960, 540) +shape = SubResource("RectangleShape2D_lyev5") diff --git a/pong_game/wall_hit.ogg b/pong_game/wall_hit.ogg new file mode 100644 index 00000000..af3b1e33 Binary files /dev/null and b/pong_game/wall_hit.ogg differ diff --git a/pong_game/wall_hit.ogg.import b/pong_game/wall_hit.ogg.import new file mode 100644 index 00000000..e4a2b346 --- /dev/null +++ b/pong_game/wall_hit.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://bc7jd3d8m5spt" +path="res://.godot/imported/wall_hit.ogg-9bf2dc2dc85cc008d84f97acca92da34.oggvorbisstr" + +[deps] + +source_file="res://pong_game/wall_hit.ogg" +dest_files=["res://.godot/imported/wall_hit.ogg-9bf2dc2dc85cc008d84f97acca92da34.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/project.godot b/project.godot index 9386eb3a..a34b7030 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="block-programming-plugin" -run/main_scene="res://test_game/test_game.tscn" +run/main_scene="res://pong_game/pong_game.tscn" config/features=PackedStringArray("4.2", "GL Compatibility") config/icon="res://icon.svg" @@ -19,6 +19,14 @@ config/icon="res://icon.svg" SignalManager="*res://addons/block_code/block_code_node/utilities/signal_manager.gd" +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 +window/size/window_width_override=960 +window/size/window_height_override=540 +window/stretch/mode="canvas_items" + [editor_plugins] enabled=PackedStringArray("res://addons/block_code/plugin.cfg", "res://addons/gut/plugin.cfg", "res://addons/plugin_refresher/plugin.cfg") @@ -46,6 +54,10 @@ player_2_right={ ] } +[physics] + +2d/default_gravity=0.0 + [rendering] renderer/rendering_method="gl_compatibility"