commit facc1dac5acf95a27a0ccfe548d14a5b752aa5cd Author: HomeMadeGames Studio Date: Tue Jul 16 23:00:08 2024 -0400 Paddle-Ball 1.01 diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6c2a51e Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff05d1d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Paddle-Ball +This is a Paddle-Ball game made in Godot. + +This is the guide I followed: https://www.youtube.com/watch?v=Xq9AyhX8HUc&t=731s +The guide went a little fast but the game works. +So thank you [CodingWithRuss](https://www.youtube.com/@CodingWithRuss) +Audio: https://www.youtube.com/watch?v=T1UoqxDYtHI diff --git a/assets/Bg.png b/assets/Bg.png new file mode 100644 index 0000000..a10e0b0 Binary files /dev/null and b/assets/Bg.png differ diff --git a/assets/Bg.png.import b/assets/Bg.png.import new file mode 100644 index 0000000..f6beb7e --- /dev/null +++ b/assets/Bg.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cxaoi5koptij5" +path="res://.godot/imported/Bg.png-ca5d2210484e197d86a976d02d289bc8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Bg.png" +dest_files=["res://.godot/imported/Bg.png-ca5d2210484e197d86a976d02d289bc8.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/assets/audio/ballCollisionSound.wav b/assets/audio/ballCollisionSound.wav new file mode 100644 index 0000000..b040daf Binary files /dev/null and b/assets/audio/ballCollisionSound.wav differ diff --git a/assets/audio/ballCollisionSound.wav.import b/assets/audio/ballCollisionSound.wav.import new file mode 100644 index 0000000..8009982 --- /dev/null +++ b/assets/audio/ballCollisionSound.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dnke8jfo0ptyc" +path="res://.godot/imported/ballCollisionSound.wav-03c498f93978854a87d533625c0ce953.sample" + +[deps] + +source_file="res://assets/audio/ballCollisionSound.wav" +dest_files=["res://.godot/imported/ballCollisionSound.wav-03c498f93978854a87d533625c0ce953.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/audio/score.wav b/assets/audio/score.wav new file mode 100644 index 0000000..e758137 Binary files /dev/null and b/assets/audio/score.wav differ diff --git a/assets/audio/score.wav.import b/assets/audio/score.wav.import new file mode 100644 index 0000000..076e3cd --- /dev/null +++ b/assets/audio/score.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://b2vdw4b4pqkk7" +path="res://.godot/imported/score.wav-29ea67c0c07cdbeb20aee0f16be1985d.sample" + +[deps] + +source_file="res://assets/audio/score.wav" +dest_files=["res://.godot/imported/score.wav-29ea67c0c07cdbeb20aee0f16be1985d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/audio/scoreCPU.wav b/assets/audio/scoreCPU.wav new file mode 100644 index 0000000..d21de96 Binary files /dev/null and b/assets/audio/scoreCPU.wav differ diff --git a/assets/audio/scoreCPU.wav.import b/assets/audio/scoreCPU.wav.import new file mode 100644 index 0000000..d7e32a9 --- /dev/null +++ b/assets/audio/scoreCPU.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dyqk8c7pv87ec" +path="res://.godot/imported/scoreCPU.wav-4cd7254f66e717303a0024f6dc209447.sample" + +[deps] + +source_file="res://assets/audio/scoreCPU.wav" +dest_files=["res://.godot/imported/scoreCPU.wav-4cd7254f66e717303a0024f6dc209447.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/icon.ico b/assets/icon.ico new file mode 100644 index 0000000..bcc7d37 Binary files /dev/null and b/assets/icon.ico differ diff --git a/assets/icon.webp.import b/assets/icon.webp.import new file mode 100644 index 0000000..9b7500b --- /dev/null +++ b/assets/icon.webp.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d0nx7474ms0gm" +path="res://.godot/imported/icon.webp-4156abe4f036fcfe061769d74cd505de.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icon.webp" +dest_files=["res://.godot/imported/icon.webp-4156abe4f036fcfe061769d74cd505de.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/assets/pixel_font.ttf b/assets/pixel_font.ttf new file mode 100644 index 0000000..618e5bb Binary files /dev/null and b/assets/pixel_font.ttf differ diff --git a/assets/pixel_font.ttf.import b/assets/pixel_font.ttf.import new file mode 100644 index 0000000..2f6fcd6 --- /dev/null +++ b/assets/pixel_font.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://bk2qwj2aovtrp" +path="res://.godot/imported/pixel_font.ttf-ac38a4d641fc4320d85cc38ad9a50d85.fontdata" + +[deps] + +source_file="res://assets/pixel_font.ttf" +dest_files=["res://.godot/imported/pixel_font.ttf-ac38a4d641fc4320d85cc38ad9a50d85.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/assets/score.wav b/assets/score.wav new file mode 100644 index 0000000..e758137 Binary files /dev/null and b/assets/score.wav differ diff --git a/assets/score.wav.import b/assets/score.wav.import new file mode 100644 index 0000000..66eb91b --- /dev/null +++ b/assets/score.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://munha6u3lhc8" +path="res://.godot/imported/score.wav-20a370d73025155b7d4b0546b0011fb1.sample" + +[deps] + +source_file="res://assets/score.wav" +dest_files=["res://.godot/imported/score.wav-20a370d73025155b7d4b0546b0011fb1.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..babcba1 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,62 @@ +[preset.0] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="Export/Pong.exe" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=false +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +binary_format/architecture="x86_64" +codesign/enable=false +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PackedStringArray() +application/modify_resources=true +application/icon="res://assets/icon.ico" +application/console_wrapper_icon="" +application/icon_interpolation=4 +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" +application/export_angle=0 +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}' +$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}' +$trigger = New-ScheduledTaskTrigger -Once -At 00:00 +$settings = New-ScheduledTaskSettingsSet +$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings +Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true +Start-ScheduledTask -TaskName godot_remote_debug +while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 } +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue" +ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue +Remove-Item -Recurse -Force '{temp_dir}'" diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..be54e8c --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dh7dcq4opi2qf" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..eeb3404 --- /dev/null +++ b/project.godot @@ -0,0 +1,27 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Pong" +config/description="This is my first Godot project, YouTube tutorial: https://www.youtube.com/watch?v=Xq9AyhX8HUc +Pong works and is very dificult." +run/main_scene="res://scenes/main.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" +config/windows_native_icon="res://assets/icon.ico" + +[input] + +pause={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} diff --git a/scenes/Ball.gd b/scenes/Ball.gd new file mode 100644 index 0000000..cfdc370 --- /dev/null +++ b/scenes/Ball.gd @@ -0,0 +1,59 @@ +extends CharacterBody2D + +var win_size :Vector2 +const START_SPEED : int = 500 +const ACCEL : int = 50 +var speed : int +var dir : Vector2 +const MAX_Y_VECTOR : float = 0.6 + +@onready var ballCollisionSound = $"../ballCollisionSound" + +# Called when the node enters the scene tree for the first time. +func _ready(): + win_size = get_viewport_rect().size + +func new_ball(): + # Randomize start position and direction + position.x = win_size.x / 2 + position.y = randi_range(200, win_size.y - 200) + speed = START_SPEED + dir = random_direction() + + +# Called every frame. 'delta' is the elapsed time since the previous frame +func _physics_process(delta): + var collision = move_and_collide(dir * speed * delta) + var collider + if collision: + collider = collision.get_collider() + # if ball hits paddle + if collider == $"../Player" or collider == $"../CPU": + ballCollisionSound.play() + speed += ACCEL + dir = new_direction(collider) + # if the ball hits a wall + else: + dir = dir.bounce(collision.get_normal()) + + +func random_direction(): + var new_dir := Vector2() + new_dir.x = [1, -1].pick_random() + new_dir.y = randf_range(-1, 1) + return new_dir.normalized() + + +func new_direction(collider): + var ball_y = position.y + var pad_y = collider.position.y + var dist = ball_y - pad_y + var new_dir := Vector2() + + # flip the horizzintal direction + if dir.x > 0: + new_dir.x = -1 + else: + new_dir.x = 1 + new_dir.y = (dist / (collider.p_height / 2)) * MAX_Y_VECTOR + return new_dir.normalized() diff --git a/scenes/CPU.gd b/scenes/CPU.gd new file mode 100644 index 0000000..609fdd7 --- /dev/null +++ b/scenes/CPU.gd @@ -0,0 +1,26 @@ +extends StaticBody2D + +var ball_pos : Vector2 +var dist : int +var move_by : int +var win_height : int +var p_height : int + +# Called when the node enters the scene tree for the first time. +func _ready(): + win_height = get_viewport_rect().size.y + p_height = $ColorRect.get_size().y + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + # move the paddle towards the ball + ball_pos = $"../Ball".position + dist = position.y - ball_pos.y + if abs(dist) > get_parent().PADDLE_SPEED * delta: + move_by = get_parent().PADDLE_SPEED * delta * (dist / abs(dist)) + else: + move_by = dist + position.y -= move_by + # limit paddle movement to window + position.y = clamp(position.y, p_height / 2, win_height - p_height / 2) diff --git a/scenes/Player.gd b/scenes/Player.gd new file mode 100644 index 0000000..0817079 --- /dev/null +++ b/scenes/Player.gd @@ -0,0 +1,19 @@ +extends StaticBody2D + +var win_height : int +var p_height : int + +# Called when the node enters the scene tree for the first time. +func _ready(): + win_height = get_viewport_rect().size.y + p_height = $ColorRect.get_size().y + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if Input.is_action_pressed("ui_up"): + position.y -= get_parent().PADDLE_SPEED * delta # get_parent() allows calls from variables from parent scripts. In this case Player is the child to Main the parent. + elif Input.is_action_pressed("ui_down"): + position.y += get_parent().PADDLE_SPEED * delta + + # Limit paddle movement to the window + position.y = clamp(position.y, p_height / 2, win_height - p_height / 2) diff --git a/scenes/main.gd b/scenes/main.gd new file mode 100644 index 0000000..ee4447c --- /dev/null +++ b/scenes/main.gd @@ -0,0 +1,27 @@ +extends Sprite2D + +var score := [0, 0]# 0:Player, 1: CPU +# Speed at which the paddles move. +const PADDLE_SPEED : int = 500 + +# goal sound +@onready var scorePlayerSound = $scorePlayer +@onready var scoreCpuSound = $scoreCPU + + +func _on_ball_timer_timeout(): + $Ball.new_ball() + +func _on_score_left_body_entered(body): + score [1] += 1 + $Hud/CPUScore.text = str(score[1]) + scoreCpuSound.play() + $ballTimer.start() + + + +func _on_score_right_body_entered(body): + score [0] += 1 + $Hud/PlayerScore.text = str(score[0]) + $ballTimer.start() + scorePlayerSound.play() diff --git a/scenes/main.tscn b/scenes/main.tscn new file mode 100644 index 0000000..b82fbd9 --- /dev/null +++ b/scenes/main.tscn @@ -0,0 +1,170 @@ +[gd_scene load_steps=17 format=3 uid="uid://bfhusxown7y62"] + +[ext_resource type="Texture2D" uid="uid://cxaoi5koptij5" path="res://assets/Bg.png" id="1_ryt67"] +[ext_resource type="FontFile" uid="uid://bk2qwj2aovtrp" path="res://assets/pixel_font.ttf" id="2_aa451"] +[ext_resource type="Script" path="res://scenes/main.gd" id="2_lh4wf"] +[ext_resource type="Script" path="res://scenes/Player.gd" id="3_g8n25"] +[ext_resource type="Script" path="res://scenes/Ball.gd" id="4_6kej0"] +[ext_resource type="Script" path="res://scenes/CPU.gd" id="4_tr43r"] +[ext_resource type="PackedScene" uid="uid://tof3b3hl57pc" path="res://scenes/pauseMenu/pause_menu.tscn" id="7_v2uy6"] +[ext_resource type="AudioStream" uid="uid://b2vdw4b4pqkk7" path="res://assets/audio/score.wav" id="8_pp1l6"] +[ext_resource type="AudioStream" uid="uid://dyqk8c7pv87ec" path="res://assets/audio/scoreCPU.wav" id="9_o8ttd"] +[ext_resource type="AudioStream" uid="uid://dnke8jfo0ptyc" path="res://assets/audio/ballCollisionSound.wav" id="10_soomi"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_c8b7f"] +size = Vector2(20, 120) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_pie6m"] +size = Vector2(10, 10) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_cqt4o"] +size = Vector2(1152, 64) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ns60v"] +size = Vector2(1152, 56) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiuk5"] +size = Vector2(64, 648) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_kwmsh"] +size = Vector2(64, 648) + +[node name="Main" type="Sprite2D"] +texture_filter = 1 +texture = ExtResource("1_ryt67") +centered = false +script = ExtResource("2_lh4wf") + +[node name="Player" type="StaticBody2D" parent="."] +position = Vector2(50, 324) +script = ExtResource("3_g8n25") + +[node name="ColorRect" type="ColorRect" parent="Player"] +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -60.0 +offset_right = 20.0 +offset_bottom = 60.0 +grow_vertical = 2 +color = Color(0.85098, 0.85098, 0.85098, 1) +metadata/_edit_use_anchors_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] +position = Vector2(10, 0) +shape = SubResource("RectangleShape2D_c8b7f") + +[node name="CPU" type="StaticBody2D" parent="."] +position = Vector2(1082, 324) +script = ExtResource("4_tr43r") + +[node name="ColorRect" type="ColorRect" parent="CPU"] +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -60.0 +offset_right = 20.0 +offset_bottom = 60.0 +grow_vertical = 2 +color = Color(0.85098, 0.85098, 0.85098, 1) +metadata/_edit_use_anchors_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CPU"] +position = Vector2(10, 0) +shape = SubResource("RectangleShape2D_c8b7f") + +[node name="Ball" type="CharacterBody2D" parent="."] +position = Vector2(576, 324) +collision_mask = 3 +script = ExtResource("4_6kej0") + +[node name="ColorRect" type="ColorRect" parent="Ball"] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -5.0 +offset_top = -5.0 +offset_right = 5.0 +offset_bottom = 5.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.262745, 1, 1, 1) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ball"] +shape = SubResource("RectangleShape2D_pie6m") + +[node name="Borders" type="StaticBody2D" parent="."] +collision_layer = 2 + +[node name="Top" type="CollisionShape2D" parent="Borders"] +position = Vector2(576, -32) +shape = SubResource("RectangleShape2D_cqt4o") + +[node name="Bottom" type="CollisionShape2D" parent="Borders"] +position = Vector2(576, 676) +shape = SubResource("RectangleShape2D_ns60v") + +[node name="ScoreLeft" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="ScoreLeft"] +position = Vector2(-32, 324) +shape = SubResource("RectangleShape2D_kiuk5") + +[node name="ScoreRight" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="ScoreRight"] +position = Vector2(1184, 324) +shape = SubResource("RectangleShape2D_kwmsh") + +[node name="Hud" type="CanvasLayer" parent="."] + +[node name="PlayerScore" type="Label" parent="Hud"] +offset_left = 465.0 +offset_top = 5.0 +offset_right = 515.0 +offset_bottom = 55.0 +theme_override_fonts/font = ExtResource("2_aa451") +theme_override_font_sizes/font_size = 50 +text = "0 +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="CPUScore" type="Label" parent="Hud"] +offset_left = 648.0 +offset_top = 5.0 +offset_right = 698.0 +offset_bottom = 55.0 +theme_override_fonts/font = ExtResource("2_aa451") +theme_override_font_sizes/font_size = 50 +text = "0 +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ballTimer" type="Timer" parent="."] +one_shot = true +autostart = true + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="PauseMenu" parent="CanvasLayer" instance=ExtResource("7_v2uy6")] + +[node name="scorePlayer" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("8_pp1l6") +volume_db = -3.0 +pitch_scale = 3.39 + +[node name="scoreCPU" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("9_o8ttd") +volume_db = -3.0 +pitch_scale = 2.8 + +[node name="ballCollisionSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("10_soomi") + +[connection signal="body_entered" from="ScoreLeft" to="." method="_on_score_left_body_entered"] +[connection signal="body_entered" from="ScoreRight" to="." method="_on_score_right_body_entered"] +[connection signal="timeout" from="ballTimer" to="." method="_on_ball_timer_timeout"] diff --git a/scenes/mainMenu/main_menu.tscn b/scenes/mainMenu/main_menu.tscn new file mode 100644 index 0000000..e2c51d5 --- /dev/null +++ b/scenes/mainMenu/main_menu.tscn @@ -0,0 +1,26 @@ +[gd_scene format=3 uid="uid://dto1knped7shp"] + +[node name="mainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] +layout_mode = 2 + +[node name="Start Game" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Options" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Quit" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 diff --git a/scenes/pauseMenu/pause_menu.gd b/scenes/pauseMenu/pause_menu.gd new file mode 100644 index 0000000..7d62840 --- /dev/null +++ b/scenes/pauseMenu/pause_menu.gd @@ -0,0 +1,37 @@ +extends Control + + +# Called when the node enters the scene tree for the first time. +func _ready(): + $AnimationPlayer.play("RESET") + +func resume(): + get_tree().paused = false + $AnimationPlayer.play_backwards("blur") + +func pause(): + get_tree().paused = true + $AnimationPlayer.play("blur") + +func Esc(): + if Input.is_action_just_pressed("pause") and get_tree().paused == false: + pause() + elif Input.is_action_just_pressed("pause") and get_tree().paused == true: + resume() + +# This button will resume the game. +func _on_resume_pressed(): + resume() + +# This button will restart the game, 0 to 0. +func _on_restart_pressed(): + resume() + get_tree().reload_current_scene() + +# This is a quit button, this will close the game completly. +func _on_quit_pressed(): + get_tree().quit() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + Esc() diff --git a/scenes/pauseMenu/pause_menu.gdshader b/scenes/pauseMenu/pause_menu.gdshader new file mode 100644 index 0000000..85e9e2a --- /dev/null +++ b/scenes/pauseMenu/pause_menu.gdshader @@ -0,0 +1,9 @@ +shader_type canvas_item; +uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap; + +uniform float lod: hint_range(0.0, 5) = 0.0; + +void fragment(){ + vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV, lod); + COLOR = color; +} \ No newline at end of file diff --git a/scenes/pauseMenu/pause_menu.tscn b/scenes/pauseMenu/pause_menu.tscn new file mode 100644 index 0000000..f2d4456 --- /dev/null +++ b/scenes/pauseMenu/pause_menu.tscn @@ -0,0 +1,130 @@ +[gd_scene load_steps=8 format=3 uid="uid://tof3b3hl57pc"] + +[ext_resource type="FontFile" uid="uid://bk2qwj2aovtrp" path="res://assets/pixel_font.ttf" id="1_1pmcj"] +[ext_resource type="Shader" path="res://scenes/pauseMenu/pause_menu.gdshader" id="1_22xeq"] +[ext_resource type="Script" path="res://scenes/pauseMenu/pause_menu.gd" id="1_prow0"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ky6mg"] +shader = ExtResource("1_22xeq") +shader_parameter/lod = 0.0 + +[sub_resource type="Animation" id="Animation_lu1dk"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:material:shader_parameter/lod") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("PanelContainer:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 0)] +} + +[sub_resource type="Animation" id="Animation_3ihps"] +resource_name = "blur" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:material:shader_parameter/lod") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 0.8] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("PanelContainer:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_6e33f"] +_data = { +"RESET": SubResource("Animation_lu1dk"), +"blur": SubResource("Animation_3ihps") +} + +[node name="PauseMenu" type="Control"] +process_mode = 3 +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_prow0") + +[node name="ColorRect" type="ColorRect" parent="."] +material = SubResource("ShaderMaterial_ky6mg") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PanelContainer" type="PanelContainer" parent="."] +modulate = Color(1, 1, 1, 0) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -60.0 +offset_top = -40.0 +offset_right = 60.0 +offset_bottom = 40.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] +layout_mode = 2 + +[node name="Resume" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("1_1pmcj") +text = "Resume" + +[node name="Restart" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("1_1pmcj") +text = "Restart" + +[node name="Quit" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("1_1pmcj") +text = "Quit" + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_6e33f") +} + +[connection signal="pressed" from="PanelContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"] +[connection signal="pressed" from="PanelContainer/VBoxContainer/Restart" to="." method="_on_restart_pressed"] +[connection signal="pressed" from="PanelContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]