Adding initial game files.
This commit is contained in:
parent
8a5d7f634c
commit
c5615cbdd8
12 changed files with 229 additions and 0 deletions
4
.editorconfig
Normal file
4
.editorconfig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
/android/
|
||||
18
Paddle.gd
Normal file
18
Paddle.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
const SPEED: float = 350.0
|
||||
|
||||
@export var player_id: int
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('up-%d' % player_id):
|
||||
velocity = Vector2(0, -SPEED)
|
||||
if event.is_action_pressed( 'down-%d' % player_id):
|
||||
velocity = Vector2(0, SPEED)
|
||||
if event.is_action_released('up-%d' % player_id) or \
|
||||
event.is_action_released('down-%d' % player_id):
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
||||
move_and_slide()
|
||||
1
Paddle.gd.uid
Normal file
1
Paddle.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d0dti6pba80ci
|
||||
23
ball.gd
Normal file
23
ball.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
const SPEED : float = 300.0
|
||||
|
||||
func _ready() -> void:
|
||||
initialize()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
func initialize():
|
||||
var extra_offset = 0.0 if randf() < 0.5 else PI
|
||||
var angle = \
|
||||
extra_offset + randf_range(-PI/3.0, PI/3.0)
|
||||
velocity = Vector2(cos(angle), sin(angle)).normalized()
|
||||
position = get_viewport_rect().size / 2.0
|
||||
|
||||
|
||||
func _on_screen_exited() -> void:
|
||||
# update score
|
||||
# reinit after 1 second
|
||||
await get_tree().create_timer (1.0).timeout
|
||||
initialize()
|
||||
1
ball.gd.uid
Normal file
1
ball.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://wrequpaalk7f
|
||||
82
game.tscn
Normal file
82
game.tscn
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://ct7v3x7imstlk"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dd0cxfceqwxca" path="res://prefabs/paddle.tscn" id="1_80nbo"]
|
||||
[ext_resource type="Script" uid="uid://wrequpaalk7f" path="res://ball.gd" id="2_e2o6t"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mwb40"]
|
||||
size = Vector2(1200, 20)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_feb5d"]
|
||||
|
||||
[node name="Root" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 2.0
|
||||
offset_bottom = 2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.184063, 0.191379, 0.203873, 1)
|
||||
|
||||
[node name="MiddleLine" type="ColorRect" parent="."]
|
||||
custom_minimum_size = Vector2(4, 0)
|
||||
layout_mode = 1
|
||||
anchors_preset = 13
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.938114, 0.940897, 0.945648, 1)
|
||||
|
||||
[node name="TopWall" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TopWall"]
|
||||
position = Vector2(571, 0)
|
||||
shape = SubResource("RectangleShape2D_mwb40")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="TopWall"]
|
||||
polygon = PackedVector2Array(-30, -10, -30, 10, 1172, 10, 1172, -10)
|
||||
|
||||
[node name="BottomWall" type="StaticBody2D" parent="."]
|
||||
position = Vector2(0, 649)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BottomWall"]
|
||||
position = Vector2(571, 0)
|
||||
shape = SubResource("RectangleShape2D_mwb40")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="BottomWall"]
|
||||
polygon = PackedVector2Array(-30, -10, -30, 10, 1172, 10, 1172, -10)
|
||||
|
||||
[node name="Paddle-0" parent="." instance=ExtResource("1_80nbo")]
|
||||
position = Vector2(40, 273)
|
||||
|
||||
[node name="Paddle-1" parent="." instance=ExtResource("1_80nbo")]
|
||||
position = Vector2(1078, 273)
|
||||
player_id = 1
|
||||
|
||||
[node name="Ball" type="CharacterBody2D" parent="."]
|
||||
position = Vector2(134, 72)
|
||||
motion_mode = 1
|
||||
script = ExtResource("2_e2o6t")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="Ball"]
|
||||
polygon = PackedVector2Array(100, 75, 120, 75, 120, 95, 100, 95)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ball"]
|
||||
position = Vector2(110, 85)
|
||||
shape = SubResource("RectangleShape2D_feb5d")
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="Ball"]
|
||||
position = Vector2(110, 85)
|
||||
|
||||
[connection signal="screen_exited" from="Ball/VisibleOnScreenNotifier2D" to="Ball" method="_on_screen_exited"]
|
||||
1
icon.svg
Normal file
1
icon.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><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 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
||||
|
After Width: | Height: | Size: 994 B |
37
icon.svg.import
Normal file
37
icon.svg.import
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ba4whcm6uncvu"
|
||||
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
|
||||
18
prefabs/paddle.tscn
Normal file
18
prefabs/paddle.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dd0cxfceqwxca"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0dti6pba80ci" path="res://Paddle.gd" id="1_q73f6"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_e2o6t"]
|
||||
size = Vector2(33, 105)
|
||||
|
||||
[node name="Paddle" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_q73f6")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||
position = Vector2(8, 60)
|
||||
polygon = PackedVector2Array(-8, -60, 25, -60, 25, 45, -8, 45)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(16.5, 52.5)
|
||||
shape = SubResource("RectangleShape2D_e2o6t")
|
||||
39
project.godot
Normal file
39
project.godot
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
; 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="2025-08-23 Learning"
|
||||
run/main_scene="uid://ct7v3x7imstlk"
|
||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[input]
|
||||
|
||||
up-0={
|
||||
"deadzone": 0.2,
|
||||
"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":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
down-0={
|
||||
"deadzone": 0.2,
|
||||
"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":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
up-1={
|
||||
"deadzone": 0.2,
|
||||
"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":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
down-1={
|
||||
"deadzone": 0.2,
|
||||
"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":75,"key_label":0,"unicode":107,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue