commit 6f558eb49f02ec2b73aff943d150ee26da6e3219 Author: DJh2o2 Date: Thu Feb 22 10:54:47 2024 +0100 init diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/.idea/.idea.01 - Pong.dir/.idea/.gitignore b/.idea/.idea.01 - Pong.dir/.idea/.gitignore new file mode 100644 index 0000000..520bbd6 --- /dev/null +++ b/.idea/.idea.01 - Pong.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.01 - Pong.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.01 - Pong.dir/.idea/encodings.xml b/.idea/.idea.01 - Pong.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.01 - Pong.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.01 - Pong.dir/.idea/indexLayout.xml b/.idea/.idea.01 - Pong.dir/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.01 - Pong.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.01 - Pong/.idea/.gitignore b/.idea/.idea.01 - Pong/.idea/.gitignore new file mode 100644 index 0000000..b9e2841 --- /dev/null +++ b/.idea/.idea.01 - Pong/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.01 - Pong.iml +/contentModel.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.01 - Pong/.idea/encodings.xml b/.idea/.idea.01 - Pong/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.01 - Pong/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.01 - Pong/.idea/indexLayout.xml b/.idea/.idea.01 - Pong/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.01 - Pong/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/01 - Pong.csproj b/01 - Pong.csproj new file mode 100644 index 0000000..f3b4625 --- /dev/null +++ b/01 - Pong.csproj @@ -0,0 +1,9 @@ + + + net6.0 + net7.0 + net8.0 + true + Pong + + \ No newline at end of file diff --git a/01 - Pong.sln b/01 - Pong.sln new file mode 100644 index 0000000..390a71d --- /dev/null +++ b/01 - Pong.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01 - Pong", "01 - Pong.csproj", "{FAC0EE5C-7341-47F3-8BDA-1405682E5643}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {FAC0EE5C-7341-47F3-8BDA-1405682E5643}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/Player.cs b/Player.cs new file mode 100644 index 0000000..6a733ed --- /dev/null +++ b/Player.cs @@ -0,0 +1,23 @@ +using Godot; + +public partial class Player : Node2D { + [Export] private int playerNumber; + [Export] private int speed = 10; + public override void _UnhandledKeyInput(InputEvent @event) { + Vector2 position = Position; + + if (playerNumber == 1) { + if (@event.IsAction("Player1Up")) position.Y -= speed; + else if (@event.IsAction("Player1Down")) position.Y += speed; + } + else { + if (@event.IsAction("Player2Up")) position.Y -= speed; + else if (@event.IsAction("Player2Down")) position.Y += speed; + } + + if (position.Y > 520) position.Y = 520; + if (position.Y < 0) position.Y = 0; + + Position = position; + } +} diff --git a/Player.png b/Player.png new file mode 100644 index 0000000..dae9ed4 Binary files /dev/null and b/Player.png differ diff --git a/Player.png.import b/Player.png.import new file mode 100644 index 0000000..d62498d --- /dev/null +++ b/Player.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://4fir02w0nns3" +path="res://.godot/imported/Player.png-3b381e068d1d74cc2895fb9be41402b0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Player.png" +dest_files=["res://.godot/imported/Player.png-3b381e068d1d74cc2895fb9be41402b0.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/ball.tscn b/ball.tscn new file mode 100644 index 0000000..60a6410 --- /dev/null +++ b/ball.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://bxkg2ri346c2o"] + +[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_toecu"] +size = Vector2(30, 30) + +[node name="Ball" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(16, 16) +scale = Vector2(1, 1.14) +texture = SubResource("PlaceholderTexture2D_toecu") 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..e4dbb10 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dabejs0csa57v" +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/player.tscn b/player.tscn new file mode 100644 index 0000000..b0cf34a --- /dev/null +++ b/player.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=3 uid="uid://dbgbygehmmopa"] + +[ext_resource type="Script" path="res://Player.cs" id="1_cs5ta"] +[ext_resource type="Texture2D" uid="uid://4fir02w0nns3" path="res://Player.png" id="2_jdmud"] + +[node name="Player1" type="Node2D"] +script = ExtResource("1_cs5ta") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(16, 200) +texture = ExtResource("2_jdmud") diff --git a/pong.tscn b/pong.tscn new file mode 100644 index 0000000..f80f78a --- /dev/null +++ b/pong.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://3acuhn3ykmnq"] + +[ext_resource type="PackedScene" uid="uid://dbgbygehmmopa" path="res://player.tscn" id="1_7bgs4"] +[ext_resource type="PackedScene" uid="uid://bxkg2ri346c2o" path="res://ball.tscn" id="2_dcxy0"] + +[node name="Pong" type="Node2D"] + +[node name="Player1" parent="." instance=ExtResource("1_7bgs4")] +position = Vector2(128, 256) +playerNumber = 1 + +[node name="Player2" parent="." instance=ExtResource("1_7bgs4")] +position = Vector2(1080, 256) +playerNumber = 2 + +[node name="Ball" parent="." instance=ExtResource("2_dcxy0")] +position = Vector2(560, 304) diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..a6cfe80 --- /dev/null +++ b/project.godot @@ -0,0 +1,43 @@ +; 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="01 - Pong" +run/main_scene="res://pong.tscn" +config/features=PackedStringArray("4.3", "C#", "Forward Plus") +config/icon="res://icon.svg" + +[dotnet] + +project/assembly_name="01 - Pong" + +[input] + +Player1Up={ +"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":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +] +} +Player1Down={ +"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":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +] +} +Player2Up={ +"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":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +Player2Down={ +"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":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +}