commit a035b749e56af791acf9868dc963c223aee90239 Author: louis.drilltzsch@gmail.com Date: Wed Jul 1 23:25:37 2026 +0200 init first deploy erster Upload diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 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..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..6c7d8f7 --- /dev/null +++ b/project.godot @@ -0,0 +1,40 @@ +; 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 v1" +run/main_scene="uid://bbjstb404m82i" +config/features=PackedStringArray("4.7", "GL Compatibility") + +[display] + +window/size/window_width_override=4608 +window/size/window_height_override=2592 +window/stretch/mode="canvas_items" + +[file_customization] + +folder_colors={ +"res://res/": "red", +"res://scene/": "blue", +"res://scripts/": "green" +} + +[physics] + +3d/physics_engine="Jolt Physics" + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +rendering_device/driver.windows="d3d12" +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/res/ball.png b/res/ball.png new file mode 100644 index 0000000..c0f09a9 Binary files /dev/null and b/res/ball.png differ diff --git a/res/ball.png.import b/res/ball.png.import new file mode 100644 index 0000000..7f4b2d6 --- /dev/null +++ b/res/ball.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://da8abrotmo5ak" +path="res://.godot/imported/ball.png-5185ee4583a020e7d5eee4c0e66e0b9f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ball.png" +dest_files=["res://.godot/imported/ball.png-5185ee4583a020e7d5eee4c0e66e0b9f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/res/tennis_racket.png b/res/tennis_racket.png new file mode 100644 index 0000000..7be5feb Binary files /dev/null and b/res/tennis_racket.png differ diff --git a/res/tennis_racket.png.import b/res/tennis_racket.png.import new file mode 100644 index 0000000..033e066 --- /dev/null +++ b/res/tennis_racket.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bm7l6nkjhoalt" +path="res://.godot/imported/tennis_racket.png-11d683821eebafa96add1a4cb6453c45.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/tennis_racket.png" +dest_files=["res://.godot/imported/tennis_racket.png-11d683821eebafa96add1a4cb6453c45.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/scene/Ping_Pong_v2.tscn b/scene/Ping_Pong_v2.tscn new file mode 100644 index 0000000..80d6928 --- /dev/null +++ b/scene/Ping_Pong_v2.tscn @@ -0,0 +1,72 @@ +[gd_scene format=3 uid="uid://bbjstb404m82i"] + +[ext_resource type="Script" uid="uid://dfyo1afvep6t6" path="res://scripts/Main.gd" id="1_qr3af"] +[ext_resource type="Script" uid="uid://cqsd7fd7uxl02" path="res://scripts/ball.gd" id="2_qr3af"] +[ext_resource type="Texture2D" uid="uid://da8abrotmo5ak" path="res://res/ball.png" id="3_s0gh3"] +[ext_resource type="Script" uid="uid://gqr2e4p78fj0" path="res://scripts/plank_right.gd" id="4_qr3af"] +[ext_resource type="Texture2D" uid="uid://bm7l6nkjhoalt" path="res://res/tennis_racket.png" id="5_dajfr"] +[ext_resource type="Script" uid="uid://unjro3ilrl38" path="res://scripts/plank_left.gd" id="6_qr3af"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_j8iw7"] +radius = 3.0 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_bfdcr"] +size = Vector2(2, 16) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_j8iw7"] +size = Vector2(2, 16) + +[node name="Main" type="Node2D" unique_id=1753431167 node_paths=PackedStringArray("ball", "score_label")] +script = ExtResource("1_qr3af") +ball = NodePath("Ball") +score_label = NodePath("ScoreLabel") + +[node name="Ball" type="CharacterBody2D" parent="." unique_id=1987649111] +position = Vector2(576, 324) +scale = Vector2(2, 2) +script = ExtResource("2_qr3af") + +[node name="Sprite2D" type="Sprite2D" parent="Ball" unique_id=1376160524] +texture_filter = 1 +texture = ExtResource("3_s0gh3") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ball" unique_id=1355308215] +shape = SubResource("CircleShape2D_j8iw7") + +[node name="SchlaegerRechts" type="CharacterBody2D" parent="." unique_id=757473239] +position = Vector2(1092, 324) +scale = Vector2(2, 5) +motion_mode = 1 +script = ExtResource("4_qr3af") + +[node name="Sprite2D" type="Sprite2D" parent="SchlaegerRechts" unique_id=120109385] +texture_filter = 1 +texture = ExtResource("5_dajfr") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="SchlaegerRechts" unique_id=396129192] +shape = SubResource("RectangleShape2D_bfdcr") + +[node name="SchlaegerLinks" type="CharacterBody2D" parent="." unique_id=339062000] +position = Vector2(60, 324) +scale = Vector2(2, 5) +motion_mode = 1 +script = ExtResource("6_qr3af") + +[node name="Sprite2D" type="Sprite2D" parent="SchlaegerLinks" unique_id=295421432] +texture_filter = 1 +texture = ExtResource("5_dajfr") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="SchlaegerLinks" unique_id=297131425] +shape = SubResource("RectangleShape2D_j8iw7") + +[node name="ScoreLabel" type="Label" parent="." unique_id=1588816466] +offset_left = 519.0 +offset_top = 216.0 +offset_right = 633.0 +offset_bottom = 266.0 +theme_override_font_sizes/font_size = 36 +text = "Punkt!" +horizontal_alignment = 1 + +[node name="Camera2D" type="Camera2D" parent="." unique_id=966032468] +position = Vector2(576, 324) diff --git a/scripts/Main.gd b/scripts/Main.gd new file mode 100644 index 0000000..99a06dd --- /dev/null +++ b/scripts/Main.gd @@ -0,0 +1,30 @@ +extends Node2D + +@export var ball: CharacterBody2D +@export var score_label: Label + +var score_links : int = 0 +var score_rechts : int = 0 + +func _ready() -> void: + # Automatischer Fallback, falls im Inspektor die Zuweisung vergessen wurde + if not ball: ball = $Ball + if not score_label: score_label = $ScoreLabel + update_score_display() + +func _process(_delta: float) -> void: + # Prüfen, ob der Ball links aus dem Bildschirm fliegt + if ball.global_position.x < 0: + score_rechts += 1 + update_score_display() + ball.reset_ball() + + # Prüfen, ob der Ball rechts aus dem Bildschirm fliegt + elif ball.global_position.x > 1152: + score_links += 1 + update_score_display() + ball.reset_ball() + +func update_score_display() -> void: + if score_label: + score_label.text = str(score_links) + " : " + str(score_rechts) diff --git a/scripts/Main.gd.uid b/scripts/Main.gd.uid new file mode 100644 index 0000000..d7e716d --- /dev/null +++ b/scripts/Main.gd.uid @@ -0,0 +1 @@ +uid://dfyo1afvep6t6 diff --git a/scripts/ball.gd b/scripts/ball.gd new file mode 100644 index 0000000..06f1b19 --- /dev/null +++ b/scripts/ball.gd @@ -0,0 +1,32 @@ +extends CharacterBody2D + +@export var START_SPEED = 300.0 +@export var SPEED_INCREMENT = 20.0 + +var current_speed = START_SPEED +var direction = Vector2.ZERO + +func _ready() -> void: + reset_ball() + +func _physics_process(delta: float) -> void: + # Bewegt den Ball und handhabt die Kollisionen mit den Schlägern + var collision = move_and_collide(direction * current_speed * delta) + + if collision: + direction = direction.bounce(collision.get_normal()) + current_speed += SPEED_INCREMENT + + # Abprallen an den horizontalen Rändern (oben und unten) + if global_position.y < 0 or global_position.y > 648: + direction.y *= -1 + +func reset_ball() -> void: + # Startet exakt in der Mitte des 1152x648 Bildschirms + global_position = Vector2(576, 324) + current_speed = START_SPEED + + # Zufällige Richtung nach links oder rechts starten + var x_dir = 1 if randf() > 0.5 else -1 + var y_dir = randf_range(-0.5, 0.5) + direction = Vector2(x_dir, y_dir).normalized() diff --git a/scripts/ball.gd.uid b/scripts/ball.gd.uid new file mode 100644 index 0000000..9e396fb --- /dev/null +++ b/scripts/ball.gd.uid @@ -0,0 +1 @@ +uid://cqsd7fd7uxl02 diff --git a/scripts/plank_left.gd b/scripts/plank_left.gd new file mode 100644 index 0000000..c7af355 --- /dev/null +++ b/scripts/plank_left.gd @@ -0,0 +1,16 @@ +extends CharacterBody2D + +const SPEED = 500.0 + +func _physics_process(_delta: float) -> void: + var direction = 0 + if Input.is_key_pressed(KEY_S): + direction += 1 + if Input.is_key_pressed(KEY_W): + direction -= 1 + + velocity.y = direction * SPEED + move_and_slide() + + # Begrenzung (angepasst an größere Schläger) + global_position.y = clamp(global_position.y, 54, 594) diff --git a/scripts/plank_left.gd.uid b/scripts/plank_left.gd.uid new file mode 100644 index 0000000..133e65a --- /dev/null +++ b/scripts/plank_left.gd.uid @@ -0,0 +1 @@ +uid://unjro3ilrl38 diff --git a/scripts/plank_right.gd b/scripts/plank_right.gd new file mode 100644 index 0000000..63640b6 --- /dev/null +++ b/scripts/plank_right.gd @@ -0,0 +1,16 @@ +extends CharacterBody2D + +const SPEED = 400.0 + +func _physics_process(_delta: float) -> void: + var direction = 0 + if Input.is_action_pressed("ui_down"): + direction += 1 # Nach unten + if Input.is_action_pressed("ui_up"): + direction -= 1 # Nach oben + + velocity.y = direction * SPEED + move_and_slide() + + # Begrenzt den Schläger, damit er nicht aus dem Bildschirm fliegt + global_position.y = clamp(global_position.y, 54, 594) diff --git a/scripts/plank_right.gd.uid b/scripts/plank_right.gd.uid new file mode 100644 index 0000000..72338d3 --- /dev/null +++ b/scripts/plank_right.gd.uid @@ -0,0 +1 @@ +uid://gqr2e4p78fj0