Paddle-Ball 1.01

This commit is contained in:
HomeMadeGames Studio 2024-07-16 23:00:08 -04:00
commit facc1dac5a
29 changed files with 834 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

7
README.md Normal file
View File

@ -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

BIN
assets/Bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

34
assets/Bg.png.import Normal file
View File

@ -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

Binary file not shown.

View File

@ -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

BIN
assets/audio/score.wav Normal file

Binary file not shown.

View File

@ -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

BIN
assets/audio/scoreCPU.wav Normal file

Binary file not shown.

View File

@ -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

BIN
assets/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

34
assets/icon.webp.import Normal file
View File

@ -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

BIN
assets/pixel_font.ttf Normal file

Binary file not shown.

View File

@ -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={}

BIN
assets/score.wav Normal file

Binary file not shown.

24
assets/score.wav.import Normal file
View File

@ -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

62
export_presets.cfg Normal file
View File

@ -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}'"

1
icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
icon.svg.import Normal file
View File

@ -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

27
project.godot Normal file
View File

@ -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)
]
}

59
scenes/Ball.gd Normal file
View File

@ -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()

26
scenes/CPU.gd Normal file
View File

@ -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)

19
scenes/Player.gd Normal file
View File

@ -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)

27
scenes/main.gd Normal file
View File

@ -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()

170
scenes/main.tscn Normal file
View File

@ -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"]

View File

@ -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

View File

@ -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()

View File

@ -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;
}

View File

@ -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"]